Canonical graph labeling 2026-11-05
Canonical graph labeling computes a standardized labeled representative of a graph, with a fixed convention that assigns identical representatives exactly to isomorphic graphs. For finite graphs, a labeling is a bijection from the original vertices to a standard set such as . A canonicalization procedure chooses a representative adjacency structure, not simply the order in which vertices happened to be supplied.
One explicit convention labels a finite undirected simple graph in every possible way and chooses the lexicographically least upper-triangular adjacency matrix string. The article complete graph invariant proves that this representative, together with vertex count, determines the graph up to graph isomorphism. Efficient software seeks the same kind of isomorphism-invariant representative without literally enumerating every permutation. The authors' nauty and Traces project identifies canonical labeling and graph-automorphism computation as supported tasks.[ref]
nauty and Traces by Brendan McKay and Adolfo Piperno. project overview and Documentation
An original three-vertex path makes a subtle distinction visible. In the edge-string order , the least string is . It puts the central vertex at label3 and the two leaves at labels1and2. Either assignment of the two original leaves gives the same canonical adjacency matrix. The representative is fixed, while the map from original vertices to labels need not be unique.
This ambiguity is forced by graph automorphisms. If an automorphism exchanges two indistinguishable vertices, no injective vertex-naming rule can both remain unchanged by that exchange and give the two vertices different names. More formally, requiring for every automorphism forces whenever is injective. A graph with a nontrivial automorphism therefore cannot have fully symmetry-invariant distinct names for all original vertices.
Canonical graph labeling instead requires the resulting labeled graph to be invariant under relabeling of the input. A returned vertex permutation may select one among equivalent choices. For a triangle, all six labelings give the same adjacency matrix, while six different input-to-label maps remain possible.
Vertex colors, directed edges or other attributes must be included in the structure if the desired isomorphisms are to preserve them. Comparing outputs from different canonicalization conventions or program options also needs care: identical invariance goals do not require every implementation to choose the same representative.
Complete graph invariant 2026-11-05
A complete graph invariant is a graph invariant whose value determines a graph up to graph isomorphism. For graphs in a specified class, completeness meansAn ordinary invariant only requires the forward preservation statement . Completeness adds the converse: equal values must exclude graph non-isomorphism.
A direct construction proves that complete invariants exist for finite undirected simple graphs. For an -vertex graph, label its vertices and list the entries above the diagonal of its adjacency matrix in the fixed order . This gives a binary string. Repeat for every labeling and choose the least string in lexicographic order. Define to be the pair consisting of and this least string. Including distinguishes graphs whose edge string is empty but whose vertex counts differ.
Relabeling a graph permutes the same collection of candidate strings, so isomorphic graphs have the same minimum. Conversely, if two minima and vertex counts agree, some labeling of each graph gives exactly the same adjacency entries. Matching vertices with those labels is an isomorphism. This proves both directions, without assuming that the construction is computationally fast.
For an original three-vertex example, a path's possible strings are , and in the order . Its invariant is . A triangle instead gives . The difference certifies non-isomorphism. For larger graphs the naive construction may examine labelings, so mathematical completeness alone supplies no practical speed guarantee.
Canonical graph labeling produces a standardized labeled representative and is closely connected to this construction. The authors of nauty and Traces identify canonical-label production as one of their programs' tasks.[ref]
nauty and Traces by Brendan McKay and Adolfo Piperno. project overview and Documentation
A particular program's chosen representative need not be the lexicographically least string used in this illustrative definition; comparisons must use the same canonization convention.Vertex count, edge count and degree sequence are useful inexpensive invariants but are not complete. The example in graph non-isomorphism gives equal values for all three while connectedness differs. Completeness concerns the information retained, separately from the effort required to compute it.
nauty 2026-11-05
nauty is software for computing graph automorphisms and canonical graph labeling, originally developed by Brendan McKay. It is distributed with Traces graph isomorphism software and auxiliary graph-generation and manipulation tools.[ref]
nauty and Traces by Brendan McKay and Adolfo Piperno. Summary; Documentation; original and current algorithm references
An automorphism result describes relabelings that preserve adjacency. For an original example, the graph with6vertices and no edges permits every vertex permutation, so its automorphism group is the symmetric group of orderA compact generator description can use a transposition and a cycle . Conjugating the transposition by powers of the cycle produces adjacent transpositions, which generate the whole symmetric group. These are illustrative generators, not a claim about the exact generator list returned by a particular run.
A canonical result serves another purpose. If denotes the chosen canonical graph encoding, correctness requiresRenaming vertices changes the input representation but must not change that chosen result. This permits duplicate elimination when generating graphs and comparison of structures supplied with unrelated labels.
nauty combines structural refinement with a search over unresolved choices, exploiting discovered graph automorphisms to reduce equivalent work. Its theoretical framework and relationship to Traces are described in the authors' joint paper.[ref]
Practical graph isomorphism, II by Brendan D. McKay and Adolfo Piperno. Introduction and individualization/refinement framework
A generating set for symmetries and a canonical encoding are different outputs. The first describes equivalences within a graph; the second makes equivalence between independently labeled graphs directly testable.