Expand description
§Permutations
This module provides a Permutation struct and associated functionalities
for representing and working with permutations of a sequence of integers 0..n.
§Key Features:
- Representation: A
Permutationis stored by its direct mapping (map[i]is the image ofi) and its inverse mapping. - Construction:
- Identity permutation:
Permutation::id(n). - From a mapping vector:
Permutation::from_map(vec![...]). - From disjoint cycles:
Permutation::from_disjoint_cycles(&[vec![...]]). - From potentially overlapping cycles with specified composition order:
Permutation::from_cycles_ordered(&[vec![...]], order).
- Identity permutation:
- Basic Operations:
- Inverse:
p.inverse(). - Composition:
p1.compose(&p2)(appliesp2thenp1). - Apply to slices:
p.apply_slice(data)(returns a newVec),p.apply_slice_in_place(data_mut). - Power:
p.pow(k). - Sign:
p.sign()(+1 for even, -1 for odd). - Check for identity:
p.is_identity().
- Inverse:
- Cycle Utilities:
- Find cycle decomposition:
p.find_cycles(). - Convert to transpositions:
p.transpositions().
- Find cycle decomposition:
- Iterators:
p.iter_slice(data): Iterates overdatain the order defined byp.map.p.iter_slice_inv(data): Iterates overdatain the order defined byp.inv.- Mutable versions:
p.iter_slice_mut(data_mut),p.iter_slice_inv_mut(data_mut).
- Ranking and Unranking:
- Myrvold & Ruskey’s ranking/unranking algorithms (
myrvold_ruskey_rank1,myrvold_ruskey_unrank1, etc.).
- Myrvold & Ruskey’s ranking/unranking algorithms (
- Sorting:
Permutation::sort(slice): Returns the permutation that sorts the slice.
- Graph Integration:
- The
HedgeGraphExtandPermutationExttraits suggest integration with graph structures, likely for tasks like finding graph automorphisms or canonical labellings by permuting vertices/hedges.
- The
The module is designed to be comprehensive for permutation-related tasks, including those relevant to combinatorial algorithms and graph theory.
Structs§
- Permutation
- A permutation of
0..n, with the ability to apply itself (or its inverse) to slices. - Permutation
MapIter - An iterator over a slice, ordered by a permutation’s
map. - Permutation
MapIter Mut
Enums§
- Cycle
Order - Specifies the direction for reading cycle compositions
- Permutation
Error