Brandes' Algorithm for Betweenness Centrality
Motivation
Computing betweenness centrality naïvely requires finding all-pairs shortest paths, which takes with Floyd-Warshall or with repeated Dijkstra. Brandes’ algorithm (2001) reduces this to for unweighted graphs by reusing intermediate computations across source vertices.
Key Insight
For each source vertex , run a single BFS (or Dijkstra for weighted graphs) to compute the shortest-path directed acyclic graph (DAG) rooted at . Then accumulate dependency values backwards — from the farthest nodes to the root — in a single reverse traversal. This avoids recomputing path counts for every target independently.
Algorithm Steps
Forward Pass — BFS from Each Source
Run BFS from to discover nodes in order of increasing distance. For each node :
- : the number of distinct shortest paths from to .
- For the source: .
- For a neighbour of : if is newly discovered (first time reaching it at this depth), set and record as a predecessor of .
- If is rediscovered at the same depth (another shortest path to of the same length), add to and add to (the predecessor set).
- : the set of nodes such that the edge lies on at least one shortest path from to .
The result is a shortest-path DAG: edges only go from nodes at distance to nodes at distance .
Backward Pass — Accumulate Dependencies
Process nodes in reverse BFS order (farthest from first, closest last). For each node (excluding ):
This says: ‘s dependency contribution to paths ending at is proportional to the fraction of shortest paths from to that pass through , plus the dependency that itself accumulates from nodes beyond it.
Add to .
Undirected Correction
For undirected graphs, each unordered pair appears twice in the summation (once as and once as ). After summing over all sources , halve all betweenness scores.
Complexity
| Graph Type | Algorithm Used | Time Complexity |
|---|---|---|
| Unweighted | BFS from each source | |
| Weighted | Dijkstra from each source |
This is close to optimal for dense graphs: all-pairs shortest paths inherently requires examining all edges from all sources, which is in the worst case.
What the Exam Expects
The full dependency-accumulation formula is beyond the scope of most MLRD exam questions. What you should know:
- Brandes runs BFS (or Dijkstra) from every source node, giving total time.
- The forward pass computes shortest-path DAGs and counts (number of shortest paths to each node).
- The backward pass accumulates dependencies from farthest nodes backward to the root.
- For undirected graphs, halve the final betweenness scores.
- This algorithm is used in practice to compute edge betweenness for Newman-Girvan community detection: edge betweenness is computed by summing the dependency contributions that flow through each edge during the backward pass.
Connection to Newman-Girvan
Newman-Girvan repeatedly removes edges with highest betweenness. Computing edge betweenness for all edges naïvely after each removal would be extremely expensive. Brandes makes this feasible: after each edge removal, recompute all-pairs shortest paths in . The algorithm is run repeatedly until the desired number of clusters is reached.
Summary
| Step | Operation |
|---|---|
| Overall approach | BFS/Dijkstra from every source, accumulate dependencies backward |
| Forward pass | Compute (path counts) and predecessors |
| Backward pass | Accumulate from farthest nodes to source |
| Complexity (unweighted) | |
| Complexity (weighted) | |
| Undirected correction | Halve all final betweenness scores |
Past paper questions: y2025p3q8 (Newman-Girvan context)