Proofs: Girvan-Newman algorithm
These are the human proofs of Girvan-Newman algorithm, at full length.
Girvan-Newman computes exact edge betweenness, stops after m rounds, and returns the best level of its dendrogram full
This proof shows: correctness, termination.
Let be an undirected simple graph with vertices and edges. For a graph on and , write for the distance in , for the number of shortest - paths (), and for the number of those that contain the edge .
Lemma 1 (BFS counts). After line L12 for a source , and for every reached, and lists the reached vertices in non-decreasing order of distance.
Proof. BFS sets correctly and dequeues vertices in non-decreasing distance. A shortest - path with ends with an edge where , and its prefix is a shortest - path, so over these . The BFS adds to for each such when is dequeued, and every such is dequeued before , so by induction on the distance .
Call an edge with a DAG edge of . A shortest path from uses only DAG edges, in their direction.
Lemma 2 (pair counts on an edge). For a DAG edge of and a vertex , the number of shortest - paths that use is if , and 0 otherwise.
Proof. Such a path is a shortest - path, then the edge, then a shortest - path, and its length is ; it is shortest exactly when this equals . Every choice of the two parts gives a different path.
Define , where is the number of shortest - paths through the vertex , and the sum runs over the reachable . Define for a DAG edge .
Lemma 3 (Brandes' recursion for edges). For a DAG edge of , , and .
Proof. By Lemma 2 with , the edge lies on of the shortest - paths. For with on a shortest - path, , so Lemma 2 gives ; for other both sides are 0. Summing over gives the first identity. Every shortest - path through with leaves by exactly one DAG edge , so ; dividing by and summing over gives the second.
Lemma 4 (EDGE-BETWEENNESS is exact). EDGE-BETWEENNESS() returns for every edge of .
Proof. Fix . Line L14 visits in reverse, so in non-increasing distance. When is visited, every DAG edge has farther from , so was visited earlier and has added its full share to . By induction in this order and Lemma 3, when is visited, and line L16 adds to for each DAG edge . An edge that is not a DAG edge of (both ends at one distance, or unreached) lies on no shortest path from and gets nothing, and so does . So after line L16, , the sum over ordered pairs. Unreachable contribute 0 on both sides. The ordered sum counts each unordered pair twice with the same value, since a path reversed is a shortest path between the same ends, so line L17 gives .
Lemma 5 (loop invariant). At the test of line L2, is the set of components of ; lists the component partitions of the graphs seen so far, each once, in order of appearance; and is the first element of with the largest value of .
Proof. Line L1 makes it true. In one round, line L5 removes one edge of . Removing an edge either leaves the components unchanged, when and stay connected, or splits the one component that holds it into two. In the first case, the number of components is still , line L6 fails and nothing changes, and is still right. In the second case, the count grows by one, line L7 sets to the new components and appends this partition, which differs from all earlier ones since the count of components only grows. Line L8 replaces only when the new value is strictly larger, so stays the first maximum.
Theorem. GIRVAN-NEWMAN() stops after exactly rounds. It returns the dendrogram of all distinct partitions into components that arise while the edges are removed in the order of line L4, from the components of to the partition into singletons, and , a partition in of largest modularity in , the first one on ties.
Proof. Each round removes one edge of the finite set and adds none, so after rounds has no edges and line L2 fails. By Lemma 4, line L4 picks an edge of maximum edge betweenness in the current , as the algorithm requires. By Lemma 5 at exit, and are as stated, and the last partition is the one of the edgeless graph, which is all singletons.
∎