Algorithm Search⌘K

Proofs: Frederickson's topology trees

These are the human proofs of Frederickson's topology trees, at full length.

The cluster method keeps the minimum spanning forest, and the topology tree is a valid hierarchy full

This proof shows: correctness.

Order the edges by the key (weight, smaller end, larger end); all keys are distinct, so every graph GG has a unique minimum spanning forest MSF(G)\mathrm{MSF}(G). We use two standard facts for distinct keys.

  • Cycle property. An edge ee is not in MSF(G)\mathrm{MSF}(G) if and only if GG has a cycle on which ee is the heaviest edge; equivalently, for e={u,v}e = \{u, v\}, the path between uu and vv in MSF(G−e)\mathrm{MSF}(G - e) exists and has only lighter edges.
  • Cut property. For any cut of GG, the lightest edge crossing it is in MSF(G)\mathrm{MSF}(G).

Invariants. After every update:

  • (F) F=MSF(G)F = \mathrm{MSF}(G);
  • (C) the clusters partition VV, each cluster is connected in FF, and the cluster tree has one edge per forest edge between two distinct clusters;
  • (T) the table holds exactly the edges of G−FG - F, each under the pair of clusters of its two ends.

Initially GG and FF are empty and the clusters are single vertices, so all three hold.

Lemma 1 (walks on the cluster tree). Under (C), two vertices are in the same tree of FF if and only if their clusters are connected in the cluster tree, and the clusters met on the forest path from uu to vv are exactly the clusters on the path from C(u)C(u) to C(v)C(v) in the cluster tree.

Proof. Contracting each cluster of a forest to one node, when each cluster is connected, gives a forest (a cycle of clusters would lift to a cycle in FF, since each cluster is connected) whose edges are the forest edges between clusters. Contraction preserves connectivity. A forest path from uu to vv maps to a walk from C(u)C(u) to C(v)C(v); it never re-enters a cluster it left, since that would give two paths in FF between two vertices of a connected cluster. So it maps to the unique path in the cluster tree. □\square

Lemma 2 (cluster maintenance). The operations on clusters keep (C) and (T).

Proof. Adding a forest edge between two clusters adds one cluster tree edge, and joining two clusters aa and bb joined by a forest edge gives a connected set. Removing a forest edge inside a cluster cc splits cc, which was connected by a subtree of FF, into exactly the two parts reachable from uu and from vv inside cc; each is connected, and line L4 makes the smaller one a new cluster. Removing a forest edge between two clusters removes one cluster tree edge. When vertices move to a new cluster, the cluster tree edges at those vertices are removed and added again with the new names, and every non-tree edge at those vertices is removed from its old table pair and added under its new pair; non-tree edges at other vertices keep their pair. Re-clustering in line L7 builds each cluster as a union of connected pieces joined through forest edges, so each cluster is connected, and it rebuilds the cluster tree and the table from FF and G−FG - F. □\square

Lemma 3 (monotonicity). Let ee be an edge. (a) MSF(G+e)⊆MSF(G)+e\mathrm{MSF}(G + e) \subseteq \mathrm{MSF}(G) + e. (b) MSF(G)−e⊆MSF(G−e)\mathrm{MSF}(G) - e \subseteq \mathrm{MSF}(G - e). (c) A minimum spanning forest of a graph with cc components on nn vertices has n−cn - c edges.

Proof. (a) An edge f≠ef \neq e outside MSF(G)\mathrm{MSF}(G) is the heaviest edge of a cycle of GG, which is also a cycle of G+eG + e, so f∉MSF(G+e)f \notin \mathrm{MSF}(G + e). (b) If f∈MSF(G)f \in \mathrm{MSF}(G), f≠ef \neq e, were the heaviest edge of a cycle of G−eG - e, that cycle would be in GG. (c) It is a spanning forest. □\square

Lemma 4 (insertion). If (F), (C), (T) hold before INSERT(u,v,w)(u, v, w), they hold after it.

Proof. Let e={u,v}e = \{u, v\} and G′=G+eG' = G + e. By Lemma 3(a), MSF(G′)⊆F+e\mathrm{MSF}(G') \subseteq F + e.

