Skip to main content

community_size_balance

Function community_size_balance 

Source
pub fn community_size_balance(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the community size balance.

Entropy of the community size distribution (from greedy partition) normalized by log(k). Values near 1 indicate balanced community sizes; values near 0 indicate one dominant community. Returns 0.0 for trivial graphs or when only one community exists.

§Examples

use rust_igraph::{Graph, community_size_balance};

// Two disconnected K_2s: 2 communities of equal size → balance = 1.0
let g = Graph::from_edges(&[(0,1),(2,3)], false, Some(4)).unwrap();
let r = community_size_balance(&g).unwrap();
assert!((r - 1.0).abs() < 0.1);