Discrete MathematicsGraphs, Paths and Circuits3 of 6
Graphs, Paths and Circuits · 3
Graph Isomorphism: When Two Drawings Are the Same Graph
Two people can draw the same network of connections in completely different ways, so we need a reliable way to tell when two drawings are really the same graph in disguise.
1
Same Graph, Different Drawing
In geometry, a square with crossing diagonals and a triangle with a dot in the center are different shapes, and a pentagon is different from a five-pointed star. In graph theory, however, a graph only records which vertices are connected to which. When two drawings have the exact same network of connections underneath, we say the graphs are isomorphic.
Same Graph, Different Drawing
No matter where the vertices sit on the page or whether the edges cross each other, the list of connected vertex pairs stays the same.
Moving the vertices changes edge lengths, crossings, and which vertex sits inside, while the connected vertex pairs never change.
2
Finding an Isomorphism by Matching Vertices
Untangling edges in your head works for four or five vertices, but for larger or more tangled graphs we need a method that works on paper. An isomorphism is a one-to-one matching (a bijection) between the vertices of two graphs so that two vertices are connected in the first graph if and only if their matched vertices are connected in the second.
Let's prove that these two 5-vertex graphs are isomorphic by finding the vertex matching between A,B,C,D,E and 1,2,3,4,5.
Finding an Isomorphism by Matching Vertices
Text solution
Match vertices with unique degreesCounting the edges at each vertex shows that only C and 2 have degree 3, and only E and 5 have degree 1, which locks in those two pairs right away.
Break ties using neighbor degreesAmong the three degree-2 vertices on the left (A,B,D), only D connects to the degree-1 vertex E, and among the degree-2 vertices on the right (1,3,4), only 1 connects to the degree-1 vertex 5.
D is adjacent to E (degree 1)and1 is adjacent to 5 (degree 1)⟹D=1
Match the remaining symmetric vertices and check all edgesThe last two vertices on each side (A,B and 3,4) connect to each other and to the degree-3 vertex (C=2), so matching A=3 and B=4 (or the reverse) maps all 5 edges of the left graph onto the 5 edges of the right graph with no extra edges left over.
A=3,B=4,C=2,D=1,E=5
A-BB-CD-E→3-4,→4-2,→1-5A-CC-D→3-2,→2-1,
So the two drawings are isomorphic, with two valid matchings depending on whether A and B map to 3 and 4 or to 4 and 3.
3
Isomorphism in Adjacency Matrices
When graphs are stored in a computer, we aren't given a drawing at all, just an edge list or an adjacency matrix. We want to see how to find an isomorphism directly from two adjacency matrices, and what relabeling the vertices does to the matrix itself.
Let's check whether these two 4×4 adjacency matrices describe the same graph:
Sum each row to find the vertex degreesAdding the 1s across each row gives the degree of each vertex, and since the degrees in both graphs sum to 6, the handshake lemma tells us both graphs have 26=3 edges.
Match a degree-1 vertex and follow the 1 in its rowMatching the degree-1 vertices as A=1 and D=2, the single 1 in Row A sits in Column B while the single 1 in Row 1 sits in Column 3, which forces B=3 and leaves C=4.
⟹⟹A=1,D=2Row A has 1 at B,Row 1 has 1 at 3B=3,C=4
Reorder both the rows and the columns in the matching orderListing Graph 2's vertices in the order 1,3,4,2 (to match A,B,C,D) along both the rows and the columns makes Graph 2's matrix identical to Graph 1's matrix in every entry.
Because each vertex labels both a row and a column, moving a vertex in the ordering shifts its row and its matching column together while keeping its row sum unchanged. When the vertex order matches Graph 1, the two grids of 0s and 1s line up in every entry.
Reordering the vertices slides each row and column together, moving the 1s around without changing any connections until a matching order makes the two matrices identical.
4
Proving Graphs Are Not Isomorphic Using Invariants
What if you try to match the vertices of two graphs and nothing works? Saying "I couldn't find a matching" is not a proof, because you might simply have missed one among hundreds of possibilities. To prove two graphs are not isomorphic, we point to a graph invariant (a structural property that cannot change when vertices are moved or relabeled) that one graph has and the other does not.
Now let's test two pairs of graphs that have the exact same number of vertices, number of edges, and degree sequence, and see how other invariants tell them apart.
Proving Graphs Are Not Isomorphic Using Invariants
same number of vertices,
same number of edges,
same degree sequence:
isomorphic?
Text solution
Check vertex counts, edge counts, and sorted degree sequences firstIn the 5-vertex pair, both graphs have 5 vertices, 6 edges, and the same sorted degree sequence, so the basic counts pass.
Compare neighbor degrees and closed loops on the 5-vertex pairIn the left house graph, the two degree-3 vertices are connected directly to each other and, together with the top of the roof, form a triangle (3-step closed loop), whereas in the right graph the two degree-3 vertices do not share an edge and the shortest closed loop takes 4 steps, proving they are not isomorphic.
Left 5-vertex graph:degree-3 vertices sharean edge (1 triangle)Right 5-vertex graph:degree-3 vertices do notshare an edge (0 triangles)
Count triangles when all degrees and neighbor degrees match on the 6-vertex pairIn the 6-vertex pair, every vertex in both graphs has degree 3 and connects to three degree-3 neighbors, but the left graph contains 2 triangles while every closed loop in the right graph takes at least 4 steps, so they are not isomorphic.
On a test, pointing out a single invariant that differs, such as one graph having a triangle while the other has none, or one graph being broken into two pieces while the other is connected in one piece, is a complete proof that they are not isomorphic. Just remember that invariants only work in one direction: if all your invariant checks match, you still have to write down the vertex bijection to prove the graphs are isomorphic.
5
Counting Graphs on Four Vertices Up to Isomorphism
Invariants also let us count how many genuinely different graphs exist on a given number of vertices without missing any or counting the same graph twice in disguise. Counting graphs up to isomorphism means grouping all isomorphic drawings together and counting each distinct structure only once.
Let's find the total number of simple graphs on 4 vertices up to isomorphism.
Counting Graphs on Four Vertices Up to Isomorphism
Text solution
Sort into buckets by edge count and list 0, 1, and 2 edgesOn 4 vertices, a simple graph has between 0 and 6 edges. There is 1 graph with 0 edges and 1 with 1 edge, while 2 edges either sit separate or share a vertex, giving 2 non-isomorphic graphs with different degree sequences.
Classify 3-edge graphs by maximum degree using the handshake lemmaWith 3 edges, the four degrees sum to 2×3=6, so the maximum degree cannot be 1(1+1+1+1=4<6). A maximum degree of 3 gives a 3-pointed star, and a maximum degree of 2 gives either a triangle with a lone vertex or a 4-vertex chain, producing 3 graphs with distinct degree sequences.
Count 4, 5, and 6 edges using complements in K4 and sum the bucketsChoosing 4,5, or 6 edges to draw on 4 vertices is the same as starting with all 6 edges of the complete graph K4 and choosing 2,1, or 0 edges to erase (taking the complement), which mirrors the first three buckets and brings the total to 11 graphs.
4 edges (2 erased from K4):(2,2,2,2),(3,2,2,1)→2 graphs5 edges (1 erased from K4):(3,3,2,2)→1 graph6 edges (0 erased from K4):(3,3,3,3)→1 graphTotal up to isomorphism:1+1+2+3+2+1+1=11 graphs
Every k-edge graph on 4 vertices is paired with a (6−k)-edge complement formed by the missing edges of K4, and redrawing the same 4-vertex chain as a U, Z, or N keeps its degree sequence and complement structure unchanged.
On four vertices, different drawings with the same connections share a degree sequence, and whichever of the six edges are missing form its complement.
6
The Isomorphism Checklist and Large Graphs
Now let's put the whole method together into one checklist for testing any pair of graphs, and see why comparing massive graphs is one of the famous open problems in computer science.
The Isomorphism Checklist and Large Graphs
Key concepts
When you are asked whether two graphs are isomorphic, always work from the fastest checks to the most detailed ones so you don't waste time trying to match vertices on graphs that are actually different:
Start with counts and the sorted degree sequence
Count the vertices and edges (in an adjacency matrix, add each row to get the vertex degrees and use edges=2sum of degrees), then list the degrees from largest to smallest, such as (3,3,2,1,1). If the vertex count, edge count, or degree sequence differs, stop right there: they are not isomorphic.
When the degree sequences match, check neighbor degrees and loops before guessing a bijection
Look at the neighbors of high-degree vertices (for instance, whether the two degree-3 vertices connect to each other), count triangles(3-step closed loops) versus 4-step loops, and check that both graphs have the same number of connected pieces. A single difference in any of these invariants proves the graphs are not isomorphic.
Switch to the complement when a graph is crowded with edges
If a graph has nearly all possible edges (such as 5 edges on 4 vertices, or 7 edges on 5 vertices where only 3 of the 10 possible edges are missing), compare the complements (the graphs formed by the missing edges) instead of untangling the full drawings.
When every check passes, lock in the bijection and verify the edges
Matching invariants never prove two graphs are isomorphic on their own. Match vertices with unique degrees first (C=2,E=5), use neighbor degrees to break ties among equal-degree vertices (D=1), and check that every edge on the left maps to an edge on the right (A-B→3-4) with the same total number of edges. In an adjacency matrix, reorder both the rows and the columns in that matching order so the two matrices match entry for entry.
7
Practice
1
Graph G has vertices A,B,C,D,E and 6 edges: A-B,A-C,A-D,B-C,C-D, and D-E. Graph H has vertices 1,2,3,4,5 and 6 edges: 1-3,2-3,2-4,2-5,3-5, and 4-5. Find all isomorphisms between G and H, and verify that your matching preserves adjacency.
Find the degree of every vertex in G and H to lock in the unique degrees first; then, among the three degree-3 vertices in each graph, ask which one is connected to the degree-1 vertex.
In G, the vertex degrees are A:3,C:3,D:3,B:2,E:1. In H, the degrees are 2:3,3:3,5:3,4:2,1:1. Matching unique degrees forces E=1 (degree 1) and B=4 (degree 2). Watch out for the common slip of treating all three degree-3 vertices (A,C,D) as interchangeable; for instance, setting D=5 makes D-E→5-1, which is not an edge in H. Among the degree-3 vertices in G, only D is adjacent to the degree-1 vertex E, and among the degree-3 vertices in H, only 3 is adjacent to the degree-1 vertex 1, which forces D=3. The remaining two degree-3 vertices, A and C, both connect to B,D, and each other, so they can match 2 and 5 in either order (don't forget to list both!). Checking the 6 edges of G under the first matching gives A-B→2-4,A-C→2-5,A-D→2-3,B-C→4-5,C-D→5-3, and D-E→3-1, which are the exact 6 edges of H. Thus there are 2 isomorphisms: (A=2,B=4,C=5,D=3,E=1) and (A=5,B=4,C=2,D=3,E=1).
2
Two 4-vertex graphs are given by their adjacency matrices. Graph 1 (vertices A,B,C,D) has rows A:[0111],B:[1010],C:[1100],D:[1000]. Graph 2 (vertices 1,2,3,4) has rows 1:[0011],2:[0010],3:[1101],4:[1010]. Use row sums and neighbors to determine whether the graphs are isomorphic, and if so, give the row-and-column ordering of Graph 2 that makes its matrix identical to Graph 1's matrix.
Add across each row to find the vertex degrees, match the unique degree-3 and degree-1 vertices first, and remember what must move along with the rows when you reorder the matrix.
Summing the rows gives the degrees: in Graph 1, A has degree 3,B and C have degree 2, and D has degree 1; in Graph 2, 3 has degree 3,1 and 4 have degree 2, and 2 has degree 1 (both degree sums are 8, giving 28=4 edges). Matching unique degrees forces A=3 and D=2. The two degree-2 vertices B and C in Graph 1 are adjacent to A and to each other, matching 1 and 4 in Graph 2 in either order (B=1,C=4 or B=4,C=1). Be careful not to reorder only the rows of Graph 2 into (3,1,4,2) while leaving the columns in the original order (1,2,3,4), which leaves the top row as [1101] instead of [0111] and makes it look like the matrices don't match. Yes, the graphs are isomorphic, and reordering both the rows and the columns of Graph 2 into the order (3,1,4,2) or (3,4,1,2) makes its matrix identical to Graph 1's matrix.
3
Graph G has 6 vertices A,B,C,D,E,F and 5 edges: A-B,A-C,A-D,B-E, and C-F. Graph H has 6 vertices 1,2,3,4,5,6 and 5 edges: 1-2,1-4,1-5,2-3, and 3-6. Show that G and H have the same number of vertices, number of edges, and degree sequence, and prove whether or not they are isomorphic.
Don't stop at the matching degree sequence and conclude the graphs are isomorphic, or match the degree-2 vertices B,C to 2,3 without checking that A-C is an edge in G while 1-3 is not an edge in H.
After verifying that the sorted degree sequences match, look at the unique degree-3 vertex in each graph and list the degrees of its three neighbors.
Both graphs have 6 vertices, 5 edges, and the exact same degree sequence (3,2,2,1,1,1) (in G, degrees are A:3,B:2,C:2,D:1,E:1,F:1; in H, degrees are 1:3,2:2,3:2,4:1,5:1,6:1). Don't stop at the matching degree sequence and conclude the graphs are isomorphic, or match the degree-2 vertices B,C to 2,3 without checking that A-C is an edge in G while 1-3 is not an edge in H. In G, the unique degree-3 vertex A is adjacent to two degree-2 vertices (B and C) and one degree-1 vertex (D), whereas in H, the unique degree-3 vertex 1 is adjacent to one degree-2 vertex (2) and two degree-1 vertices (4 and 5). Because A would have to map to 1 and their neighbors do not have matching degrees, G and H are not isomorphic.
4
Graph G has 6 vertices A,B,C,D,E,F and 7 edges: A-B,B-C,C-A,C-D,D-E,E-F, and F-D. Graph H has 6 vertices 1,2,3,4,5,6 and 7 edges: 1-2,2-3,3-4,4-5,5-6,6-1, and 1-4. Verify that both graphs have the same degree sequence and the same neighbor degrees for every vertex, then prove they are not isomorphic.
Since the degree sequences and even the neighbor degrees match everywhere, count how many steps it takes to walk around the shortest closed loop in each graph.
Both G and H are connected in one piece, have 6 vertices and 7 edges, and share the degree sequence (3,3,2,2,2,2)(C and D have degree 3 in G;1 and 4 have degree 3 in H). Even the neighbor degrees match at every vertex: in both graphs, each degree-3 vertex connects to one degree-3 vertex and two degree-2 vertices, and each degree-2 vertex connects to one degree-3 vertex and one degree-2 vertex. Watch out for the trap of assuming that matching neighbor degrees guarantee an isomorphism (trying to match C=1 and its degree-2 neighbors A,B to 2,6 fails because A-B is an edge in G whereas 2-6 is not an edge in H). Graph G has 2 triangles (A-B-C-A and D-E-F-D, closed loops of 3 steps), while Graph H has 0 triangles (its shortest closed loops, 1-2-3-4-1 and 1-6-5-4-1, take 4 steps), so G and H are not isomorphic.
5
Graph G on vertices A,B,C,D,E and Graph H on vertices 1,2,3,4,5 each have 7 edges. In G, every pair of vertices is connected except A-B,B-C, and C-D. In H, every pair of vertices is connected except 1-4,4-2, and 2-5. Use the complements of G and H to find an isomorphism between them.
Draw only the 3 missing edges for each graph, remembering not to leave out the 5th vertex that has no missing edges, and match the resulting chains from one end to the other.
On 5 vertices there are 10 possible edges, so each 7-edge graph is missing 3 edges, and two graphs are isomorphic if and only if their complements are isomorphic. In the complement of G, the 3 missing edges form the 4-vertex chain A-B-C-D while E sits isolated (degree 0 in the complement, meaning degree 4 in G). In the complement of H, the 3 missing edges form the 4-vertex chain 1-4-2-5 while 3 sits isolated. Matching the isolated vertices forces E=3. Be careful not to match A,B,C,D to the numbers 1,2,4,5 in numerical order ((A=1,B=2,C=4,D=5,E=3) swaps the middle vertices 2 and 4 of the chain 1-4-2-5). Matching the chain A-B-C-D along 1-4-2-5 in either direction gives the 2 isomorphisms: (A=1,B=4,C=2,D=5,E=3) and (A=5,B=2,C=4,D=1,E=3).
6
How many different simple graphs are there on 5 vertices with 3 edges, up to isomorphism? Use that result to state how many different simple graphs there are on 5 vertices with 7 edges, up to isomorphism.
Avoid the common slip of getting only 3 graphs by just adding an isolated 5th vertex to each of the three 4-vertex, 3-edge graphs, which misses (2,1,1,1,1) because that graph has no isolated vertex.
Use the handshake lemma (5 degrees summing to 6) and classify by maximum degree as in the 4-vertex case, watching out for a 3-edge arrangement that uses all 5 vertices at once.
By the handshake lemma, 3 edges mean the 5 vertex degrees must sum to 2×3=6. Classifying by maximum degree: (1) Maximum degree 3 gives a 3-pointed star plus 1 isolated vertex, with degrees (3,1,1,1,0). (2) Maximum degree 2 gives three possibilities: a triangle plus 2 isolated vertices with degrees (2,2,2,0,0); a 4-vertex chain plus 1 isolated vertex with degrees (2,2,1,1,0); or a 3-vertex V-shape plus a separate edge on the remaining 2 vertices with degrees (2,1,1,1,1). Avoid the common slip of getting only 3 graphs by just adding an isolated 5th vertex to each of the three 4-vertex, 3-edge graphs, which misses (2,1,1,1,1) because that graph has no isolated vertex. (3) Maximum degree 1 or 0 is impossible because 5 vertices of degree at most 1 have degree sum at most 5<6. Since all 4 possibilities have different degree sequences, none are isomorphic. Furthermore, because K5 has 10 edges and choosing 7 edges to draw is the same as choosing 10−7=3 edges to erase (taking the complement), there are 4 simple graphs with 3 edges and 4 simple graphs with 7 edges.