Graph Isomorphism
When are two drawings of a graph "the same graph"? A hexagon drawn as a regular polygon and a hexagon drawn as a tangled star look nothing alike. Yet they encode identical connection data. Graph isomorphism is the precise notion of sameness that ignores labels, positions, and drawing style. It keeps only who-is-adjacent-to-whom. This matters because in applications — molecules, circuits, social networks, databases — the labels attached to vertices are often arbitrary. The real question is always structural: does this chemical skeleton match that one? Does this network contain that motif? Are these two encodings of a puzzle really the same puzzle? The subject sits at a curious crossroads. Deciding whether two graphs are isomorphic is easy to state. It is computationally mysterious in general — one of the few natural problems not known to be in P nor proven NP-complete. Yet it is routinely easy in practice using invariants — quantities that isomorphic graphs must share. This article builds the formal definition. It proves the basic structural theorem that isomorphism is an equivalence relation compatible with the invariants. It works through two genuinely different, non-symmetric example pairs. It shows exactly where naive invariant-checking can be fooled. The bigger picture: isomorphism is the graph-theoretic instance of a much broader idea. That idea is recognizing when two mathematical objects, though built from different raw materials, have identical relational structure. The same instinct produces isomorphism of groups, of vector spaces, of posets. Graphs are an unusually visual and combinatorially rich setting to master this idea. This is because invariants (degree sequences, cycle structure, spectra) are concrete and computable. It is also because the automorphism group of a graph — its self-isomorphisms — measures internal symmetry directly. By the end you will have a rigorous definition of graph isomorphism. You will have a proven theorem describing its basic algebraic behavior and its interaction with invariants. You will see worked examples showing both a successful isomorphism construction and a failed one exposed by an invariant. You will gain a clear sense of why this deceptively simple-looking equivalence relation still resists a complete computational understanding. This sets up the spectral viewpoint developed in Introduction to Spectral Graph Theory.
- Two graphs are isomorphic if there is a bijection between their vertex sets that preserves adjacency exactly.
- Isomorphism is an equivalence relation on graphs, so "isomorphism classes" partition all graphs into structural types.
- Any quantity preserved by every isomorphism (degree sequence, number of edges, number of triangles, connectivity, spectrum) is an invariant; mismatched invariants prove non-isomorphism instantly.
- Invariants alone can never prove isomorphism — matching invariants are necessary but not sufficient, as the counterexample below shows.
- The self-isomorphisms of a single graph form its automorphism group, a subgroup of the symmetric group on its vertices, measuring internal symmetry.
- No polynomial-time algorithm for general graph isomorphism is known, and none is known to be impossible; it is a rare "in-between" problem.
- Key idea: isomorphism forgets labels and keeps only the adjacency relation, so two graphs are the same exactly when some relabeling makes their edge sets literally equal.
Where this lives today
Chemistry and cheminformatics. Molecules are modeled as graphs (atoms as vertices, bonds as edges); checking whether two molecular graphs are isomorphic decides whether two different-looking structural diagrams represent the same compound, and isomorphism-based subgraph matching underlies database searches for substructures (e.g., "does this molecule contain a benzene ring").
Circuit design and VLSI verification. Two logic circuit netlists that are isomorphic as graphs implement equivalent wiring regardless of physical layout; automated equivalence checking tools rely on fast graph isomorphism (and subgraph isomorphism) heuristics to verify that a redesigned chip layout matches its specification.
Cryptography. Some proposed public-key and zero-knowledge protocols use the presumed computational difficulty of graph isomorphism (or related problems) as a hardness assumption, since no efficient general algorithm is known despite decades of effort, distinguishing it from problems already known to be easy or from NP-complete problems believed intractable.
Chemistry-adjacent and network science. Automorphism groups measure symmetry in molecular graphs (predicting spectroscopic degeneracies) and in complex networks (identifying structurally equivalent nodes, useful for role discovery in social or biological networks).
Computer vision and pattern matching. Scene graphs or shape skeletons are compared via (sub)graph isomorphism to recognize objects regardless of position or orientation, echoing the "same shape, different labels" intuition at the heart of the definition.
Theoretical computer science. Graph Isomorphism is a centerpiece example in complexity theory of a natural problem whose exact classification (P, NP-complete, or strictly in between) remains unresolved, motivating deep structural and algorithmic techniques, and connecting directly to the eigenvalue-based invariants developed in Introduction to Spectral Graph Theory.
Ask the tutor: Can you show me why checking the eigenvalues of the adjacency matrix is a stronger invariant than the degree sequence, but still not a perfect test for isomorphism?
Let and be simple graphs (no loops, no multiple edges, no orientation). A function
is a graph isomorphism from to if: 1. is a bijection (injective and surjective) from to ; and 2. preserves adjacency in both directions: for all ,
Graphs and are isomorphic, written , if an isomorphism between them exists. If as abstract graphs (so ), is called an automorphism of ; the set of all automorphisms of , under function composition, is the automorphism group . A graph invariant is a function on graphs such that implies .
Intuition
Think of a graph as a physical structure: vertices are joints, edges are rigid rods connecting them. Isomorphism asks whether two such structures, perhaps built from rods of different colors and joints with different names, could be assembled into the exact same shape if you were allowed to relabel the joints however you like — but not allowed to add, remove, or reroute a single rod. The relabeling is the bijection ; the "same shape" condition is exactly that adjacency is preserved both ways. The two-directional condition in the definition is doing real work. It is not enough for to send edges to edges; it must also send non-edges to non-edges. A map that collapses a sparse graph's non-adjacencies into a denser graph's adjacencies would satisfy only "half" the condition and is not an isomorphism. This is why isomorphism is far more rigid than a mere edge-preserving map (a graph homomorphism); isomorphism requires the bijection to be a perfect two-way dictionary between adjacency patterns.
Central theorem
Let denote the class of all (finite, simple) graphs. Then:
(a) The relation is an equivalence relation on : it is reflexive, symmetric, and transitive.
(b) If via isomorphism , then for every ,
and consequently and have the same degree sequence (the multiset of vertex degrees, listed in non-increasing order), the same number of vertices, and the same number of edges.
(c) More generally, if is any function on graphs defined purely in terms of the adjacency relation — that is, depends only on the isomorphism type of — then is a graph invariant: .
We prove each part in turn, using only the definition of isomorphism and the Graphs and Basic Definitions together with Degree and the Handshake Lemma for the degree statement.
(a) Equivalence relation. We check the three defining properties directly from the definition of isomorphism. Reflexivity. For any graph , the identity map is a bijection, and trivially since and . Hence is an isomorphism from to itself, so . Symmetry. Suppose via isomorphism . Since is a bijection, it has a two-sided inverse , which is also a bijection (this is a standard fact about bijections between finite sets: a bijection has a unique inverse function, and that inverse is itself a bijection). We claim is an isomorphism from to . Let ; write , for the unique , . Then
where the middle equivalence is exactly the defining property of as an isomorphism (applied in the direction ). This chain shows preserves adjacency both ways, so . Transitivity. Suppose via and via . Composition of bijections is a bijection (a standard fact: if is injective/surjective and is injective/surjective then is injective/surjective, by direct verification of the definitions), so is a bijection. For :
using the isomorphism property of for the first equivalence and of for the second. Hence , so is an isomorphism , giving . Reflexivity, symmetry, and transitivity together establish that is an equivalence relation on .
(b) Degree preservation. Let be an isomorphism and fix . By definition,
Consider the map restricted to the neighborhood . Because is injective, this restriction is injective, so it is a bijection from onto its image . We claim , the neighborhood of in . () If then , so by the isomorphism property , i.e. . () Let , so . Since is surjective, for some . Then , and by the isomorphism property (the direction) , so and . Thus restricts to a bijection , giving
Since is a bijection on the full vertex sets, the multiset equals the multiset (re-indexing the sum/multiset over the bijection ). Sorting both multisets into non-increasing order produces identical sequences, so and have the same degree sequence. Since is a bijection , . For the edge count, apply the Degree and the Handshake Lemma (Handshake Lemma) to both graphs:
where the middle equality re-sums over the bijection exactly as above. Hence .
(c) General invariants. Suppose is a function on graphs whose value is determined entirely by the isomorphism type of , meaning: is defined as some property or count of the abstract relational structure that does not reference vertex labels — for instance "the number of -vertex subsets inducing a complete subgraph," "the length of a longest path," "whether the graph is connected," or "the number of spanning trees." Formally, this means is built from operations that commute with relabeling: if is any bijection carrying to (i.e. any isomorphism), then applying to every set/structure entering the definition of produces exactly the corresponding structure for , since is by hypothesis a bijection on vertices respecting adjacency in both directions (parts of the argument in (b) generalize verbatim: any adjacency-defined substructure of , such as a triangle, a path, a cycle, a clique, or a spanning subgraph, is carried by to the corresponding substructure of , because membership in transports exactly to membership in ). Hence counting or existence statements about such substructures are unchanged. Therefore whenever , i.e. is a graph invariant.
∎Worked examples
Example 1: Constructing an explicit isomorphism (asymmetric labeling). Let have vertex set and edges
So is a 5-cycle ––––– with one extra chord . Let have vertex set and edges
So is the 5-cycle ––––– with chord .
Degree check first. In : (neighbors ), (neighbors ), and . Degree sequence: . In : (neighbors ), (neighbors ), and . Degree sequence: . They match — necessary, not yet sufficient.
Finding . In , the two degree-3 vertices are adjacent (chord ). In , the two degree-3 vertices are adjacent (chord ) — consistent, since by the theorem an isomorphism must send the chord's endpoints to the chord's endpoints. Try , . The cycle order in is ; in it is . Sending and going around the cycle in matching direction, (between the short way on the cycle) should go to (between ). Set:
Verification, edge by edge. We must check all edges of map to edges of , and (since forces already, and is a bijection between two 6-element edge sets once we confirm the forward containment, equality follows by a counting argument given below) confirm no non-edge is sent to an edge.
- . ✓
- . ✓
- . ✓
- . ✓
- . ✓
- . ✓
All six images are exactly the six edges of , with no repeats (since is a bijection on vertices, distinct edges of map to distinct edges of : if as edges of then , because injective forces whenever the images coincide). So maps bijectively onto ; in particular every edge of maps to an edge of , and since , the image , having elements all inside the -element set , must equal exactly — there is no room for a non-edge of to sneak an image into beyond what is already accounted for, and conversely every edge of is hit. Concretely, checking non-edges: and indeed ; and ; and ; and . All four non-edges of (there are ) map to non-edges of . Hence is a graph isomorphism, and .
Example 2: Two graphs on vertices, same size, decided by structure beyond degree. Let be the graph with and edges forming two disjoint triangles:
Let have and edges forming a -cycle:
Invariant check. Both graphs have vertices and edges. Degree sequence of : every vertex has degree (each vertex in a triangle is adjacent to the other two), so . Degree sequence of : every vertex in a cycle has degree , so also . Vertex count, edge count, and degree sequence all agree — invariants so far give no obstruction.
A finer invariant: connectivity. By part (c) of the theorem, "is the graph connected" is an isomorphism invariant, since connectivity is defined purely via existence of adjacency-paths, a notion transported faithfully by any adjacency-preserving bijection. is connected: from any vertex one can walk around the single -cycle to reach any other. is disconnected: there is no path from vertex to vertex , since every edge of lies entirely inside or entirely inside , so no sequence of edges can cross between the two triangles. Since connectedness is an invariant (Theorem, part (c)) and is disconnected while is connected, we conclude
even though , , and both degree sequences equal . This shows degree sequence alone is not a complete invariant, foreshadowing the counterexample below and the need for finer invariants such as those studied via eigenvalues in Introduction to Spectral Graph Theory.
The theorem proves that isomorphic graphs must share every invariant, including degree sequence. It does not claim the converse — that graphs sharing an invariant, or even all of a long list of invariants, must be isomorphic. Dropping the hypothesis " is a bijection preserving adjacency in both directions" down to merely "same degree sequence" breaks the conclusion entirely. Here is an explicit pair. Let be two disjoint copies of the path on three vertices : vertices with edges
Degrees: , giving sorted sequence . Let be a single path on six vertices, with edges
Wait — this has only edges while has ; to keep edge count matching we instead take to be a -cycle broken differently: let have edges
Concretely , a path with an extra chord . This has edges, not , so instead compare (4 edges) against a graph with the same edge count and degree sequence but different shape: Let have vertices and edges
a single -cycle ----, together with two isolated vertices . Degrees: , . Sorted degree sequence: — this does not match 's , so this pair is not the right counterexample either; let us fix the construction cleanly.
Correct minimal counterexample. Take
Explicitly , (a path on vertices ) with vertex isolated. Degrees: . Sorted: — still not matching . To match exactly with a connected graph on vertices and edges is impossible (a connected graph on vertices needs at least edges), so the cleanest true counterexample compares against pieces — but alone already has degree sequence so (a -path plus a disjoint single edge) on vertices has degrees : exactly the same sorted degree sequence as , and the same number of edges, . So the genuine counterexample is:
both with vertices, edges, and identical degree sequence . These are not isomorphic: 's largest connected piece has vertices, while has a connected piece () with vertices. "Size of the largest connected component" is an isomorphism invariant (an instance of Theorem part (c), since connected components and their sizes are determined purely by the adjacency relation), and it takes the value on but on . Hence , despite agreeing on vertex count, edge count, and full degree sequence. This shows precisely what fails if one tries to define isomorphism as "same degree sequence" instead of "adjacency-preserving bijection exists": the weaker condition is satisfiable by structurally different graphs, so it cannot serve as a correct definition or a sufficient test.
Scope, edge cases & common traps
| Situation | What holds |
|---|---|
| isomorphic | Same , , degree sequence, connectivity, number of triangles/cycles of each length, spectrum, chromatic number, and every other invariant |
| Same degree sequence only | Not sufficient for isomorphism (see counterexample) |
| Same number of vertices and edges only | Not sufficient; weaker than degree sequence match |
| but graphs have loops or multi-edges | Definition given here is for simple graphs; multigraphs/loops need adjacency multiplicities preserved too |
| Directed graphs | Isomorphism must preserve arc direction: , a strictly stronger condition than for undirected graphs |
| Checking isomorphism by brute force | Always sound but costs up to bijections to try; invariants are used to prune, not to decide, in general |
| trivial (only the identity) | Graph is called rigid; happens for "generic" graphs with no repeated local structure |
The mathematician behind it
Origins · 1 minEugene M. Luks and how this was discovered
Luks is best known for a landmark 1982 result showing that graph isomorphism can be decided in polynomial time when the input graphs have bounded vertex degree — a striking positive result in a landscape otherwise dominated by uncertainty. His techniques, combining group-theoretic methods (analyzing the automorphism group's structure via composition series) with combinatorial partitioning, became foundational for later attacks on the general graph isomorphism problem, including László Babai's quasipolynomial-time algorithm decades later. The bounded-degree case captures a large fraction of graphs arising in chemistry and network science, where practical instances rarely have huge-degree vertices.
Is graph isomorphism the same as graph equality?
No. Graph equality would require and as literal sets — same vertex names, same edge set. Isomorphism is weaker and more useful: it only asks whether some relabeling (bijection ) turns into exactly. Two graphs drawn with completely different vertex names, and even different physical layouts, can be isomorphic. Equality is a special case of isomorphism (via the identity map), but isomorphism captures the "structurally identical" idea that mathematicians actually care about, since vertex labels are usually arbitrary bookkeeping rather than meaningful data.
Why isn't matching degree sequences enough to prove isomorphism?
Degree sequence only records local information — how many neighbors each vertex has — and discards how those neighborhoods connect to each other globally. Two graphs can have every vertex touching the same number of edges while being wired into completely different global shapes, such as one graph forming two separate triangles and another forming a single hexagonal cycle, both with degree sequence . The counterexample in this article makes this failure completely explicit with a connectedness argument, which is itself a valid invariant that degree sequence does not capture.
Is deciding graph isomorphism computationally hard?
It is unresolved. Graph Isomorphism is known to be in NP (a candidate bijection can be checked in polynomial time), but it has never been proven NP-complete, and no general polynomial-time algorithm is known either. László Babai's 2015–2017 algorithm runs in quasipolynomial time, faster than any previously known general method, but still not proven polynomial. For special cases — bounded degree, planar graphs, trees — polynomial or even linear-time algorithms are known and well understood.
What is the difference between isomorphism and homomorphism?
A graph homomorphism only requires that edges map to edges: , with no requirement of bijectivity and no requirement that non-edges map to non-edges. Isomorphism is strictly stronger: it demands a bijection and the full "if and only if" adjacency-preservation in both directions. Every isomorphism is a homomorphism (and its inverse is too), but a homomorphism need not be injective, surjective, or reversible, so it can collapse structure that isomorphism must preserve exactly.
What does the automorphism group tell you about a graph?
collects every way of relabeling 's own vertices that leaves the adjacency relation unchanged, forming a group under composition (identity, inverses, and closure all follow from the equivalence-relation proof given above applied to self-isomorphisms). A large automorphism group signals rich internal symmetry — the complete graph has equal to the full symmetric group , since every permutation preserves "all pairs adjacent." A trivial automorphism group (only the identity) means the graph is rigid, with no nontrivial self-symmetry, which is typical of "generic" random graphs.
Can two graphs with different numbers of vertices be isomorphic?
No. Part of the definition of isomorphism requires a bijection , and a bijection between finite sets can only exist if the sets have the same cardinality. So is an immediate, absolute prerequisite for ; checking vertex counts is always the very first, cheapest invariant test before attempting anything more elaborate.
How does isomorphism connect to spectral graph theory?
The adjacency matrix's eigenvalues (its spectrum) form a graph invariant: relabeling vertices via a permutation matrix conjugates the adjacency matrix as , and conjugate matrices share the same eigenvalues, so isomorphic graphs have identical spectra. This gives a powerful, easily computed invariant beyond degree sequences, though — mirroring the moral of this article's counterexample — non-isomorphic graphs can occasionally share a spectrum too (so-called cospectral mates), a subtlety explored further in Introduction to Spectral Graph Theory.