Skip to main content

community_to_membership

Function community_to_membership 

Source
pub fn community_to_membership(
    merges: &[[u32; 2]],
    nodes: u32,
    steps: u32,
) -> IgraphResult<CommunityToMembershipResult>
Expand description

Cut a binary dendrogram at steps merges, returning the resulting membership and cluster-size vectors.

merges[i] = [c1, c2] is the i-th merge: it combines dendrogram nodes c1 and c2 into the new node with id nodes + i. Leaves are numbered 0..nodes; nodes ≥ nodes are internal merges from earlier rows.

§Errors

  • InvalidArgument if steps > merges.len().
  • InvalidArgument if a merge entry would be merged twice.
  • InvalidArgument if a merge entry references a dendrogram node that does not exist (≥ nodes + i at row i).

§Examples

use rust_igraph::community_to_membership;

// Four leaves, one merge: {0,1} | {2} | {3}.
let r = community_to_membership(&[[0, 1]], 4, 1).unwrap();
assert_eq!(r.membership, vec![0, 0, 1, 2]);
assert_eq!(r.csize, vec![2, 1, 1]);