How to update MST after deleting an edge from the graph?

為{幸葍}努か 提交于 2019-12-04 16:03:21

Just search the minimum-distance path of the now-disconnected tree portion to the rest of the tree and add that path in between-- which is a single edge.

Say your original tree is T. With the removal of the edge, it is now split into trees T1 and T2.

Take one of these-- say T2. Every edge incident to a node on T2 is either on T2 or is one connecting T2 to T1. Among these edges incident to a node on T2, pick the one which ( (has its other end at a T1 node) and (has the minimum cost among all such edges) ). Search for this edge, say e=(u,v), takes O(|E|) time. O(|N|) if the separated portion is a leaf.

if there were a tree, say T', with less cost than T1 \union T2 \union {e}, then the node sets N1 and N2 of T1 and T2 would have more inter-connections than just one edge,

i.e., there would be two or more more edges on T' that begin at a node in N1 and end at a node in N2. Otherwise, ( (T1 and T2 are minimum spanning trees resply. over N1 and N2) and (e is the least costly connection between T1 and T2) ) would be false. But then, any go-between T1 and T2 is costlier than e=(u,v)-- contradicts.

Skipped some proof details. hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!