bliss_automorphism_group#
- graph_tool.structure.bliss_automorphism_group(g, vertex_label=None, edge_label=None, orbits=False, canonical=False)[git][source]#
Obtain the automorphism group of the graph with the bliss algorithm.
- 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.
- 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
nauty_automorphism_groupAutomorphism group with nauty or Traces
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 search algorithm of Junttila and Kaski implemented by the bliss library [junttila-bliss-2007] [junttila-bliss-2011], a copy of which is included in graph-tool. The group is returned as a set of at most \(V-1\) generators. The running time is typically almost linear in the size of the graph for sparse networks, but is exponential in the worst case.
References
[junttila-bliss-2007]Tommi Junttila and Petteri Kaski, “Engineering an efficient canonical labeling tool for large and sparse graphs”, Proceedings of the Ninth Workshop on Algorithm Engineering and Experiments (ALENEX), 135-149 (2007), DOI: 10.1137/1.9781611972870.13 [sci-hub, @tor]
[junttila-bliss-2011]Tommi Junttila and Petteri Kaski, “Conflict propagation and component recursion for canonical labeling”, Theory and Practice of Algorithms in (Computer) Systems (TAPAS), 151-162 (2011), DOI: 10.1007/978-3-642-19754-3_16 [sci-hub, @tor]
Examples
The Petersen graph has 120 automorphisms, and all its vertices are equivalent:
>>> g = gt.collection.petersen_graph() >>> gens, order, orbit = gt.bliss_automorphism_group(g, orbits=True) >>> print(order, len(set(orbit.a))) 120 1
Two graphs can be tested for isomorphism by comparing their canonically relabeled edges:
>>> def canonical_edges(g): ... gens, order, c = gt.bliss_automorphism_group(g, canonical=True) ... es = c.a[g.get_edges()] ... es.sort(axis=1) ... return set(map(tuple, es)) >>> g = gt.collection.data["karate"] >>> u = gt.Graph(g, vorder=g.new_vp("int", vals=np.random.permutation(g.num_vertices()))) >>> canonical_edges(g) == canonical_edges(u) True