pub fn leiden_weighted(
graph: &Graph,
weights: &[f64],
) -> IgraphResult<LeidenResult>Expand description
Run Leiden with per-edge weights (modularity objective, γ = 1,
β = 0.01, two iterations, seed 0).
§Errors
IgraphError::Unsupportedifgraphis directed.IgraphError::InvalidArgumentifweights.len() != ecount, any weight is non-finite, or any weight is negative.
§Examples
use rust_igraph::{Graph, leiden_weighted};
// Two K3s + bridge with heavy intra-clique and very thin bridge:
// Leiden splits the two triangles.
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 weights = vec![10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.01];
let r = leiden_weighted(&g, &weights).unwrap();
assert_eq!(r.membership[0], r.membership[1]);
assert_ne!(r.membership[0], r.membership[3]);