easygraph.functions.centrality.betweenness module#
- easygraph.functions.centrality.betweenness.betweenness_centrality(G, weight=None, sources=None, normalized=True, endpoints=False, n_workers=None)[source]#
Compute the shortest-basic betweenness centrality for nodes.
\[c_B(v) = \sum_{s,t \in V} \frac{\sigma(s, t|v)}{\sigma(s, t)}\]where V is the set of nodes,
\[\sigma(s, t)\]is the number of shortest (s, t)-paths, and
\[\sigma(s, t|v)\]is the number of those paths passing through some node v other than s, t.
\[If\ s\ =\ t,\ \sigma(s, t) = 1, and\ if\ v \in {s, t}, \sigma(s, t|v) = 0 [2]_.\]- Parameters:
G (graph) – A easygraph graph.
weight (None or string, optional (default=None)) – If None, all edge weights are considered equal. Otherwise holds the name of the edge attribute used as weight.
sources (None or nodes list, optional (default=None)) – If None, all nodes are considered. Otherwise,the set of source vertices to consider when calculating shortest paths.
normalized (bool, optional) – If True the betweenness values are normalized by 2/((n-1)(n-2)) for graphs, and 1/((n-1)(n-2)) for directed graphs where n is the number of nodes in G.
endpoints (bool, optional) – If True include the endpoints in the shortest basic counts.
- Returns:
nodes (dictionary) – Dictionary of nodes with betweenness centrality as the value.
>>> betweenness_centrality(G,weight=”weight”)