Proofs: Borůvka's algorithm
These are the human proofs of Borůvka's algorithm, at full length.
Borůvka's algorithm returns a minimum spanning forest in at most floor(lg n) + 1 rounds full
This proof shows: correctness, termination.
Claim. Let be a finite undirected graph with vertices and a real weight on each edge, with ties, parallel edges and self-loops allowed, and not necessarily connected. Let be the strict total order on given by in lexicographic order, with distinct ids. Then BORŮVKA stops after at most rounds and returns a minimum spanning forest of .
Setup. Let be the number of components of . Each spanning forest of has edges. For , an edge crosses when it has exactly one end in . Let be the output of Kruskal's algorithm when line L3 of that algorithm sorts the edges by . Since lists the edges in non-decreasing order of weight, is a minimum spanning forest of , by the correctness of Kruskal's algorithm.
Lemma 1. If and is the -least edge that crosses , then .
Proof. Let with , . When Kruskal's algorithm reaches , it has seen only edges , and none of them crosses . So each tree of its current forest has all its vertices in or all outside , and and are in different trees. Kruskal's algorithm therefore adds .
Lemma 2 (invariant). At the start of each round, . In particular is a forest.
Proof. By induction on the rounds. Before the first round . Assume at the start of a round. Line L3 labels the trees of . For a tree , after the loop of lines L5 to L8, is nil if no edge crosses the vertex set of , and otherwise it is the -least edge that crosses it, because the loop looks at every edge that crosses (each such edge has with one of the two) and keeps the least one. By Lemma 1, each edge of is in . So after line L10. A subset of a forest is a forest.
Lemma 3 (rounds). Call a tree of open if some edge of crosses its vertex set. If a round starts with open trees, the next round starts with at most open trees.
Proof. A tree that is not open is a whole component of . It picks nothing, no edge reaches it, and it stays as it is and not open. Each open tree picks the edge , which joins to a different tree , and is open too, since that edge crosses it. So after line L10, each new tree that contains an open tree contains at least two old open trees. A new tree that is open contains at least one old open tree, because a new tree made only of closed trees is a single closed tree. So each new open tree contains at least two old open trees, the new open trees are disjoint, and there are at most of them.
Termination and the count. At the start of round 1 there are open trees. By Lemma 3, round starts with open trees. A round adds an edge if and only if , and if then , because an open tree has an edge to another tree of its component, and that tree is open too. So a round that adds edges needs , that is , so at most rounds add edges. The round after the last of them has and stops the loop at line L11. In total there are at most rounds. Each round does a finite amount of work, so the algorithm stops.
Conclusion. In the last round , so no edge crosses the vertex set of any tree of . Then each edge of has both ends in one tree of , so each component of lies inside one tree of . Since , each tree of lies inside one component of . So has the components of and, by Lemma 2, is a forest: it is a spanning forest with edges. Lemma 2 also gives , and has edges, so , a minimum spanning forest.
Why the strict order is needed. In a triangle with three edges of weight 1, the order by weight alone allows , and . Then is the whole triangle, which is a cycle. Lemma 1 fails for such picks, because each of the three edges is a lightest edge of its cut but they are not all in one spanning tree.