Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
Find communities by cutting the busiest edges
Community detection: delete the edge with the highest betweenness until the graph splits, keep the division with the best modularity
Select an algorithm and generate steps to begin visualization
The Girvan-Newman algorithm detects communities in a network: groups of vertices with many edges inside and few between them. Michelle Girvan and Mark Newman published it in 2002, and it was one of the first methods to find communities by removing edges rather than by building groups up. It produces a whole hierarchy of divisions, from one community down to single vertices.
The edges between communities are the ones that many shortest paths have to use, so their edge betweenness is high. The algorithm computes the betweenness of every edge with Brandes' algorithm, deletes the edge with the highest value, recomputes, and repeats. As edges disappear, the graph falls apart into ever smaller connected pieces. Each division is scored by modularity Q: the fraction of edges inside the communities minus the fraction expected if the edges were wired at random with the same degrees. The division with the highest Q is the answer; values above about 0.3 suggest real community structure. Recomputing after every deletion makes the method O(E²V).
Community detection finds friend groups and interest clusters in social networks, research fields in citation networks, functional modules in protein and gene networks, and related products in purchase data. Girvan-Newman is mostly used on small and medium networks and in teaching, because it is easy to follow and shows the full hierarchy, while faster methods such as Louvain handle very large graphs.
Girvan-Newman finds communities by removing edges rather than grouping vertices. The edges between communities carry the most shortest paths, so deleting the edge of highest betweenness again and again pulls the groups apart.
GirvanNewman(graph):
best = the whole graph as one community, Q = 0
while the graph has edges:
compute the betweenness of every edge // Brandes
delete the edge with the highest betweenness
if the number of components increased:
Q = modularity of the components, on the original graph
if Q > Q(best): best = the components
return bestThe edge betweenness must be recomputed after every deletion, because removing a bridge between two groups reroutes all the shortest paths that used it, often onto another bridge. The method produces a whole hierarchy of splits, a dendrogram, and modularity is the yardstick used to choose one level of it.
Divide the twelve-vertex network of the example this page loads. It has three tightly knit groups of four, joined by only three edges.
Example graph: Undirected edges within the groups: A-B, A-C, A-D, B-C, B-D, C-D, then E-F, E-G, E-H, F-G, F-H, G-H, then I-J, I-K, J-K, J-L, K-L. Between the groups: D-E, D-I and H-J. That makes 20 edges.
The best division has three communities and modularity 0.515, which can be checked by hand: each group of four contributes its share of internal edges, 6, 6 and 5 out of 20, minus the square of its share of the degree sum, 14, 14 and 12 out of 40. The answer matches the visible structure exactly. The price is speed: every deletion needs a fresh edge betweenness computation, three to reach this division and twenty for the full run.
Time: O(E^2 V) · Space: O(V + E)
Each round runs Brandes' algorithm for edge betweenness in O(VE) on an unweighted graph, and there are up to E rounds, one per deleted edge. The total is O(E^2 V), which is O(V^3) on sparse graphs where E is proportional to V. Recomputation can be restricted to the component that lost an edge, which helps in practice but does not change the worst case. In practice this limits Girvan-Newman to networks of a few thousand vertices, which is why faster modularity heuristics replaced it for large data.
Girvan-Newman is the classical divisive method and is still valued for its transparency. For large networks other methods are used.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Louvain | Large networks where modularity is the objective. It merges vertices greedily and then aggregates, and it is the default in most tools. | near O(E) per pass |
| Leiden | Like Louvain, but it guarantees that every community found is internally connected. | near O(E) per pass |
| Label propagation | Speed matters most and some run-to-run variation is acceptable. No objective function at all. | O(E) per round |
| Spectral clustering | You know the number of communities in advance and the graph fits in memory as a matrix. | O(V^3) dense |
Read the full article: Community Detection: Modularity, Louvain, Girvan-Newman
Read the full article: Graph Centrality Measures: Degree, Betweenness, PageRank
Related algorithms: Betweenness Centrality, K-Means Logistics Clustering, Bridge Finding, Tarjan's SCC Algorithm