Skip to main content

compare_communities

Function compare_communities 

Source
pub fn compare_communities(
    comm1: &[i64],
    comm2: &[i64],
    method: CommunityComparison,
) -> Result<f64>
Expand description

Compares two partitions of the same set with the given measure.

Community ids need not be contiguous. Time complexity: O(n log n).

Binds igraph_compare_communities.

§Errors

ErrorKind::InvalidValue if the lengths differ, or for the Rand indices with fewer than two elements.

§Examples

use igraph::prelude::*;
use igraph::community::compare_communities;
let a = [2, 0, 2, 1, 1, 0, 2, 2, 1, 2];
let b = [1, 1, 2, 1, 1, 0, 2, 2, 0, 2];
let rand = compare_communities(&a, &b, CommunityComparison::Rand).unwrap();
assert!((rand - 0.711111).abs() < 1e-6);
// Relabeling does not matter:
let vi = compare_communities(&[0, 1], &[1, 0], CommunityComparison::Vi).unwrap();
assert_eq!(vi, 0.0);