Skip to main content

invert_permutation

Function invert_permutation 

Source
pub fn invert_permutation(perm: &[i64]) -> Result<Vec<i64>>
Expand description

Inverts a permutation of 0..n (igraph_invert_permutation).

The result inv satisfies inv[perm[i]] == i for all i. Handy to turn the labeling returned by Graph::canonical_permutation (“which vertex goes to position i”) into “which position does vertex v go to”, or to turn a map21 of IsoMapping into a map12.

Binds igraph_invert_permutation.

§Errors

ErrorKind::InvalidValue if perm is not a permutation of 0..perm.len().

§Examples

use igraph::isomorphism::invert_permutation;
assert_eq!(invert_permutation(&[2, 0, 1]).unwrap(), vec![1, 2, 0]);
assert!(invert_permutation(&[0, 0, 1]).is_err());