I have a possible solution for the following question, but not sure if correct:
Assume we have already found a minimum spanning tree T
for a weighted, undirected graph G = (V,E)
. We would like to be able to efficiently update T
should G
be altered slightly.
An edge is added to G
to produce a new graph. Give an algorithm that uses T
to find a minimum spanning tree for the new graph in O(|V|)
time.
My algorithm:
for each vertex do
if smallest edge not in T then
replace this edge with existing edge in T
break
end if
end for
I do not have much experience in writing pseudocode, so my algorithm might be over-simplified or incorrect. Please correct me if I am wrong. Thanks!
mst = 1 or 0 . After deleting an MST edge, search outward along the MST from each vertex, marking each vertex as part of the 'left' or 'right' halves of the split MST. This takes O(E) each side. Then for all edges (u, v) if u and v are in different MST halves, keep the smallest such edge and add it to the MST.
We will prove that adding an edge to it creates a cycle. Since G is a tree, any 2 vertices have a unique simple path between them. Therefore, if an edge is added between 2 vertices, those vertices will now have multiple paths between them.
Let G=(V,E) undirected connected graph, w:E→R weight function. Let T a MST (minimum spanning tree) of G. Now, we add a new edge e′ to E with weight w(e′). Find an algorithm that updates T so it will be a MST of the new graph G′=(V,E∪{e′}).
Don't know if your algorithm is correct, but it doesn't seem O(|V|)
at least, because getting the "smallest edge not in T" of a vertex cannot be done in O(1)
.
The most usual way to add an edge e=(u, v)
into a MST T
is:
T
from u
to v
to detect the edge with maximum value in that path. (O(|V|)
)O(1)
).The rationale behind this solution is that simply adding the edge into T
would create exactly one cycle, and to restore the MST property you have to remove the edge with maximum value from that cycle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With