group_betweenness_centrality#
- group_betweenness_centrality(G, C, normalized=True, weight=None, endpoints=False)[source]#
Compute the group betweenness centrality for a group of nodes.
Group betweenness centrality of a group of nodes \(C\) is the sum of the fraction of all-pairs shortest paths that pass through any vertex in \(C\)
\[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|C)\) is the number of those paths passing through some node in group \(C\). Note that \((s, t)\) are not members of the group (\(V-C\) is the set of nodes in \(V\) that are not in \(C\)).
- Parameters:
- Ggraph
A NetworkX graph.
- Clist or set or list of lists or list of sets
A group or a list of groups containing nodes which belong to G, for which group betweenness centrality is to be calculated.
- normalizedbool, optional (default=True)
If True, group betweenness is normalized by \(1/(N_{out}(N_{out}-1))\) where \(N_{out}\) is the number of nodes in
Gthat are not inC. This ensures the reported value is between 0 and 1. Ifendpointsis True, the normalization uses all nodes inG. The reported value is then between \(2N_{in}/(N-1)\) and 1 where \(N_{in}\) is the number of nodes inCand \(N\) the number of nodes inG.- weightNone or string, optional (default=None)
If None, all edge weights are considered equal. Otherwise holds the name of the edge attribute used as weight. The weight of an edge is treated as the length or distance between the two sides.
- endpointsbool, optional (default=False)
By default, only node-pairs that are both not in
Care counted for group betweenness centrality. The count is how many non-Cnode-pairs have nodes fromC“between” them on a shortest path.When
endpoints=True, we also count node-pairs with one or both nodes inCwhile considering endpoint nodes as being between the node-pairs. So we count paths that start inCwhether or not they pass through any other nodes inC. This adds centrality to large groups without any reference to the connectivity of the group. The minimum normalized score is \(N_{in}(N_{in}-1)/(N(N-1))\) instead of 0. For that reason, this feature is rarely used.We don’t currently support considering node-pairs with nodes in
Cwithout also counting their endpoints. Nor do we support counting endpoints while only considering node-pairs that are both not inC. This keyword indicates both coutning endpoints of paths and allowing node-pairs in C.
- Returns:
- betweennesslist of floats or float
If
Cis a single group then return a float. IfCis a list with several groups then return a list of group betweenness centralities.
- Raises:
- NodeNotFound
If node(s) in
Care not present inG.
See also
Notes
Group betweenness centrality is defined in [1] and discussed in [3]. The algorithm is described in [2] and is based on techniques mentioned in [4].
The number of nodes in the group must be a maximum of
N - 2whereNis the total number of nodes in the graph.For weighted graphs the edge weights must be greater than zero. Zero edge weights can produce an infinite number of equal length paths between pairs of nodes.
The total number of paths between source and target is counted differently for directed and undirected graphs. Directed paths between “u” and “v” are counted as two possible paths (one each direction) while undirected paths between “u” and “v” are counted as one path. Said another way, the sum in the expression above is over all
s != tfor directed graphs and fors < tfor undirected graphs.References
[1]M G Everett and S P Borgatti: The Centrality of Groups and Classes. Journal of Mathematical Sociology. 23(3): 181-201. 1999. http://www.analytictech.com/borgatti/group_centrality.htm
[2]Ulrik Brandes: On Variants of Shortest-Path Betweenness Centrality and their Generic Computation. Social Networks 30(2):136-145, 2008. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.9610&rep=rep1&type=pdf
[3]Sourav Medya et. al.: Group Centrality Maximization via Network Design. SIAM International Conference on Data Mining, SDM 2018, 126–134. https://sites.cs.ucsb.edu/~arlei/pubs/sdm18.pdf
[4]Rami Puzis, Yuval Elovici, and Shlomi Dolev. “Fast algorithm for successive computation of group betweenness centrality.” https://journals.aps.org/pre/pdf/10.1103/PhysRevE.76.056709