pub fn edge_betweenness_subset(
graph: &Graph,
sources: &[VertexId],
targets: &[VertexId],
directed: bool,
) -> IgraphResult<Vec<f64>>Expand description
Subset edge betweenness centrality.
Computes edge betweenness considering only shortest paths that
originate in sources and terminate in targets. The result is a
vector indexed by edge id.
For undirected graphs (or when directed = false), the result is
halved.
§Parameters
graph— the input graph.sources— source vertices.targets— target vertices.directed— whether to follow edge directions (ignored for undirected graphs).
§Examples
use rust_igraph::{Graph, edge_betweenness_subset};
// Path 0—1—2—3: sources={0}, targets={2,3}
let mut g = Graph::with_vertices(4);
for i in 0..3u32 { g.add_edge(i, i + 1).unwrap(); }
let eb = edge_betweenness_subset(&g, &[0], &[2, 3], true).unwrap();
// Edge 0 (0-1): on paths (0,2),(0,3) → 2
// Edge 1 (1-2): on paths (0,2),(0,3) → 2
// Edge 2 (2-3): on path (0,3) → 1
// Undirected → halved: [1.0, 1.0, 0.5]
assert!((eb[0] - 1.0).abs() < 1e-12);
assert!((eb[1] - 1.0).abs() < 1e-12);
assert!((eb[2] - 0.5).abs() < 1e-12);