If uu and vv are in different trees of FF, which line L1 tests by Lemma 1, then G′G' has one component less than GG, so by Lemma 3(c) MSF(G′)\mathrm{MSF}(G') has ∣F∣+1|F| + 1 edges and equals F+eF + e.

Otherwise G′G' has the same components as GG, so MSF(G′)\mathrm{MSF}(G') has ∣F∣|F| edges. Let PP be the forest path from uu to vv, which line L2 finds inside the clusters of the cluster path by Lemma 1, and xx its heaviest edge. The edges P+eP + e form a cycle of G′G'. If ee is heavier than xx, it is the heaviest edge of that cycle, so e∉MSF(G′)e \notin \mathrm{MSF}(G'), hence MSF(G′)⊆F\mathrm{MSF}(G') \subseteq F, and by size MSF(G′)=F\mathrm{MSF}(G') = F; line L3 puts ee in the table. If ee is lighter than xx, then xx is the heaviest edge of that cycle, so MSF(G′)⊆F−x+e\mathrm{MSF}(G') \subseteq F - x + e, and both sides have ∣F∣|F| edges, so they are equal; line L3 makes this change and puts xx in the table.

The cluster and table changes keep (C) and (T) by Lemma 2. □\square

Lemma 5 (deletion). If (F), (C), (T) hold before DELETE(u,v)(u, v), they hold after it.

Proof. Let e={u,v}e = \{u, v\} and G′=G−eG' = G - e. By Lemma 3(b), F−e⊆MSF(G′)F - e \subseteq \mathrm{MSF}(G').

If e∉Fe \notin F, the components do not change, so MSF(G′)\mathrm{MSF}(G') has ∣F∣|F| edges and contains FF; it is FF, and only the table entry is removed.

If e∈Fe \in F, removing it splits a tree into TuT_u and TvT_v. If no edge of G′G' joins TuT_u and TvT_v, then G′G' has one component more, MSF(G′)\mathrm{MSF}(G') has ∣F∣−1|F| - 1 edges and contains F−eF - e, so it is F−eF - e. Otherwise the lightest edge rr of G′G' between TuT_u and TvT_v is in MSF(G′)\mathrm{MSF}(G') by the cut property, the components do not change, and F−e+r⊆MSF(G′)F - e + r \subseteq \mathrm{MSF}(G') has ∣F∣|F| edges, so it is MSF(G′)\mathrm{MSF}(G').

It remains to see that lines L5 and L6 find rr. After line L4, (C) holds by Lemma 2, so by Lemma 1 the walks on the cluster tree from C(u)C(u) and C(v)C(v) give exactly the clusters of TuT_u and of TvT_v. Every edge of G′G' between TuT_u and TvT_v is a non-tree edge, so by (T) it is in the table under a pair (a,b)(a, b) with aa a cluster of TuT_u and bb one of TvT_v, and every edge under such a pair joins the two sides. So the minimum over these pairs is rr, or there is none. Line L6 moves rr from the table to FF, and Lemma 2 keeps (C) and (T). □\square

By induction on the updates, Lemmas 4 and 5 give (F) after every update.

Lemma 6 (topology tree). BUILD-TOPOLOGY-TREE on a tree of maximum degree three returns levels in which every cluster is connected, has at most three edges leaving it, and is the union of one or two clusters of the level below; the last level is the whole tree.

Proof. Level 0 has single vertices, with external degree at most three. A pair joined at line L9 is two adjacent clusters, so the union is connected. Between two adjacent clusters of a tree there is exactly one edge, so the union has external degree d1+d2−2d_1 + d_2 - 2; the allowed pairs have d1=1d_1 = 1, giving at most 3−1=23 - 1 = 2, or d1,d2≤2d_1, d_2 \le 2, giving at most 2. Unpaired clusters are copied. The loop stops only when no adjacent pair is allowed. If the level has two or more clusters, the cluster tree is a tree with at least two nodes and so has a leaf, of external degree 1, which may be paired with its neighbor; so the loop stops only at a single cluster, the whole tree. Each level with at least two clusters joins at least one pair, so the loop ends. ■\blacksquare

Back to Frederickson's topology trees