pub fn betweenness_cutoff(graph: &Graph, cutoff: u32) -> IgraphResult<Vec<f64>>Expand description
Range-limited betweenness centrality.
Computes betweenness centrality for all vertices using only shortest
paths of length at most cutoff. Shorter cutoffs reduce computation
time by limiting BFS depth, capturing local betweenness structure.
For undirected graphs the result is halved (each unordered pair counted once). This matches igraph’s convention.
§Parameters
graph— the input graph.cutoff— maximum shortest-path length to consider.
§Examples
use rust_igraph::{Graph, betweenness_cutoff};
// Path 0—1—2—3—4
let mut g = Graph::with_vertices(5);
for i in 0..4u32 { g.add_edge(i, i + 1).unwrap(); }
// With cutoff=2, vertex 2 lies on paths of length ≤2:
// (1,3) only. (0,2) passes through 1, not 2.
let b = betweenness_cutoff(&g, 2).unwrap();
// All betweenness ≤ full betweenness
assert!(b[2] <= 4.0);