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.
Graph invariant 2026-11-05
A graph invariant assigns a value to a graph in a way preserved by graph isomorphism. For an invariant ,The value may be a number, a sequence or another mathematical object whose equality has been specified. Isomorphism preserves adjacency while allowing a relabeling of vertices; a drawing's page coordinates are therefore not a graph invariant.[ref]
Examples include vertex count, edge count, the sorted degree sequence and the number of connected components of a graph. If even one invariant differs, it proves graph non-isomorphism. Equality of an invariant usually supplies only a necessary condition. For example, a six-vertex cycle graph and two disjoint triangles both have six vertices, six edges and six degrees equal to2, but only the cycle is a connected graph. The example in graph non-isomorphism proves the obstruction through connectedness.
The adjacency matrix gives an algebraic way to construct invariants. Relabeling a graph replaces by for a permutation matrix . HenceFor a finite undirected simple graph, the th diagonal entry of counts three-step closed walks from vertex . Every triangle gives two traversal directions and three possible starting vertices, so the number of triangles in a graph isThe six-cycle has no triangles and trace zero; two disjoint triangles have trace12 and triangle count2. This invariant distinguishes them even though their degree sequences agree.
A complete graph invariant would satisfy the reverse implication too: equal values would guarantee graph isomorphism. Being easy to compute and being complete are separate properties. Combining several inexpensive invariants can reject many non-isomorphic pairs, but a surviving pair still requires a justification that the chosen information determines its adjacency structure.