Algorithm
Betweenness centrality
activeNeeds verification
Scores a node by the fraction of all shortest paths between other node pairs that pass through it, highlighting brokers and bottlenecks.
Definition
Intuition
If many shortest routes run through you, you control flow between other parts of the network.
Pseudocode
Brandes: for each source s, run BFS (or Dijkstra) counting shortest paths σ, then accumulate dependencies δ in reverse BFS order.
Complexity
| Time | O(VE) unweighted; O(VE + V² log V) weighted |
|---|---|
| Space | O(V + E) |
Python
import networkx as nx
bc = nx.betweenness_centrality(G, normalized=True)
approx = nx.betweenness_centrality(G, k=200, seed=1) # sampledCypher (Neo4j GDS)
CALL gds.betweenness.stream('myGraph')
YIELD nodeId, score RETURN gds.util.asNode(nodeId).name, score
ORDER BY score DESCProcedure names and options vary between GDS versions; check the GDS docs for your version.
An interactive step-by-step visualizer for this algorithm is planned for phase 3.
Profile
| Time complexity | O(VE) unweighted; O(VE + V² log V) weighted |
|---|---|
| Space complexity | O(V + E) |
Relationships
- Belongs to
- Introduced by
- A faster algorithm for betweenness centrality— Brandes' algorithm; the measure dates to Freeman (1977)
- Prerequisites
- Breadth-first search (BFS)(Algorithm)
- Centrality(Concept)