Skip to main content

split_join_distance

Function split_join_distance 

Source
pub fn split_join_distance(
    comm1: &[u32],
    comm2: &[u32],
) -> IgraphResult<SplitJoinDistance>
Expand description

Compute the two asymmetric projection distances between comm1 and comm2.

Both vectors must have the same length. Cluster ids do not have to be densified — they are reindexed internally via crate::reindex_membership. Empty inputs return (0, 0).

§Examples

use rust_igraph::split_join_distance;

// comm1 is a sub-partition of comm2: every cluster in comm1 fits
// entirely inside some cluster of comm2, so d12 == 0.
let r = split_join_distance(&[0, 0, 1, 2], &[0, 0, 0, 1]).unwrap();
assert_eq!(r.d12, 0);
assert_eq!(r.d21, 1);
assert_eq!(r.total(), 1);

// Identical partitions: both distances are 0.
let r = split_join_distance(&[0, 0, 1, 1], &[5, 5, 7, 7]).unwrap();
assert_eq!(r.d12, 0);
assert_eq!(r.d21, 0);

§Errors