You are given a weighted undirected graph G = (V,E). You have run Prim's algorithm and found the MST of this graph. Now you pick one edge that is not part of the MST and reduce its weight by some value. You now want to come up with a smart way to find the new MST of the graph.

My approach would be the following. Take this edge (u,v) that you changed and add it to your MST. Start from u and travel around in your MST until you end up back in u, since it is guaranteed that after inserting (u,v) you will create a cycle (MST is a tree). Then from the cycle that you found, remove the edge with the maximum weight.

I feel like this is correct but I don't know how to prove it. Can someone guide me?

Here's what I've tried:

My intuition about the problem is the following. Let's call T, the MST that we found before updating an edge (u,v). Now after updating this edge (u,v), let's just add it to our MST. What is the resulting structure? Since we connect two nodes that are part of the MST with an edge that was previously not in the MST, we create a cycle. Of course this indicates that some edge/edges need to go, since what we just created is not a valid MST. We can not remove any edges that are not part of the cycle that we just created, since this action would give us two components that are not connected. If we look at the cycle that we created, we can only remove exactly one edge and no more than that. Since we want to minimize the weight of all the edges part of the MST, we simply remove the edge with the largest weight. So in the end we get something that is definitely a spaning tree, and it is also minimal. Proving that it's spanning tree is trivial. To prove the latter, the edges that are not part of the cycle, should definitely be part of some MST (they are light edges of some cut), so it's ok to leave them there, as for the cycle removing the max weight will give a min total weight.

  • $\begingroup$ What have you tried? Why do you feel it is correct? What properties does the result have to have, for it to be correct ? It has to be a MST, right? So you need to prove (a) it is a ST, (b) it is minimal. Have you tried proving either of those? We want to give you understanding, not just solve our exercise for you, so we want you to show us your thoughts in the question. Try using these questions/prompts to help you make more progress, and then edit the question to show us how far you've gotten. $\endgroup$
    – D.W.
    Commented May 19, 2015 at 18:23

1 Answer 1


You are definitely on the right track. As D.W. notes, you have to prove two things:

  1. The new tree is a spanning tree.
  2. There is no spanning tree of lower total weight (i.e. minimality).

For (1), consider what it means to be a spanning tree:

  • Every vertex must be a part of it (this is the spanning part).
  • It must be a tree (i.e. a connected acyclic graph).

So with your construction, you have a starting MST $T$ for the graph $G$, and you create a new potential MST $T'$ for $G'$, which is $G$ with a single modified edge weight (which may or may not be the added edge).

  • Is every vertex of $G$ (and hence $G'$) in $T'$?
  • Is $T'$ connected?

For (2), you want to show that there's no other tree that is better. Proofs of this kind are normally done by contradiction. So start by assume there is a tree $R$ that is a spanning tree of $G'$ and has lower weight than $T'$, what would this imply?

In thinking about this consider what it means for $R$ to be different, and what this would imply for $T$, the original MST.

  • $\begingroup$ For (2), could you please show me more details? I cannot work out an answer. Thanks. $\endgroup$
    – hengxin
    Commented Jun 3, 2015 at 8:38
  • $\begingroup$ @hengxin Assume that there is such an $R$ (we can assume it's an MST), as it has a smaller weight than $T'$ (note the weight of $T'$ is less than or equal to that of $T$ as well). Then there's an edge in $R$ that's not in $T'$, Either this edge is the modified edge, in which case it must have weight less than something in the cycle it induces in $T'$ and the algorithm was not followed, or it's a different edge, and we can contradict either the minimality of $R$ by taking a different edge that's in $T'$, or the minimality of $T$, by swapping the new edge for the largest in the induced cycle. $\endgroup$ Commented Jun 3, 2015 at 11:11
  • $\begingroup$ Either this edge is the modified edge: do you mean the edge $e = (u,v)$ whose weight is decreased? By the algorithm for computing $T'$, doesn't $T'$ contain it? If so, how can it be $e \in R \land e \notin T'$? $\endgroup$
    – hengxin
    Commented Jun 3, 2015 at 12:34
  • $\begingroup$ @user76284 because then $R$ wouldn't have weight less than $T'$. $\endgroup$ Commented Apr 22, 2018 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.