Skip to main content

le_community_to_membership

Function le_community_to_membership 

Source
pub fn le_community_to_membership(
    merges: &[(i64, i64)],
    steps: usize,
    membership: &[i64],
) -> Result<(Vec<i64>, Vec<i64>)>
Expand description

Applies steps merges of a leading eigenvector dendrogram to an initial partition, returning the new membership vector and community sizes.

Unlike community_to_membership, the dendrogram leaves are the m communities of membership (ids 0..m, contiguous), and the i-th merge forms community m + i, as produced by Graph::community_leading_eigenvector. The result has m - steps communities. Time complexity: O(|V|).

Binds igraph_le_community_to_membership.

§Errors

ErrorKind::InvalidValue for non-contiguous or negative ids, too many steps, or merges referring to already merged clusters.

§Examples

use igraph::community::le_community_to_membership;
let (membership, sizes) = le_community_to_membership(&[(1, 3)], 1, &[0, 1, 2, 3, 4]).unwrap();
assert_eq!(membership, vec![1, 0, 2, 0, 3]);
assert_eq!(sizes, vec![2, 1, 1, 1]);