nauty_automorphism_group#
- graph_tool.structure.nauty_automorphism_group(g, vertex_label=None, edge_label=None, orbits=False, canonical=False, traces=False)[git][source]#
Obtain the automorphism group of the graph with the nauty or Traces algorithms.
- Parameters:
- g
Graph Graph to be used.
- vertex_label
VertexPropertyMap(optional, default:None) If given, only automorphisms that preserve the values of this property map are considered.
- edge_label
EdgePropertyMap(optional, default:None) If given, only automorphisms that preserve the values of this property map are considered.
- orbits
bool(optional, default:False) If
True, the vertex orbits of the group are also returned.- canonical
bool(optional, default:False) If
True, a canonical labeling of the vertices is also returned.- traces
bool(optional, default:False) If
True, the Traces algorithm is used instead of nauty’s.
- g
- Returns:
- generators
listofVertexPropertyMap Generators of the automorphism group, each given by the image
gen[v]of every vertexv.- order
int Order of the automorphism group, i.e. the number of automorphisms.
- orbit
VertexPropertyMap Orbit of every vertex, labeled by the smallest vertex index it contains. Only returned if
orbits == True.- labeling
VertexPropertyMap Canonical position of every vertex, in the range \([0, V-1]\). Only returned if
canonical == True.
- generators
See also
bliss_automorphism_groupAutomorphism group with the bliss algorithm
isomorphismIsomorphism test between two graphs
weisfeiler_lehman_hashHash of a graph that is invariant under isomorphism
Notes
An automorphism of a graph is a permutation \(\pi\) of its vertices that maps the graph onto itself, i.e. such that, for every pair of vertices \(u\) and \(v\), the edges from \(\pi(u)\) to \(\pi(v)\) are as many as those from \(u\) to \(v\) (following the edge directions, for directed graphs), and that preserves the labels: \(\pi(v)\) has the same label as \(v\), and the multiset of the labels of the edges from \(\pi(u)\) to \(\pi(v)\) is that of the edges from \(u\) to \(v\). The automorphisms form a group under composition, whose orbits are the sets of vertices that are mapped onto one another. The group is described by a set of generators, i.e. automorphisms whose compositions yield every automorphism, and by its order, the number of automorphisms.
Graphs with edge labels, parallel edges, or self-loops are reduced to vertex-colored simple graphs with the same automorphisms: self-loops are absorbed into the colors of their vertices, parallel edges are merged into a single edge labeled by the multiset of their labels, and the edges with a label other than the most frequent one are subdivided by an auxiliary vertex of a distinct color.
Every generator is a property map with an entry for each vertex, so that the memory needed is \(O(V)\) per generator, which may be large for networks with many generators.
Two graphs are isomorphic if and only if they become identical, including their vertex and edge labels, after their vertices are relabeled according to their canonical labelings. The canonical labeling depends on the algorithm and its version, and hence can only be compared between results of the same function and version of graph-tool.
The automorphisms are found with the sparse version of the nauty algorithm or with the Traces algorithm of McKay and Piperno [mckay-practical-2014], both from the nauty library [nauty], of which graph-tool includes a copy compiled with thread-local storage, so that concurrent calls are possible. Directed graphs are passed to the library as undirected graphs with three copies of every vertex, since the search of nauty for directed graphs is very slow. The group is returned as a set of at most \(V-1\) generators.
The two algorithms explore the same search tree in different ways: nauty goes depth-first, whereas Traces goes breadth-first, compares the sequences of cell splits of the refinements to discard nodes early, and keeps track of the group found so far to prune equivalent nodes. The running time of both is exponential in the worst case, and neither is always faster than the other, or than
bliss_automorphism_group().Traces gives the order of the group only as a floating-point number, so the exact order is computed from the generators. The group is first split into the direct product of the groups generated on disjoint sets of vertices, and the order of each of these is found with the randomized Schreier-Sims algorithm [seress-permutation-2003], as a product of orbit sizes. The result is a lower bound on the order, each of whose factors is at most \(V\), so that a bound that is not exact falls short by a fraction of at least \(1/V\); the algorithm continues until the bound agrees with the estimate of Traces to within \(1/(2V)\), at which point it is exact.
References
[mckay-practical-2014]Brendan D. McKay and Adolfo Piperno, “Practical graph isomorphism, II”, Journal of Symbolic Computation 60, 94-112 (2014), DOI: 10.1016/j.jsc.2013.09.003 [sci-hub, @tor], arXiv: 1301.1493
[seress-permutation-2003]Ákos Seress, “Permutation group algorithms”, Cambridge University Press (2003), DOI: 10.1017/CBO9780511546549 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> gens, order = gt.nauty_automorphism_group(g) >>> print(order) 480 >>> gens, order = gt.nauty_automorphism_group(g, traces=True) >>> print(order) 480