|
1 | 1 | # Graph automorphism groups |
2 | | -To obtain information about a graph's automorphism group, use `nauty(g)`. This will return the canonical permutation as well as an `AutomorphismGroup` object. |
3 | | -Right now, the recorded properties of the automorphism group are very limited and only include the group size and orbits, but this will change in the future. |
| 2 | + |
| 3 | +Use `automorphism_group(g)` to get a graph's [`AutomorphismGroup`](@ref). |
| 4 | +It reports the group's [`order`](@ref), its vertex [`orbits`](@ref) and a set of [`generators`](@ref), and leaves `g` untouched. |
| 5 | + |
| 6 | +```jldoctest groups |
| 7 | +julia> using NautyGraphs, Graphs |
| 8 | +
|
| 9 | +julia> g = NautyGraph(smallgraph(:petersen)); |
| 10 | +
|
| 11 | +julia> autg = automorphism_group(g) |
| 12 | +AutomorphismGroup |
| 13 | + order 120 |
| 14 | + vertices 10 |
| 15 | + orbits 1 |
| 16 | + generators 4 |
| 17 | +
|
| 18 | +julia> order(autg) |
| 19 | +120 |
| 20 | +
|
| 21 | +julia> orbit_partition(autg) |
| 22 | +1-element Vector{Vector{Int64}}: |
| 23 | + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
| 24 | +``` |
| 25 | + |
| 26 | +Generators are permutations in one-based form: generator `p` maps vertex `i` to `p[i]`. |
| 27 | +Together they generate the whole group, so its `order` is generally much larger than the number of generators. |
| 28 | + |
| 29 | +The identity belongs to every automorphism group and is never listed as a generator. |
| 30 | +A graph with no symmetry therefore comes back with an empty generating set, not with a single identity permutation. |
| 31 | + |
| 32 | +```jldoctest groups |
| 33 | +julia> frucht = automorphism_group(NautyGraph(smallgraph(:frucht))) |
| 34 | +AutomorphismGroup |
| 35 | + order 1 |
| 36 | + vertices 12 |
| 37 | + orbits 12 |
| 38 | + generators 0 |
| 39 | +
|
| 40 | +julia> generators(frucht) |
| 41 | +Vector{Int32}[] |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +`orbits(autg)` labels every vertex with the smallest vertex it can be mapped to, so two vertices share an orbit exactly if they carry the same label. |
| 46 | +`orbit_partition(autg)` turns that labelling into one vector per orbit, at the cost of an allocation per orbit. |
| 47 | + |
| 48 | +## Computing less |
| 49 | + |
| 50 | +`automorphism_group` computes everything nauty can report. |
| 51 | +When that is more than you need, call [`nauty`](@ref) directly and switch the expensive parts off. |
| 52 | +It returns the canonical permutation alongside the group, so nothing has to be recomputed: |
| 53 | + |
| 54 | +```jldoctest groups |
| 55 | +julia> canonperm, autg = nauty(g; generators=true); |
| 56 | +
|
| 57 | +julia> order(autg) |
| 58 | +120.0 |
| 59 | +``` |
| 60 | + |
| 61 | +The orbits and an approximate order come for free with every run. |
| 62 | +The generators and the exact order each cost an extra callback into Julia, so they are opt-in: |
| 63 | + |
| 64 | +| keyword | what it adds | cost | |
| 65 | +| --- | --- | --- | |
| 66 | +| none | orbits, `order` as a `Float64` | free | |
| 67 | +| `generators=true` | the generating permutations | one callback per generator | |
| 68 | +| `exact_order=true` | `order` as an exact `BigInt` | one callback per search-tree level | |
| 69 | +| `canonize=true` | canonizes `g` in place | rewrites the group into the new numbering | |
| 70 | + |
| 71 | +Without `exact_order=true`, `order(autg)` is a `Float64`: it carries about 16 significant digits, is exact up to roughly `10^12`, and overflows to `Inf` past `10^308`. |
| 72 | +Ask for the exact order whenever you need to count with it, for example when dividing by ``|\mathrm{Aut}(g)|``. |
| 73 | + |
| 74 | +!!! warning "`canonize` renumbers the group as well" |
| 75 | + |
| 76 | + Nauty reports the automorphism group in terms of `g`'s vertex numbering on input. |
| 77 | + With `canonize=true` that numbering is replaced, so the returned orbits and generators are rewritten to match the canonized `g` and no longer refer to the graph as it was passed in. |
| 78 | + |
| 79 | +## Working with the group |
| 80 | + |
| 81 | +NautyGraphs deliberately does not implement group theory beyond what nauty reports. |
| 82 | +To enumerate elements, test membership or build stabilizer chains, hand the generators to a group theory package: |
| 83 | + |
| 84 | +```julia |
| 85 | +using PermutationGroups |
| 86 | +group = PermGroup([Perm(p) for p in generators(autg)]) |
| 87 | +``` |
0 commit comments