rustworkx.group_betweenness_centrality

group_betweenness_centrality(graph, group, normalized=True, parallel_threshold=50)[source]

Compute the group betweenness centrality of a set of nodes.

Group betweenness centrality measures the fraction of shortest paths between non-group node pairs that pass through at least one group member. It is defined as:

\[C_B(S) = \sum_{s,t \in V \setminus S} \frac{\sigma(s, t|S)}{\sigma(s, t)}\]

where \(\sigma(s,t)\) is the number of shortest paths from \(s\) to \(t\), and \(\sigma(s,t|S)\) is the number of those paths passing through at least one node in \(S\).

Based on: Everett, M. G., & Borgatti, S. P. (1999). The centrality of groups and classes. Journal of Mathematical Sociology, 23(3), 181-201.

This function is multithreaded and will run in parallel if the number of nodes in the graph is above the value of parallel_threshold (it defaults to 50). If the function will be running in parallel the env var RAYON_NUM_THREADS can be used to adjust how many threads will be used.

Parameters:
  • graph – The input graph. Can either be a PyGraph or PyDiGraph.

  • group (list) – A list of node indices representing the group.

  • normalized (bool) – Whether to normalize the result. Defaults to True.

  • parallel_threshold (int) – The number of nodes to calculate the the group betweenness centrality in parallel at if the number of nodes in the graph is less than this value it will run in a single thread. The default value is 50.

Returns:

The group betweenness centrality as a float.

Return type:

float