Skip to main content

edge_betweenness_cutoff

Function edge_betweenness_cutoff 

Source
pub fn edge_betweenness_cutoff(
    graph: &Graph,
    cutoff: u32,
) -> IgraphResult<Vec<f64>>
Expand description

Range-limited edge betweenness centrality.

Computes edge betweenness considering only shortest paths of length at most cutoff. The result is a vector indexed by edge id.

For undirected graphs the result is halved (each unordered pair counted once).

§Parameters

  • graph — the input graph.
  • cutoff — maximum shortest-path length to consider.

§Examples

use rust_igraph::{Graph, edge_betweenness_cutoff};

// Path 0—1—2—3 with cutoff=2
let mut g = Graph::with_vertices(4);
for i in 0..3u32 { g.add_edge(i, i + 1).unwrap(); }
let eb = edge_betweenness_cutoff(&g, 2).unwrap();
// Edge 0 (0-1): on paths (0,1) len 1 and (0,2) len 2 → 2 pairs
// Edge 1 (1-2): on paths (1,2) len 1 and (0,2) len 2 and (1,3) len 2 → 3 pairs
// Edge 2 (2-3): on paths (2,3) len 1 and (1,3) len 2 → 2 pairs
assert_eq!(eb, vec![2.0, 3.0, 2.0]);