Algorithm Search⌘K

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 G=(V,E)G = (V, E) be an undirected simple graph with nn vertices and mm edges. For a graph HH on VV and s,t∈Vs, t \in V, write d(s,t)d(s, t) for the distance in HH, σst\sigma_{st} for the number of shortest ss-tt paths (σss=1\sigma_{ss} = 1), and σst(e)\sigma_{st}(e) for the number of those that contain the edge ee.

Lemma 1 (BFS counts). After line L12 for a source ss, dist[v]=d(s,v)\mathrm{dist}[v] = d(s, v) and σ[v]=σsv\sigma[v] = \sigma_{sv} for every vv reached, and SS lists the reached vertices in non-decreasing order of distance.

Proof. BFS sets dist\mathrm{dist} correctly and dequeues vertices in non-decreasing distance. A shortest ss-ww path with w≠sw \ne s ends with an edge {v,w}\{v, w\} where d(s,v)=d(s,w)−1d(s, v) = d(s, w) - 1, and its prefix is a shortest ss-vv path, so σsw=∑vσsv\sigma_{sw} = \sum_{v} \sigma_{sv} over these vv. The BFS adds σ[v]\sigma[v] to σ[w]\sigma[w] for each such vv when vv is dequeued, and every such vv is dequeued before ww, so by induction on the distance σ[w]=σsw\sigma[w] = \sigma_{sw}. □\square

Call an edge {v,w}\{v, w\} with d(s,v)=d(s,w)−1d(s, v) = d(s, w) - 1 a DAG edge v→wv \to w of ss. A shortest path from ss uses only DAG edges, in their direction.

Lemma 2 (pair counts on an edge). For a DAG edge v→wv \to w of ss and a vertex tt, the number of shortest ss-tt paths that use {v,w}\{v, w\} is σsv⋅σwt\sigma_{sv} \cdot \sigma_{wt} if d(s,t)=d(s,w)+d(w,t)d(s, t) = d(s, w) + d(w, t), and 0 otherwise.

Proof. Such a path is a shortest ss-vv path, then the edge, then a shortest ww-tt path, and its length is d(s,w)+d(w,t)d(s, w) + d(w, t); it is shortest exactly when this equals d(s,t)d(s, t). Every choice of the two parts gives a different path. □\square

Define δs(x)=∑t∉{s,x}σst(x)/σst\delta_s(x) = \sum_{t \notin \{s, x\}} \sigma_{st}(x) / \sigma_{st}, where σst(x)\sigma_{st}(x) is the number of shortest ss-tt paths through the vertex xx, and the sum runs over the reachable tt. Define cs(v,w)=∑t≠sσst({v,w})/σstc_s(v, w) = \sum_{t \ne s} \sigma_{st}(\{v, w\}) / \sigma_{st} for a DAG edge v→wv \to w.

Lemma 3 (Brandes' recursion for edges). For a DAG edge v→wv \to w of ss, cs(v,w)=σsvσsw(1+δs(w))c_s(v, w) = \frac{\sigma_{sv}}{\sigma_{sw}} (1 + \delta_s(w)), and δs(v)=∑w:v→wcs(v,w)\delta_s(v) = \sum_{w : v \to w} c_s(v, w).

Proof. By Lemma 2 with t=wt = w, the edge lies on σsv\sigma_{sv} of the σsw\sigma_{sw} shortest ss-ww paths. For t≠wt \ne w with ww on a shortest ss-tt path, σst(w)=σswσwt\sigma_{st}(w) = \sigma_{sw} \sigma_{wt}, so Lemma 2 gives σst({v,w})=σsvσswσst(w)\sigma_{st}(\{v,w\}) = \frac{\sigma_{sv}}{\sigma_{sw}} \sigma_{st}(w); for other tt both sides are 0. Summing over tt gives the first identity. Every shortest ss-tt path through vv with t≠vt \ne v leaves vv by exactly one DAG edge v→wv \to w, so σst(v)=∑wσst({v,w})\sigma_{st}(v) = \sum_w \sigma_{st}(\{v, w\}); dividing by σst\sigma_{st} and summing over tt gives the second. □\square

Lemma 4 (EDGE-BETWEENNESS is exact). EDGE-BETWEENNESS(HH) returns BH(e)B_H(e) for every edge ee of HH.

Proof. Fix ss. Line L14 visits SS in reverse, so in non-increasing distance. When ww is visited, every DAG edge w→xw \to x has xx farther from ss, so xx was visited earlier and has added its full share to δ[w]\delta[w]. By induction in this order and Lemma 3, δ[w]=δs(w)\delta[w] = \delta_s(w) when ww is visited, and line L16 adds c=cs(v,w)c = c_s(v, w) to B[{v,w}]B[\{v, w\}] for each DAG edge v→wv \to w. An edge that is not a DAG edge of ss (both ends at one distance, or unreached) lies on no shortest path from ss and gets nothing, and so does csc_s. So after line L16, B[e]=∑s∑t≠sσst(e)/σstB[e] = \sum_s \sum_{t \ne s} \sigma_{st}(e)/\sigma_{st}, the sum over ordered pairs. Unreachable tt 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 BH(e)B_H(e). □\square

Lemma 5 (loop invariant). At the test of line L2, PP is the set of components of HH; levelslevels lists the component partitions of the graphs HH seen so far, each once, in order of appearance; and bestbest is the first element of levelslevels with the largest value of QGQ_G.

Proof. Line L1 makes it true. In one round, line L5 removes one edge of HH. Removing an edge {u,v}\{u, v\} either leaves the components unchanged, when uu and vv stay connected, or splits the one component that holds it into two. In the first case, the number of components is still ∣P∣|P|, line L6 fails and nothing changes, and PP is still right. In the second case, the count grows by one, line L7 sets PP to the new components and appends this partition, which differs from all earlier ones since the count of components only grows. Line L8 replaces bestbest only when the new value is strictly larger, so bestbest stays the first maximum. □\square

Theorem. GIRVAN-NEWMAN(GG) stops after exactly mm rounds. It returns the dendrogram levelslevels of all distinct partitions into components that arise while the edges are removed in the order of line L4, from the components of GG to the partition into singletons, and bestbest, a partition in levelslevels of largest modularity in GG, the first one on ties.

Proof. Each round removes one edge of the finite set EE and adds none, so after mm rounds HH has no edges and line L2 fails. By Lemma 4, line L4 picks an edge of maximum edge betweenness in the current HH, as the algorithm requires. By Lemma 5 at exit, levelslevels and bestbest are as stated, and the last partition is the one of the edgeless graph, which is all singletons. □\square

∎

Back to Girvan-Newman algorithm