Reputation: 2723
Let
G(V,E)
an undirected and connected graph with the weight functionw
. We are givenT
, an MST ofG
. Now we removee1, e2, e3
fromG
(which also appear inT
) and get a new graph,G'
. Describe an efficient algorithm to find an MST ofG'
.
My intuition tells me that we can throw those 3
edges and run Prim algorithm for G'
starting from T-{e1, e2,e3}
.
Is my intuition correct? Could help me formulate this (Or suggest another approach)?
Upvotes: 1
Views: 87
Reputation: 10458
You can solve it using Kruskal's Algorithm where you start traversing the edges which have a weight >= max(e1,e2,e3) from the set { S-{e1,e2,e3} }. Before this step the graph would have all the edges you need.
Upvotes: 1
Reputation: 172
Prim's algorithm grows a tree T in G from a single vertex by adding edges, but removing an edge from T makes it disconnected, so you cannot use this as partial input for the algorithm.
You can however use Kruskal's agorithm, which grows a forest T until it is connected. Deleting one edge of T from the G requires one new step of the algorithm. The proof is along the lines of the proof of correctness for the algorithm itself.
Upvotes: 1