pub fn edge_betweenness_centrality<G>(
    graph: G,
    normalized: bool,
    parallel_threshold: usize
) -> Vec<Option<f64>>where
    G: NodeIndexable + EdgeIndexable + IntoEdges + IntoNodeIdentifiers + IntoNeighborsDirected + NodeCount + EdgeCount + GraphProp + Sync,
    G::NodeId: Eq + Hash + Send,
    G::EdgeId: Eq + Hash + Send,
Expand description

Compute the edge betweenness centrality of all edges in a graph.

The algorithm used in this function is based on:

Ulrik Brandes: On Variants of Shortest-Path Betweenness Centrality and their Generic Computation. Social Networks 30(2):136-145, 2008. https://doi.org/10.1016/j.socnet.2007.11.001.

This function is multithreaded and will run in parallel if the number of nodes in the graph is above the value of parallel_threshold. 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.

Arguments:

  • graph - The graph object to run the algorithm on
  • normalized - Whether to normalize the betweenness scores by the number of distinct paths between all pairs of nodes
  • parallel_threshold - The number of nodes to calculate the betweenness centrality in parallel at, if the number of nodes in graph is less than this value it will run in a single thread. A good default to use here if you’re not sure is 50 as that was found to be roughly the number of nodes where parallelism improves performance

Example

use rustworkx_core::petgraph;
use rustworkx_core::centrality::edge_betweenness_centrality;

let g = petgraph::graph::UnGraph::<i32, ()>::from_edges(&[
    (0, 4), (1, 2), (1, 3), (2, 3), (3, 4), (1, 4)
]);

let output = edge_betweenness_centrality(&g, false, 200);
let expected = vec![Some(4.0), Some(2.0), Some(1.0), Some(2.0), Some(3.0), Some(3.0)];
assert_eq!(output, expected);

See Also

betweenness_centrality