NetworkX

Previous topic

networkx.betweenness_centrality

Next topic

networkx.load_centrality

networkx.betweenness_centrality_source

betweenness_centrality_source(G, normalized=True, weighted_edges=False, sources=None)

Compute betweenness centrality for a subgraph.

Enchanced version of the method in centrality module that allows specifying a list of sources (subgraph).

Parameters:

G : graph

A networkx graph

normalized : bool, optional

If True the betweenness values are normalized by b=b/(n-1)(n-2) where n is the number of nodes in G.

weighted_edges : bool, optional

Consider the edge weights in determining the shortest paths. If False, all edge weights are considered equal.

sources : node list

A list of nodes to consider as sources for shortest paths.

Returns:

nodes : dictionary

Dictionary of nodes with betweeness centrality as the value.

Notes

See Sec. 4 in Ulrik Brandes, A Faster Algorithm for Betweenness Centrality. Journal of Mathematical Sociology 25(2):163-177, 2001. http://www.inf.uni-konstanz.de/algo/publications/b-fabc-01.pdf

This algorithm does not count the endpoints, i.e. a path from s to t does not contribute to the betweenness of s and t.