动态最小生成树

编程入门 行业动态 更新时间:2024-10-27 06:19:57
本文介绍了动态最小生成树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想打一个动态最小生成树。我有一个现有的MS树在n个顶点,我再加上一个顶点和边从这个新的顶点所有现有的顶点。如何更新的MST为有效的新的图形?为O(n)将是最佳的。我也可以使删除顶点运行效率?

I want to make a dynamic minimum spanning tree. I have an existing MS tree over n vertices and I add one more vertex and edges to all the existing vertices from this new vertex. How can I update the MST for the new graph efficiently? O(n) would be optimal. Can I also make delete vertex operation efficient?

推荐答案

为O(n log n)的使用Kruskal算法。关键思想是在原始的MST不使用任何边缘,不会在新的MST使用,也可以。因此,只要排序 N 新边为O(n log n)的,合并此排序列表的边缘名单老MST(你保持有序,对吧?) O(N),然后边产生的排序列表上运行Kruskal算法重新O(n)的-ish 。

O(n log n) using Kruskal's algorithm. The key idea is any edges not used in the original MST will not be used in the new MST either. So just sort the n new edges O(n log n), merge this sorted list with the list of edges of the old MST (which you kept in sorted order, right?) O(n), then run Kruskal's algorithm anew on the resulting sorted list of edges O(n)-ish.

更多推荐

动态最小生成树

本文发布于:2023-11-30 21:19:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651497.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最小   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!