Proofs: Reverse-delete algorithm
These are the human proofs of Reverse-delete algorithm, at full length.
Reverse-delete returns a minimum spanning forest full
This proof shows: correctness, termination.
Claim. Let be a finite undirected graph with a real weight on each edge. Weights may tie and may be negative, may have parallel edges and self-loops, and need not be connected. Then REVERSE-DELETE stops, and the set that it returns is a minimum spanning forest of : a forest with the same connected components as , of least total weight among all such forests.
Setup. Let be the edges in the order of line L2, so . Let be the set after is processed, with . An edge is a bridge of if its two ends are not connected in . A self-loop is never a bridge. An edge lies on a cycle of if and only if it is not a bridge: if its ends are connected without it, a simple path from to and the edge form a cycle, and a self-loop is a cycle by itself; conversely, the rest of a cycle through connects its ends. Each spanning forest of has edges, where is the number of components of (spanning forest).
Lemma 1 (bridges stay bridges). If is a bridge of and with , then is a bridge of .
Proof. A path in is also a path in . So if the ends of are not connected in the second graph, they are not connected in the first.
Invariant. For each from to :
- (C) has the same connected components as .
- (K) Each edge with and is a bridge of .
- (M) There is a minimum spanning forest of with .
Initialization. , so (C) holds, (K) is empty, and any minimum spanning forest is a subset of , so (M) holds.
Maintenance, kept. Then , and (C) and (M) carry over. The test of line L4 failed, so is a bridge of . The edges with in were bridges of by (K). So (K) holds.
Maintenance, deleted. Then and are connected in .
-
(C): any path of that uses can replace it by a path from to in . So connectivity does not change.
-
(K): each with in was a bridge of by (K), and it is a bridge of by Lemma 1.
-
(M): if , then and we take . So assume . A self-loop is in no forest, so . Let be a simple path from to in . Then is a cycle in .
Each edge is for some . If , then by (K) is a bridge of , but lies on the cycle of , so it is not a bridge. Hence , and by the order of the sort.
Removing from splits its tree that holds and into a part and a part . The path starts in and ends in , so it has an edge with one end in and the other in . Then , since the only edge of between and is , and . Let . Adding joins and again, so is a forest with the components of , which are those of . Its weight is , since . So is a minimum spanning forest, and , because and .
Termination. The loop of line L3 runs once for each of the edges, and each test of line L4 is a graph search on a finite graph, which stops. So the algorithm stops after steps.
Conclusion. Let . By (K) with , every edge of is a bridge of , so no edge of lies on a cycle, and is a forest. By (C), its components are those of , so is a spanning forest with edges. By (M), contains a minimum spanning forest , which also has edges, so . Therefore is a minimum spanning forest, and a minimum spanning tree when is connected.