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 has a unique minimum spanning forest . We use two standard facts for distinct keys.
- Cycle property. An edge is not in if and only if has a cycle on which is the heaviest edge; equivalently, for , the path between and in exists and has only lighter edges.
- Cut property. For any cut of , the lightest edge crossing it is in .
Invariants. After every update:
- (F) ;
- (C) the clusters partition , each cluster is connected in , and the cluster tree has one edge per forest edge between two distinct clusters;
- (T) the table holds exactly the edges of , each under the pair of clusters of its two ends.
Initially and 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 if and only if their clusters are connected in the cluster tree, and the clusters met on the forest path from to are exactly the clusters on the path from to 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 , since each cluster is connected) whose edges are the forest edges between clusters. Contraction preserves connectivity. A forest path from to maps to a walk from to ; it never re-enters a cluster it left, since that would give two paths in between two vertices of a connected cluster. So it maps to the unique path in the cluster tree.
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 and joined by a forest edge gives a connected set. Removing a forest edge inside a cluster splits , which was connected by a subtree of , into exactly the two parts reachable from and from inside ; 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 and .
Lemma 3 (monotonicity). Let be an edge. (a) . (b) . (c) A minimum spanning forest of a graph with components on vertices has edges.
Proof. (a) An edge outside is the heaviest edge of a cycle of , which is also a cycle of , so . (b) If , , were the heaviest edge of a cycle of , that cycle would be in . (c) It is a spanning forest.
Lemma 4 (insertion). If (F), (C), (T) hold before INSERT, they hold after it.
Proof. Let and . By Lemma 3(a), .
If and are in different trees of , which line L1 tests by Lemma 1, then has one component less than , so by Lemma 3(c) has edges and equals .
Otherwise has the same components as , so has edges. Let be the forest path from to , which line L2 finds inside the clusters of the cluster path by Lemma 1, and its heaviest edge. The edges form a cycle of . If is heavier than , it is the heaviest edge of that cycle, so , hence , and by size ; line L3 puts in the table. If is lighter than , then is the heaviest edge of that cycle, so , and both sides have edges, so they are equal; line L3 makes this change and puts in the table.
The cluster and table changes keep (C) and (T) by Lemma 2.
Lemma 5 (deletion). If (F), (C), (T) hold before DELETE, they hold after it.
Proof. Let and . By Lemma 3(b), .
If , the components do not change, so has edges and contains ; it is , and only the table entry is removed.
If , removing it splits a tree into and . If no edge of joins and , then has one component more, has edges and contains , so it is . Otherwise the lightest edge of between and is in by the cut property, the components do not change, and has edges, so it is .
It remains to see that lines L5 and L6 find . After line L4, (C) holds by Lemma 2, so by Lemma 1 the walks on the cluster tree from and give exactly the clusters of and of . Every edge of between and is a non-tree edge, so by (T) it is in the table under a pair with a cluster of and one of , and every edge under such a pair joins the two sides. So the minimum over these pairs is , or there is none. Line L6 moves from the table to , and Lemma 2 keeps (C) and (T).
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 ; the allowed pairs have , giving at most , or , 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.