Algorithm Search⌘K

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 G=(V,E)G = (V, E) be a finite undirected multigraph with real weights; self-loops, parallel edges, ties and several components are allowed. Order the edges by the key (w(e),index of e)(w(e), \text{index of } e), so that all keys are distinct, and let MSF⁡(H)\operatorname{MSF}(H) be the unique minimum spanning forest of a graph HH for this order. Then OPTIMAL-MSF(G)(G) stops and returns MSF⁡(G)\operatorname{MSF}(G), whichever keys the soft heap corrupts. With ties in ww, MSF⁡(G)\operatorname{MSF}(G) is a minimum spanning forest for ww, since Kruskal's algorithm with the key order is a valid run of Kruskal's algorithm for ww.

The running time bound O(T∗(m,n))O(T^\ast(m, n)) 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 S⊆VS \subseteq V and ee is the least edge of HH with exactly one end in SS, then e∈MSF⁡(H)e \in \operatorname{MSF}(H).

Fact 2 (subgraphs). If H′⊆HH' \subseteq H and e∈MSF⁡(H)∩H′e \in \operatorname{MSF}(H) \cap H', then e∈MSF⁡(H′)e \in \operatorname{MSF}(H'). 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 H′H' is a cycle of HH, so if ee were the largest edge on a cycle of H′H', it would not be in MSF⁡(H)\operatorname{MSF}(H). □\square

Fact 3 (contraction). If F⊆MSF⁡(H)F \subseteq \operatorname{MSF}(H), then MSF⁡(H)=F∪MSF⁡(H/F)\operatorname{MSF}(H) = F \cup \operatorname{MSF}(H / F).

Proof of Fact 3. Let T=MSF⁡(H)T = \operatorname{MSF}(H) and cc the number of components of HH, so ∣T∣=∣V(H)∣−c|T| = |V(H)| - c. The set T∖FT \setminus F is a forest of H/FH / F: a cycle in it would lift to a cycle in TT through edges of FF. It has ∣T∣−∣F∣|T| - |F| edges, and H/FH/F has ∣V(H)∣−∣F∣|V(H)| - |F| vertices (each edge of the forest FF merges two vertices) and cc components, so T∖FT \setminus F is a spanning forest of H/FH / F. It is the minimum one: for e∈(H/F)∖(T∖F)e \in (H/F) \setminus (T \setminus F), e∉Te \notin T, so ee is the largest edge on the cycle formed by ee and the path of TT between its ends (cycle property for spanning forests); contracting FF maps this cycle to a closed walk in H/FH/F through ee whose other edges are in T∖FT \setminus F and lighter than ee, which contains a cycle through ee (the edge ee is not a self-loop of H/FH/F, since e∈H/Fe \in H / F). So every edge of H/FH/F outside T∖FT \setminus F is the largest on a cycle of H/FH/F, and T∖F=MSF⁡(H/F)T \setminus F = \operatorname{MSF}(H/F). □\square

Fact 4 (sandwich). If MSF⁡(H)⊆H′⊆H\operatorname{MSF}(H) \subseteq H' \subseteq H, then MSF⁡(H′)=MSF⁡(H)\operatorname{MSF}(H') = \operatorname{MSF}(H). Proof. By Fact 2, MSF⁡(H)⊆MSF⁡(H′)\operatorname{MSF}(H) \subseteq \operatorname{MSF}(H'). Both are spanning forests with the components of HH, since H′H' contains MSF⁡(H)\operatorname{MSF}(H) and lies inside HH, so they have the same number of edges and are equal. □\square

Step 1: the forest F of line L4 lies in MSF(G \ C)

Consider the growth of one piece SS in PARTITION. Let CC 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 ee from the heap of SS, ee has the least key among the edges of G∖CG \setminus C with exactly one end in SS.

Proof. Let f≠ef \ne e be an edge of G∖CG \setminus C with one end x∈Sx \in S and the other end y∉Sy \notin S. When xx joined SS, yy was not in SS, and ff was not in CC (it is never in CC), so ff was inserted. It has not been extracted: an extracted edge is put into CC (if corrupted), skipped because both ends are in SS, used as a link (which ends the growth), or used to grow SS (which puts its other end in SS); none of these fits ff. So ff is in the heap, with its true key, since it is not in CC. The heap returns the least current key, and ee is uncorrupted, so the key of ee is less than the key of ff. □\square

By Fact 1 applied to H=G∖CH = G \setminus C, every edge that grows a piece and every link edge is in MSF⁡(G∖C)\operatorname{MSF}(G \setminus C). Each growth edge has both ends in its piece and is not in CC, so the growth edges of piece ii form a spanning tree TiT_i of Mi∖CM_i \setminus C. By Fact 2, Ti⊆MSF⁡(Mi∖C)T_i \subseteq \operatorname{MSF}(M_i \setminus C), and since TiT_i spans the connected graph it lives in, MSF⁡(Mi∖C)=Ti\operatorname{MSF}(M_i \setminus C) = T_i. Lemma 1 also holds for earlier pieces after later pieces add edges to CC, since adding edges to CC only removes competitors. No edge of LL or of a TiT_i is ever put into CC: 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 CC already and would not have been inserted. So

F=L∪T1∪⋯∪Ts⊆MSF⁡(G∖C).F = L \cup T_1 \cup \cdots \cup T_s \subseteq \operatorname{MSF}(G \setminus C).

Step 2: G_B contains MSF(G)

By Fact 3 with H=G∖CH = G \setminus C, MSF⁡(G∖C)=F∪MSF⁡((G∖C)/F)=F∪FA\operatorname{MSF}(G \setminus C) = F \cup \operatorname{MSF}((G \setminus C)/F) = F \cup F_A, where FAF_A is the forest of line L6, read as edges of GG. Each edge of MSF⁡(G)\operatorname{MSF}(G) is either in CC, or in G∖CG \setminus C and then, by Fact 2, in MSF⁡(G∖C)\operatorname{MSF}(G \setminus C). So

MSF⁡(G)⊆F∪FA∪C=GB⊆G,\operatorname{MSF}(G) \subseteq F \cup F_A \cup C = G_B \subseteq G,

and by Fact 4, MSF⁡(GB)=MSF⁡(G)\operatorname{MSF}(G_B) = \operatorname{MSF}(G).

Step 3: the Borůvka steps and the recursion

In a Borůvka step on a graph HH, each vertex chooses the least edge at it; by Fact 1 with SS the vertex, every chosen edge is in MSF⁡(H)\operatorname{MSF}(H). Contracting the chosen edges and applying Fact 3, MSF⁡(H)=(chosen)∪MSF⁡(H/chosen)\operatorname{MSF}(H) = (\text{chosen}) \cup \operatorname{MSF}(H / \text{chosen}). Two steps give MSF⁡(GB)=FB∪MSF⁡(GC)\operatorname{MSF}(G_B) = F_B \cup \operatorname{MSF}(G_C).

Termination. We use induction on the number of vertices. If GG has no edge other than self-loops, line L1 returns ∅=MSF⁡(G)\emptyset = \operatorname{MSF}(G). Otherwise MSF⁡(G)\operatorname{MSF}(G) is not empty and lies in GBG_B, so the first Borůvka step chooses at least one edge that is not a self-loop and GCG_C has fewer vertices than GG. By induction, line L9 returns MSF⁡(GC)\operatorname{MSF}(G_C).

So line L10 returns FB∪MSF⁡(GC)=MSF⁡(GB)=MSF⁡(G)F_B \cup \operatorname{MSF}(G_C) = \operatorname{MSF}(G_B) = \operatorname{MSF}(G). 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 C=∅C = \emptyset. ■\blacksquare

Back to Pettie-Ramachandran optimal MST algorithm