pub fn automorphism_group(
graph: &Graph,
colors: Option<&[u32]>,
) -> IgraphResult<Vec<Vec<u32>>>Expand description
Compute a generating set of the automorphism group Aut(G).
Returns a small list of permutations that generate the whole group:
every automorphism of graph is a product of these generators (and
their inverses). Each generator g is a vertex permutation given as a
Vec<u32> where g[v] is the image of vertex v; it preserves
adjacency and, when supplied, vertex colours. This mirrors igraph’s
igraph_automorphism_group, which likewise returns generators rather
than the full (potentially factorial) group.
The generating set is not unique — different correct implementations
(and igraph’s bliss backend) may return different generators. What is
invariant is the group they generate: its order equals
count_automorphisms.
The trivial group (only the identity) is represented by an empty list.
colors is an optional per-vertex colour slice (length must equal the
vertex count); only colour-preserving permutations are included. Pass
None for an uncoloured graph.
Generators come from the shared individualization-refinement engine (see
canonical_permutation):
every leaf of the I-R search tree whose certificate equals the canonical
one yields one automorphism, and a greedy subset that generates all of
them is returned.
§Scope
Simple graphs (directed or undirected), self-loops allowed, optional vertex colours. Multi-edges are rejected.
§Errors
Returns an error if colors has the wrong length or the graph has
multiple edges between the same pair of vertices.
§Examples
use rust_igraph::{Graph, automorphism_group};
// The path P_3 (0-1-2) has one non-trivial automorphism: the end swap
// (0 2). So a single generator suffices.
let mut p3 = Graph::new(3, false).unwrap();
p3.add_edge(0, 1).unwrap();
p3.add_edge(1, 2).unwrap();
let gens = automorphism_group(&p3, None).unwrap();
assert_eq!(gens, vec![vec![2, 1, 0]]);