group_betweenness#
- graph_tool.centrality.group_betweenness(g, group, weight=None, norm=True, endpoints=False)[git][source]#
Calculate the betweenness centrality of a group of vertices.
- Parameters:
- g
Graph Graph to be used.
- grouplist or
numpy.ndarray Vertices of the group.
- weight
EdgePropertyMap(optional, default:None) Edge lengths. If not supplied, every edge has unit length.
- norm
bool(optional, default:True) Whether or not the value should be normalized.
- endpoints
bool(optional, default:False) If
True, the pairs of vertices in which one of them belongs to the group are also included.
- g
- Returns:
- GBC
float The group betweenness centrality.
- GBC
See also
betweennessBetweenness of single vertices
prominent_groupGroup of largest betweenness
group_closenessGroup closeness centrality
group_degreeGroup degree centrality
Notes
The group betweenness [everett-centrality-1999] of a group \(C\) is
\[C_B(C) = \sum_{s,t\notin C,\, s\ne t}\frac{\sigma_{st}(C)}{\sigma_{st}},\]where \(\sigma_{st}\) is the number of shortest paths from \(s\) to \(t\), and \(\sigma_{st}(C)\) the number of them that pass through at least one vertex of \(C\). If
endpoints == True, the sum is over all ordered pairs, and the pairs with an endpoint in \(C\) contribute one if they are connected. For undirected graphs, the sum is divided by two. Ifnorm == True, the value is instead divided by \(m(m-1)\), where \(m = n - |C|\) (or \(m=n\) ifendpoints == True), for both directed and undirected graphs.The shortest paths that avoid the group are counted on the shortest-path tree of each source, in time \(O(VE)\) for unweighted graphs and \(O(VE + V(V+E)\log V)\) for weighted graphs.
Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[everett-centrality-1999]M. G. Everett and S. P. Borgatti, “The centrality of groups and classes”, The Journal of Mathematical Sociology 23, 181-201 (1999), DOI: 10.1080/0022250X.1999.9990219 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.group_betweenness(g, [0, 33])) 0.684557411...