Advanced maths

Graph isomorphism calculator for two adjacency matrices

Decide whether two small undirected graphs have the same adjacency structure after relabeling, or count every automorphism of one graph.

Your numbers

One row per line, entries separated by commas or spaces. Use a symmetric square 0/1 matrix with zero diagonal; order 1–9.
One row per line, entries separated by commas or spaces. Use a symmetric square 0/1 matrix with zero diagonal; order 1–9.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Graph isomorphism asks whether two adjacency tables describe the same simple undirected graph after changing vertex names. The calculator searches degree-compatible bijections, pruning any partial mapping that contradicts an already mapped adjacency or nonadjacency. A successful mapping is checked against every matrix entry. Compare mode stops after one complete witness; a No result requires exhaustion of the supported search. Self-map mode sets the second graph equal to the first and counts every automorphism, including the identity.

THE FORMULAFind a bijection π with A[i,j]=B[π(i),π(j)] for every i,j; automorphisms use B=A and count all such π.

A worked example

The first matrix describes path 1–2–3. The second describes edges 1–3 and 2–3. A valid mapping sends first-graph vertices (1,2,3) to second-graph vertices (1,3,2). The middle vertex changes from label two to label three, but the path structure is unchanged. For a triangle, every permutation of its three vertices preserves adjacency, so self-map mode counts 3!=6 automorphisms. A three-vertex path has only two: the identity and the exchange of its endpoints.

Good to know

Symmetric zero-diagonal 0/1 matrices of order 1–9, interpreted as unweighted simple undirected graphs. Matrices of different order are nonisomorphic. Vertex text labels, geometry, edge weights, colors and directions are not compared. Degree compatibility is only a pruning rule, not a proof of equivalence. A hard cap of one million search states produces an explicit resource error rather than an incomplete count or false No. Self-map mode ignores the second matrix and counts exact vertex permutations.

Matching degrees narrows the search but cannot finish it

Any isomorphism sends a vertex to one with the same degree, so incompatible degree choices can be discarded immediately. The search then compares edges and missing edges among already assigned vertices. Preserving nonadjacency matters as much as preserving adjacency: a bijection between two fixed vertex sets must reproduce the entire matrix, not merely find a few attractive correspondences in the drawing.

Two disjoint triangles and a six-vertex cycle each have six vertices, six edges and degree two at every vertex. They are nevertheless nonisomorphic: one graph has two components, while the other is connected. More subtle examples can share connectivity and degree summaries as well. The displayed row-by-row permutation is therefore the positive certificate; on failure, exhaustive search rather than equal summary statistics establishes the supported negative decision.

Renaming the middle vertex turns one labeled three-vertex path into the other123123First graphSecond graphMapping: 1→1, 2→3, 3→2
Left edges 1–2 and 2–3 map to right edges 1–3 and 3–2 under π(1)=1,π(2)=3,π(3)=2. Both adjacency and nonadjacency are preserved; the positions of the drawn nodes are irrelevant.

The Graphical degree sequence calculator with Havel–Hakimi steps constructs a graph from degrees. Equal degrees alone do not prove that two supplied graphs are isomorphic.

One witness and a count of all witnesses are different outputs

Compare mode returns one satisfactory permutation as soon as it is found. The search-state count describes computational work, not how many isomorphisms exist. Self-map mode instead continues through every compatible permutation, because stopping at the first identity would always report one and miss graph symmetries. The interface changes the requested task explicitly and hides the unused second matrix in this mode.

An automorphism can exchange vertices only when every adjacency remains unchanged. The center of a star is fixed while its leaves can be permuted; a graph with all vertices isolated admits every permutation. These are symmetries of a labeled representation considered up to adjacency-preserving renaming, not geometric rotations of a particular picture. The bounded order keeps exact enumeration practical. A larger unsupported graph should produce a size error rather than a heuristic equality claim based on a hash or rounded spectral values.

A few questions, answered

Do equal eigenvalues prove that graphs are isomorphic?

No. Nonisomorphic graphs can share the same adjacency spectrum. This page verifies a complete adjacency-preserving permutation rather than treating a spectral summary as proof.

Why does self-map mode include the identity?

An automorphism is any adjacency-preserving permutation from a graph to itself. Leaving every vertex fixed always satisfies that definition and is counted once.

Find your calculator

Start typing to explore the library.