pub fn fluid_communities(graph: &Graph, k: u32) -> IgraphResult<FluidResult>Expand description
Run Fluid Communities with default options
(seed = 0, max_iterations = FLUID_DEFAULT_MAX_ITERATIONS).
k is the number of communities to find; it must satisfy
1 ≤ k ≤ vcount. Self-loops, parallel edges, disconnected
components, and weighted graphs are all rejected.
§Errors
IgraphError::InvalidArgumentifk = 0,k > vcount, or the graph is not simple / not connected.
§Examples
use rust_igraph::{Graph, fluid_communities};
// Two K4 cliques joined by a single bridge edge — the two-community
// partition is the obvious result for k=2.
let mut g = Graph::with_vertices(8);
for u in 0..4 {
for v in (u + 1)..4 {
g.add_edge(u, v).unwrap();
}
}
for u in 4..8 {
for v in (u + 1)..8 {
g.add_edge(u, v).unwrap();
}
}
g.add_edge(3, 4).unwrap();
let r = fluid_communities(&g, 2).unwrap();
assert_eq!(r.membership[0], r.membership[1]);
assert_eq!(r.membership[4], r.membership[5]);
assert_ne!(r.membership[0], r.membership[4]);