pub fn group_betweenness_centrality<G>(
graph: G,
group: &[usize],
normalized: bool,
parallel_threshold: usize,
) -> f64where
G: NodeIndexable + IntoNodeIdentifiers + IntoNeighborsDirected + NodeCount + GraphProp + GraphBase + Sync,
G::NodeId: Eq + Hash,Expand description
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\S} 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.
Arguments:
graph- The graph object to run the algorithm ongroup- A slice of node indices representing the groupnormalized- Whether to normalize the resultparallel_threshold- The number of nodes to calculate the group betweenness centrality in parallel at, if the number of nodes ingraphis less than this value it will run in a single thread. A good default to use here if you’re not sure is50as that was found to be roughly the number of nodes where parallelism improves performance for the standard betweenness centrality function.
This function uses multiple threads for per-source shortest path searches
when the graph has at least parallel_threshold nodes. 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.
§Example
use rustworkx_core::petgraph;
use rustworkx_core::centrality::group_betweenness_centrality;
let g = petgraph::graph::UnGraph::<i32, ()>::from_edges([
(0, 1), (1, 2), (2, 3), (3, 4)
]);
let output = group_betweenness_centrality(&g, &[2], true, 50);
// Node 2 is on every shortest path between {0,1} and {3,4}.
assert!(output > 0.0);