UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • Running Algorithms
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Eccentricity Centrality
    • Betweenness Centrality
    • Bridges
    • Articulation Points
    • Eigenvector Centrality
    • Katz Centrality
    • CELF
    • PageRank
    • ArticleRank
    • TextRank
    • HITS
    • SybilRank
    • Jaccard Similarity
    • Overlap Similarity
    • Cosine Similarity
    • Pearson Correlation Coefficient
    • Euclidean Distance
    • KNN
    • Vector Similarity
    • Bipartite Graph
    • HyperANF
    • Weakly Connected Components (WCC)
    • Strongly Connected Components (SCC)
    • k-Edge Connected Components
    • Local Clustering Coefficient
    • Triangle Count
    • Clique Count
    • k-Core
    • k-Truss
    • p-Cohesion
    • Induced Subgraph
    • Topological Sort
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Dijkstra's Shortest Path
    • A* Shortest Path
    • Yen's K-Shortest Paths
    • Shortest Path (BFS)
    • Delta-Stepping SSSP
    • Shortest Path Faster Algorithm (SPFA)
    • All-Pairs Shortest Path (APSP)
    • Minimum Spanning Tree (MST)
    • K-Spanning Tree
    • Steiner Tree
    • Prize-Collecting Steiner Tree (PCST)
    • Minimum Cost Flow
    • Maximum Flow
    • K-Hop Fast
    • Longest Path (DAG)
    • Random Walk
    • Adamic-Adar Index
    • Common Neighbors
    • Preferential Attachment
    • Resource Allocation
    • Total Neighbors
    • Same Community
    • Louvain
    • Leiden
    • Modularity Optimization
    • Label Propagation
    • HANP
    • SLPA
    • k-Means
    • HDBSCAN
    • K-1 Coloring
    • Modularity
    • Conductance
    • Max k-Cut
      • Node2Vec
      • Struc2Vec
      • LINE
      • Fast Random Projection
      • Summary of Graph Embedding
      • Gradient Descent
      • Backpropagation
      • Skip-gram
      • Skip-gram Optimization
  1. Docs
  2. /
  3. Graph Algorithms
  4. /
  5. Centrality

Betweenness Centrality

Overview

Betweenness centrality measures the likelihood of a node being on the shortest paths between any two other nodes. This metric effectively identifies "bridge" nodes that facilitate connectivity between different parts of a graph.

Betweenness centrality scores range from 0 to 1 (when normalized), with higher scores indicating nodes that exert greater influence over the flow and connectivity of the network.

References:

  • L.C. Freeman, A Set of Measures of Centrality Based on Betweenness (1977)
  • L.C. Freeman, Centrality in Social Networks Conceptual Clarification (1978)

Concepts

Shortest Path

The shortest paths between two nodes are the paths that contain the fewest edges. When considering edge weights, the (weighted) shortest paths are those with the lowest total weight sum.

Betweenness Centrality

The betweenness centrality of a node x is computed by:

where,

  • i and j are two distinct nodes in the graph, excluding x.
  • σij is the total number of shortest paths between i and j.
  • σij(x) is the number of shortest paths between i and j that pass through node x.
  • σij(x)/σij gives the probability that x lies in the shortest paths between i and j. Note that if i and j are not connected, σij(x)/σij is 0.

The final value is normalized by the factor (k – 1)(k – 2), where k is the total number of nodes in the graph. This normalization ensures the result lies within a fixed range, making it comparable across graphs of different sizes.

The betweenness centrality of node A is computed as: (1/2 + 1 + 2/3 + 1/2 + 1 + 2/3) / (4 * 3) = 0.3611111111.

Example Graph

GQL
INSERT (Sue:user {_id: "Sue"}), (Dave:user {_id: "Dave"}),
       (Ann:user {_id: "Ann"}), (Mark:user {_id: "Mark"}),
       (May:user {_id: "May"}), (Jay:user {_id: "Jay"}),
       (Billy:user {_id: "Billy"}),
       (Dave)-[:know {strength: 1}]->(Sue), (Dave)-[:know {strength: 3}]->(Ann),
       (Mark)-[:know {strength: 2}]->(Dave), (May)-[:know {strength: 1}]->(Mark),
       (May)-[:know {strength: 2}]->(Jay), (Jay)-[:know {strength: 2}]->(Ann)

Parameters

NameTypeDefaultDescription
idsLIST/_ids of nodes to compute (empty = all nodes).
directionSTRINGbothEdge direction: in, out, or both.
normalizedBOOLfalseWhether to normalize scores to [0, 1].
weightSTRING or LIST/Numeric edge property for weighted shortest paths.
samplingSizeINT-1Number of source nodes to sample (-1 = all). Recommended for large graphs.
limitINT-1Limits the number of results returned (-1 = all).
orderSTRING/Sorts the results by score: asc or desc.

Run Mode

Returns:

ColumnTypeDescription
nodeIdSTRINGNode identifier (_id)
scoreFLOATBetweenness centrality score
rankINTRank position (1 = highest betweenness)

Normalized betweenness centrality for all nodes:

GQL
CALL algo.betweenness({
  normalized: true,
  order: "desc"
}) YIELD nodeId, score, rank

Result:

nodeIdscorerank
Dave0.33333333333333331
Mark0.133333333333333332
Ann0.133333333333333333
May0.066666666666666674
Jay0.066666666666666675
Sue06
Billy07

Weighted betweenness centrality:

GQL
CALL algo.betweenness({
  ids: ["Dave"],
  normalized: true,
  weight: ["strength"]
}) YIELD nodeId, score, rank

Result:

nodeIdscorerank
Dave0.31

Stream Mode

Returns the same columns as run mode, streamed for memory efficiency.

GQL
CALL algo.betweenness.stream({
  normalized: true,
  order: "desc"
}) YIELD nodeId, score
FILTER score > 0.1
RETURN nodeId, score

Result:

nodeIdscore
Dave0.3333333333333333
Mark0.13333333333333333
Ann0.13333333333333333

Stats Mode

Returns:

ColumnTypeDescription
nodeCountINTTotal number of nodes
minScoreFLOATMinimum betweenness score
maxScoreFLOATMaximum betweenness score
avgScoreFLOATAverage betweenness score
GQL
CALL algo.betweenness.stats({normalized: true}) YIELD nodeCount, minScore, maxScore, avgScore

Result:

nodeCountminScoremaxScoreavgScore
700.33333333333333330.1047619047619048

Write Mode

Computes results and writes them back to node properties. The write configuration is passed as a second argument map.

Write parameters:

NameTypeDescription
db.propertySTRING or MAPNode property to write results to. String: writes the score column in results to a property. Map: explicit column-to-property mapping (e.g., {score: 'bc_score', rank: 'bc_rank'}).

Writable columns:

ColumnTypeDescription
scoreFLOATBetweenness centrality score
rankINTRank position

Returns:

ColumnTypeDescription
task_idSTRINGTask identifier for tracking via SHOW TASKS
nodesWrittenINTNumber of nodes with properties written
computeTimeMsINTTime spent computing the algorithm (milliseconds)
writeTimeMsINTTime spent writing properties to storage (milliseconds)
GQL
CALL algo.betweenness.write({normalized: true}, {
  db: {
    property: "bc_score"
  }
}) YIELD task_id, nodesWritten, computeTimeMs, writeTimeMs