pub fn leiden_with_options(
graph: &Graph,
weights: Option<&[f64]>,
opts: &LeidenOptions,
) -> IgraphResult<LeidenResult>Expand description
Run Leiden with the full set of options.
§Errors
IgraphError::Unsupportedifgraphis directed.IgraphError::InvalidArgumentfor malformed weights,opts.resolution < 0,!opts.beta.is_finite(),opts.beta < 0,!opts.resolution.is_finite(), negative weights withLeidenObjective::ModularityorLeidenObjective::Er, or a non-Noneopts.startwhose length differs fromvcount.
§Examples
use rust_igraph::{Graph, LeidenObjective, LeidenOptions, leiden_with_options};
// Same partition every time for a fixed seed.
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 opts = LeidenOptions {
objective: LeidenObjective::Cpm,
resolution: 0.1,
seed: 42,
..LeidenOptions::default()
};
let a = leiden_with_options(&g, None, &opts).unwrap();
let b = leiden_with_options(&g, None, &opts).unwrap();
assert_eq!(a.membership, b.membership);