pub fn betweenness_subset(
graph: &Graph,
sources: &[VertexId],
targets: &[VertexId],
directed: bool,
) -> IgraphResult<Vec<f64>>Expand description
Subset betweenness centrality.
Computes betweenness for all vertices considering only shortest paths
that start in sources and end in targets.
For undirected graphs (or when directed = false), the result is
halved since each unordered pair is counted once.
§Parameters
graph— the input graph.sources— source vertices for the shortest paths.targets— target vertices for the shortest paths.directed— whether to follow edge directions (ignored for undirected graphs).
§Examples
use rust_igraph::{Graph, betweenness_subset};
// Path 0—1—2—3—4: sources={0,1}, targets={3,4}
let mut g = Graph::with_vertices(5);
for i in 0..4u32 { g.add_edge(i, i + 1).unwrap(); }
let b = betweenness_subset(&g, &[0, 1], &[3, 4], true).unwrap();
// Vertex 2 lies on paths (0,3),(0,4),(1,3),(1,4) — betweenness = 4/2 = 2
// Vertex 3 lies on paths (0,4),(1,4) — betweenness = 2/2 = 1
assert!((b[2] - 2.0).abs() < 1e-12);
assert!((b[3] - 1.0).abs() < 1e-12);