Algorithm Search⌘K

Proofs: Eppstein-Galil-Italiano-Nissenzweig algorithm

These are the human proofs of Eppstein-Galil-Italiano-Nissenzweig algorithm, at full length.

The root of the sparsification tree holds the minimum spanning forest full

This proof shows: correctness.

Fix a strict total order ≺\prec on the edges: e≺fe \prec f if w(e)<w(f)w(e) < w(f), or w(e)=w(f)w(e) = w(f) and ee has the smaller id. For a finite multigraph GG on the vertex set VV, let MSF(G)\mathrm{MSF}(G) be the minimum spanning forest for this order. It is unique, because all weights are distinct under ≺\prec, and Kruskal's algorithm computes it.

Lemma 1 (cycle rule). An edge ee of GG is not in MSF(G)\mathrm{MSF}(G) if and only if GG has a cycle on which ee is the ≺\prec-largest edge.

Proof. Kruskal's algorithm scans the edges in ≺\prec-order and rejects ee exactly when its ends are already joined by earlier, so smaller, edges; those edges and ee form a cycle with ee largest. Conversely, if e={u,v}e = \{u, v\} is largest on a cycle ZZ, then when Kruskal scans ee, every other edge of ZZ has been scanned, and each of them is either in the forest or has its ends already joined, so uu and vv are already joined and ee is rejected. □\square

Lemma 2 (strong certificate). For any multigraphs GG and HH on VV, MSF(G∪H)=MSF(MSF(G)∪H)\mathrm{MSF}(G \cup H) = \mathrm{MSF}(\mathrm{MSF}(G) \cup H).

Proof. Write G′=MSF(G)∪HG' = \mathrm{MSF}(G) \cup H, a subgraph of G∪HG \cup H. First, MSF(G∪H)⊆G′\mathrm{MSF}(G \cup H) \subseteq G': an edge of GG outside MSF(G)\mathrm{MSF}(G) is largest on a cycle of GG by Lemma 1, hence largest on a cycle of G∪HG \cup H, hence not in MSF(G∪H)\mathrm{MSF}(G \cup H). Now take any edge ee of G′G'. If e∉MSF(G∪H)e \notin \mathrm{MSF}(G \cup H), then by Lemma 1 there is a cycle in G∪HG \cup H on which ee is largest. Take such a cycle and replace each edge ff on it that is not in G′G': such an ff is in G∖MSF(G)G \setminus \mathrm{MSF}(G), so its ends are joined in MSF(G)\mathrm{MSF}(G) by a path of edges ≺f≺e\prec f \prec e. The result is a closed walk in G′G' through ee once, all of whose other edges are ≺e\prec e; it contains a cycle through ee with ee largest. So e∉MSF(G′)e \notin \mathrm{MSF}(G'). Conversely, if e∉MSF(G′)e \notin \mathrm{MSF}(G'), then ee is largest on a cycle of G′G', which is a cycle of G∪HG \cup H, so e∉MSF(G∪H)e \notin \mathrm{MSF}(G \cup H). Hence the two forests have the same edges. □\square

Corollary. MSF(G1∪G2)=MSF(MSF(G1)∪MSF(G2))\mathrm{MSF}(G_1 \cup G_2) = \mathrm{MSF}(\mathrm{MSF}(G_1) \cup \mathrm{MSF}(G_2)), by applying Lemma 2 twice: once with G=G1G = G_1, H=G2H = G_2, then with G=G2G = G_2, H=MSF(G1)H = \mathrm{MSF}(G_1).

Stability. The time bound of the paper uses one more fact, which the correctness proof below does not need: if one edge is inserted into or deleted from G1G_1, then MSF(G1∪G2)\mathrm{MSF}(G_1 \cup G_2) changes by at most one inserted and one deleted edge. For an insertion of ee, the new forest is the old one plus ee, minus the largest edge on the cycle that ee closes, if any. For a deletion of a forest edge, the new forest is the old one minus that edge, plus the smallest edge that reconnects the two parts, if any.

Theorem. After each operation, F(root)=MSF(G)F(\text{root}) = \mathrm{MSF}(G) for the current graph GG.

Proof. For a node xx, let E(x)E(x) be the union of the groups at the leaves below xx. Claim: after each operation, F(x)=MSF(E(x))F(x) = \mathrm{MSF}(E(x)) for every node xx. It holds after a build, by induction from the leaves: at a leaf by definition, and at an internal node by the Corollary, since E(x)=E(left(x))∪E(right(x))E(x) = E(\mathrm{left}(x)) \cup E(\mathrm{right}(x)).

Assume the claim before an update. INSERT changes one group (line L1), and DELETE changes at most two groups, the group EiE_i and the last group (lines L3 and L4). For a node xx, the set E(x)E(x) changes only if a changed group is below xx, that is, if xx is on the path from a changed leaf to the root. Lines L2 and L5 call RECOMPUTE-PATH on every changed leaf. RECOMPUTE-PATH goes from the leaf upward (line L6), so when it recomputes F(x)F(x) in line L7, both children of xx already hold the correct forests: a child on a recomputed path was done earlier in this or the previous call, and a child on no such path has an unchanged EE. By the Corollary, F(x)F(x) is then MSF(E(x))\mathrm{MSF}(E(x)). Nodes on no recomputed path keep their correct forests. When the number of groups exceeds the number of leaves, the implementation rebuilds the whole tree, which is again correct by the build argument.

At the root, E(root)E(\text{root}) is the set of all current edges, because every edge is in exactly one group and moving an edge in line L4 keeps it in some group. So F(root)=MSF(G)F(\text{root}) = \mathrm{MSF}(G), which line L8 reports. ■\blacksquare

Back to Eppstein-Galil-Italiano-Nissenzweig algorithm