pub fn compare_communities(
comm1: &[u32],
comm2: &[u32],
method: CommunityComparison,
) -> IgraphResult<f64>Expand description
Compare two community membership vectors over the same vertex set.
Both vectors must have the same length. Cluster ids do not have to
be densified — they are reindexed internally via
crate::reindex_membership.
The returned f64 carries either a distance (VI, SplitJoin)
or a similarity (NMI, Rand, AdjustedRand) depending on
CommunityComparison.
§Examples
use rust_igraph::{compare_communities, CommunityComparison};
// Identical partitions.
let q = compare_communities(
&[0, 0, 1, 1],
&[5, 5, 7, 7],
CommunityComparison::NormalizedMutualInformation,
).unwrap();
assert!((q - 1.0).abs() < 1e-12);
let q = compare_communities(
&[0, 0, 1, 1],
&[5, 5, 7, 7],
CommunityComparison::VariationOfInformation,
).unwrap();
assert!(q.abs() < 1e-12);§Errors
IgraphError::InvalidArgumentifcomm1.len() != comm2.len().IgraphError::InvalidArgumentifn < 2andmethodisRandorAdjustedRand(mirrors the C reference).