Skip to main content

leiden_with_options

Function leiden_with_options 

Source
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

§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);