Skip to content
Graph Intelligence Hub
Menu

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

TimeO(VE) unweighted; O(VE + V² log V) weighted
SpaceO(V + E)

Python

import networkx as nx
bc = nx.betweenness_centrality(G, normalized=True)
approx = nx.betweenness_centrality(G, k=200, seed=1)  # sampled

Cypher (Neo4j GDS)

CALL gds.betweenness.stream('myGraph')
YIELD nodeId, score RETURN gds.util.asNode(nodeId).name, score
ORDER BY score DESC

Procedure 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 complexityO(VE) unweighted; O(VE + V² log V) weighted
Space complexityO(V + E)

Relationships

Belongs to
Introduced by
Prerequisites
Implemented by