pub fn edge_betweenness_community(
graph: &Graph,
) -> IgraphResult<EdgeBetweennessResult>Expand description
Run edge-betweenness community detection on graph.
Returns the partition with the highest modularity along the Girvan-Newman dendrogram, plus the full removal history and merges so callers can replay alternative cuts. Accepts both undirected and directed graphs: the directed branch uses directed shortest paths (OUT-incidence forward, IN-incidence backward) and directed modularity (Leicht-Newman 2008) for the per-level Q.
§Errors
Returns IgraphError only for internal-consistency failures (edge
id overflow in the dendrogram replay, dangling adjacency entries).
Both graph orientations are supported.
§Examples
use rust_igraph::{Graph, edge_betweenness_community};
// Two K3 triangles bridged by a single edge (0-1-2)-(3-4-5).
// Girvan-Newman removes the bridge first, splitting into the two
// expected communities.
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 r = edge_betweenness_community(&g).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]);