Proofs: Pettie-Ramachandran optimal MST algorithm
These are the human proofs of Pettie-Ramachandran optimal MST algorithm, at full length.
OPTIMAL-MSF returns the minimum spanning forest for every behaviour of the soft heap full
This proof shows: correctness, termination.
Claim. Let be a finite undirected multigraph with real weights; self-loops, parallel edges, ties and several components are allowed. Order the edges by the key , so that all keys are distinct, and let be the unique minimum spanning forest of a graph for this order. Then OPTIMAL-MSF stops and returns , whichever keys the soft heap corrupts. With ties in , is a minimum spanning forest for , since Kruskal's algorithm with the key order is a valid run of Kruskal's algorithm for .
The running time bound is the main theorem of Pettie and Ramachandran and is not proved here.
Facts about minimum spanning forests
All graphs below have distinct keys. Contracting edges keeps the edge identities, and self-loops are removed after a contraction.
Fact 1 (cut property). If and is the least edge of with exactly one end in , then .
Fact 2 (subgraphs). If and , then . Proof. An edge is outside the MSF of a graph if and only if it is the largest edge on some cycle of that graph (cycle property). A cycle of is a cycle of , so if were the largest edge on a cycle of , it would not be in .
Fact 3 (contraction). If , then .
Proof of Fact 3. Let and the number of components of , so . The set is a forest of : a cycle in it would lift to a cycle in through edges of . It has edges, and has vertices (each edge of the forest merges two vertices) and components, so is a spanning forest of . It is the minimum one: for , , so is the largest edge on the cycle formed by and the path of between its ends (cycle property for spanning forests); contracting maps this cycle to a closed walk in through whose other edges are in and lighter than , which contains a cycle through (the edge is not a self-loop of , since ). So every edge of outside is the largest on a cycle of , and .
Fact 4 (sandwich). If , then . Proof. By Fact 2, . Both are spanning forests with the components of , since contains and lies inside , so they have the same number of edges and are equal.
Step 1: the forest F of line L4 lies in MSF(G \ C)
Consider the growth of one piece in PARTITION. Let be the final corrupted set of the call, which contains every edge whose key was raised in any heap.
Lemma 1. At each extraction of an uncorrupted edge from the heap of , has the least key among the edges of with exactly one end in .
Proof. Let be an edge of with one end and the other end . When joined , was not in , and was not in (it is never in ), so was inserted. It has not been extracted: an extracted edge is put into (if corrupted), skipped because both ends are in , used as a link (which ends the growth), or used to grow (which puts its other end in ); none of these fits . So is in the heap, with its true key, since it is not in . The heap returns the least current key, and is uncorrupted, so the key of is less than the key of .
By Fact 1 applied to , every edge that grows a piece and every link edge is in . Each growth edge has both ends in its piece and is not in , so the growth edges of piece form a spanning tree of . By Fact 2, , and since spans the connected graph it lives in, . Lemma 1 also holds for earlier pieces after later pieces add edges to , since adding edges to only removes competitors. No edge of or of a is ever put into : it was extracted uncorrupted, and afterwards both of its ends are dead, so it never enters a heap again; a link edge that had been corrupted in an earlier heap would be in already and would not have been inserted. So
Step 2: G_B contains MSF(G)
By Fact 3 with , , where is the forest of line L6, read as edges of . Each edge of is either in , or in and then, by Fact 2, in . So
and by Fact 4, .
Step 3: the Borůvka steps and the recursion
In a Borůvka step on a graph , each vertex chooses the least edge at it; by Fact 1 with the vertex, every chosen edge is in . Contracting the chosen edges and applying Fact 3, . Two steps give .
Termination. We use induction on the number of vertices. If has no edge other than self-loops, line L1 returns . Otherwise is not empty and lies in , so the first Borůvka step chooses at least one edge that is not a self-loop and has fewer vertices than . By induction, line L9 returns .
So line L10 returns . The argument used no property of which keys the heap corrupts, so it holds for every soft heap, and also for an exact heap, where .