pub fn edge_betweenness_community_weighted(
graph: &Graph,
weights: &[f64],
) -> IgraphResult<EdgeBetweennessResult>Expand description
Run weighted edge-betweenness community detection on graph with
per-edge weights.
Returns the same EdgeBetweennessResult shape as the unweighted
CO-006 entrypoint. edge_betweenness[i] is the weighted
betweenness of the i-th removed edge at the moment of removal
(halved for undirected to match the centrality convention, left
un-halved for directed). Per-level modularity uses
modularity_weighted (undirected) or
modularity_weighted_directed (directed) so the best-Q partition
reflects edge weights, not just edge counts.
Accepts both undirected and directed graphs: the directed branch uses directed Dijkstra (OUT-incidence forward, IN-incidence backward) and directed weighted modularity (Leicht-Newman 2008).
§Errors
IgraphError::InvalidArgumentifweights.len() != ecount, or if any weight is NaN, negative, or non-finite.
§Examples
use rust_igraph::{Graph, edge_betweenness_community_weighted};
// Two K3 triangles bridged by edge (2,3). Weights = 1.0 everywhere
// ⇒ identical result to the unweighted slice (CO-006).
let mut g = Graph::with_vertices(6);
for &(u, v) in &[(0, 1), (0, 2), (1, 2), (3, 4), (3, 5), (4, 5), (2, 3)] {
g.add_edge(u, v).unwrap();
}
let w = vec![1.0_f64; g.ecount()];
let r = edge_betweenness_community_weighted(&g, &w).unwrap();
assert_eq!(r.nb_clusters, 2);
assert_eq!(r.membership[0], r.membership[1]);
assert_eq!(r.membership[3], r.membership[5]);
assert_ne!(r.membership[0], r.membership[3]);