Algorithm Search⌘K

Proofs: Generic minimum spanning tree method

These are the human proofs of Generic minimum spanning tree method, at full length.

The generic MST method returns a minimum spanning forest for every choice of cuts full

This proof shows: correctness, termination.

Claim. Let G=(V,E)G = (V, E) be a finite undirected graph with nn vertices, cc components and a real weight on each edge; ties, parallel edges and self-loops are allowed. For each sequence of choices made at line L3, GENERIC-MST stops after exactly n−cn - c iterations, and the set AA that it returns is a minimum spanning forest of GG.

Setup. A spanning forest is an acyclic edge set with the components of GG; each has n−cn - c edges. A cut (S,V∖S)(S, V \setminus S) respects AA when no edge of AA has exactly one end in SS.

Lemma 1. If AA is a forest, a cut (S,V∖S)(S, V \setminus S) respects AA if and only if SS is a union of vertex sets of trees of (V,A)(V, A). Each edge that crosses such a cut joins two different trees of (V,A)(V, A).

Proof. If SS is a union of trees, each edge of AA lies in one tree and has both ends in SS or both outside. Conversely, if SS cuts a tree, the tree has a vertex in SS and one outside, and the path between them in the tree has an edge with exactly one end in SS. For the second part, an edge with one end in SS and one outside cannot have both ends in one tree, because each tree is inside SS or outside it. □\square

Lemma 2 (the cut property, forest form). If AA is a subset of some minimum spanning forest F∗F^*, the cut (S,V∖S)(S, V \setminus S) respects AA, and ee is a light edge of the cut, then A∪{e}A \cup \{e\} is a subset of some minimum spanning forest.

Proof. If e∈F∗e \in F^* we are done. Else let e=(u,v)e = (u, v), u∈Su \in S, v∉Sv \notin S. The vertices uu and vv are in one component of GG, so F∗F^* has a path PP from uu to vv, and PP has an edge ff that crosses the cut; f∉Af \notin A because AA respects the cut. The set F′=F∗−f+eF' = F^* - f + e is a spanning forest: removing ff splits one tree into a part with uu and a part with vv, and ee joins them again. Since ee is light, w(e)≤w(f)w(e) \le w(f) and w(F′)≤w(F∗)w(F') \le w(F^*), so F′F' is minimum, and it contains A∪{e}A \cup \{e\}. □\square

Invariant. At the test of line L2, AA is a subset of some minimum spanning forest, and in particular AA is a forest.

  1. Initialization. A=∅A = \emptyset is a subset of every minimum spanning forest, and one exists because EE is finite and contains a spanning forest.
  2. Maintenance. The cut of line L3 respects AA, and the edge of line L4 is light for it. Lemma 2 shows that A∪{(u,v)}A \cup \{(u, v)\} is a subset of some minimum spanning forest, so the invariant holds after line L5. The edge of line L4 exists, since line L3 chooses a cut that some edge crosses. Such a cut exists whenever the test of line L2 is true: the tree at one end of an edge that joins two trees is a valid SS.

Termination. By Lemma 1, the edge added at line L5 joins two different trees of (V,A)(V, A), so AA stays a forest and its number of trees drops by exactly one in each iteration. The number of trees starts at nn and is never less than cc, because the trees of AA lie inside the components of GG. So there are at most n−cn - c iterations, and the loop stops.

Conclusion. When the test of line L2 is false, no edge of GG joins two different trees of (V,A)(V, A). So each component of GG lies inside one tree of AA, and each tree of AA lies inside one component of GG. Thus AA is a spanning forest, with n−cn - c edges, and the loop ran exactly n−cn - c times. By the invariant, A⊆F∗A \subseteq F^* for a minimum spanning forest F∗F^*, which also has n−cn - c edges, so A=F∗A = F^*. ■\blacksquare

Back to Generic minimum spanning tree method