Brandes' algorithm
![]() An undirected graph colored based on the betweenness centrality of each vertex from least (red) to greatest (blue). | |
Class | Greedy algorithm Dynamic programming |
---|---|
Worst-case performance |
In network theory, Brandes' algorithm is an algorithm for calculating the betweenness centrality of vertices in a graph. The algorithm was first published in 2001 by Ulrik Brandes.[1] Calculating betweenness centrality is of great interest to some people such as __ and __.
Definitions
There are several metrics for the centrality of a node, one such metric being the betweenness centrality. For a node in a connected graph, we first define the pair dependency of with respect to and as:[2][3]
- ,
where is the total number of shortest paths from node to node , and is the number of these paths which pass through . By convention, whenever . For an unweighted graph, the length of a path is the number of edges. In other words, the pair dependency is the proportion of shortest paths that go through .
The betweenness centrality of is simply the sum of its pair dependencies, taken over all pairs and excluding :
Algorithm
The algorithm performs the following steps:
- for every
- if , and otherwise
- For every :
- is now the betweenness centrality of .
In pseudocode:
function Brandes(graph):
for u in graph.vertices:
for v in graph.vertices:
if u = v:
σ[u, v] = 1
else:
σ[u, v] = 0
for v in graph.vertices:
CB[v] ← 0
for s in graph.vertices:
for v in graph.vertices:
δ[v] ← 0
dist[v] ← ∞
Q ← queue containing only s
S ← empty stack
while Q is not empty:
u ← Q.dequeue()
for v in graph.neighbours[u]:
if dist[v] = ∞:
dist[v] = dist[u] + 1
Q.enqueue(v)
if dist[v] = dist[u] + 1:
σ[s, v] ← σ[s, v] + σ[s, u]
append u to prev[v]
while S is not empty:
v ← S.pop()
for u in prev[v]:
δ[u] ← δ[u] + σ[s, u]/σ[s, v] : (1 + δ[v])
if v ≠ s:
CB[v] ← CB[v] + δ[v]
return CB
Brandes' algorithm calculates betweenness centrality for all nodes in a graph. Several algorithms have been proposed in the past, including a modification of the Floyd–Warshall algorithm. To calculate the number of shortest paths, breadth-first search can be used. For a breadth-first search starting from node , we keep track of the set of immediate predecessors for each node . The shortest path count can be calculated by summing the counts of its predecessors:
If this process is repeated for every starting node , the time complexity is .
A naive algorithm does this on every node, counting the number of shortest paths, and summing them up. This is possible by However, this is inefficient, as it would take time and space to store data.
The naive algorithm explicitly sums all pair dependencies.
We define the dependency of a vertex as the sum of its pair dependencies, with respect to a fixed and summed over all :
Proof of correctness
The algorithm relies on the following recursive formula for vertex dependencies:
Variants
The algorithm can be generalised to weighted graphs by using Dijkstra's algorithm instead of breadth-first search.
Sources
Brandes 2001, primary[1]
Brandes 2008[4]
Wasserman Faust 1994, social network analysis[5]
Scott 1991, methods of network analysis[6]
Freeman 1977, measures of centrality[2]
Sabidussi 1966, the centrality index[7]
Borgatti Everett 2006, Graph perspective on centrality[8]
Kleinberg 1999, internet networks[9]
Brin Page 1998, anatomy of the web[10]
Bharat Henzinger 1998, hyperlinked environments[11]
Anthonisse 1971, the rush in a directed graph
References
- ^ a b Brandes, Ulrik (June 2001). "A faster algorithm for betweenness centrality:". The Journal of Mathematical Sociology. 25 (2): 163–177. doi:10.1080/0022250X.2001.9990249. ISSN 0022-250X. Retrieved 10 May 2024.
- ^ a b Freeman, Linton C. (1977). "A Set of Measures of Centrality Based on Betweenness". Sociometry. 40 (1): 35–41. doi:10.2307/3033543. ISSN 0038-0431.
- ^ Anthonisse, J. M. (1 January 1971). "The rush in a directed graph". Stichting Mathematisch Centrum.
- ^ Brandes, Ulrik (May 2008). "On variants of shortest-path betweenness centrality and their generic computation". Social Networks. 30 (2): 136–145. doi:10.1016/j.socnet.2007.11.001. ISSN 0378-8733. Retrieved 10 May 2024.
- ^ Wasserman, Stanley; Faust, Katherine (1994). "Social Network Analysis: Methods and Applications". Cambridge University Press. doi:10.1017/cbo9780511815478. Retrieved 10 May 2024.
{{cite journal}}
: Cite journal requires|journal=
(help) - ^ Scott, John (February 1991). "Methods of Network Analysis". The Sociological Review. 39 (1): 155–163. doi:10.1111/j.1467-954X.1991.tb02974.x. ISSN 0038-0261. Retrieved 10 May 2024.
- ^ Sabidussi, Gert (1 December 1966). "The centrality index of a graph". Psychometrika. 31 (4): 581–603. doi:10.1007/BF02289527. ISSN 1860-0980. Retrieved 10 May 2024.
- ^ Borgatti, Stephen P.; Everett, Martin G. (1 October 2006). "A Graph-theoretic perspective on centrality". Social Networks. 28 (4): 466–484. doi:10.1016/j.socnet.2005.11.005. ISSN 0378-8733. Retrieved 10 May 2024.
- ^ Kleinberg, Jon M. (1 September 1999). "Authoritative sources in a hyperlinked environment". Journal of the ACM. 46 (5): 604–632. doi:10.1145/324133.324140. ISSN 0004-5411. Retrieved 10 May 2024.
- ^ Brin, Sergey; Page, Lawrence (1 April 1998). "The anatomy of a large-scale hypertextual Web search engine". Computer Networks and ISDN Systems. 30 (1): 107–117. doi:10.1016/S0169-7552(98)00110-X. ISSN 0169-7552. Retrieved 10 May 2024.
- ^ Bharat, Krishna; Henzinger, Monika R. (1 August 1998). "Improved algorithms for topic distillation in a hyperlinked environment". Proceedings of the 21st annual international ACM SIGIR conference on Research and development in information retrieval. Association for Computing Machinery: 104–111. doi:10.1145/290941.290972. Retrieved 10 May 2024.