Subgraphs and Complements
A graph is a subgraph of , written , if and . is spanning if , and is the subgraph induced by , written , if consists of ALL edges of with both ends in (not just some of them). The complement has the same vertices as , with .
An induced subgraph is the one subgraph on a vertex set you get "for free": pick the vertices and every edge that survives comes along automatically. A general subgraph is weaker — you may also delete edges inside — so induced subgraphs are the most informative kind, and the ones invariants in this topic will lean on. The complement flips every potential edge of the complete graph at once, so and partition the pairs of vertices: , and .
Let have vertices and edges (a triangle on with a path hanging off through to ). The subgraph induced by keeps every edge of with both ends in : that is — the triangle plus the edge to , but nothing touching . Compare the spanning subgraph with and edges only: is spanning (it has all 5 vertices) but NOT induced by anything, since are all present yet edge and are missing even though both ends lie in .
Take with parts and : every cross pair is an edge, , six edges in all. Of the possible pairs on 5 vertices, the four NOT used are (within the first part) and (within the second). So has exactly those four edges — a single edge together with a disjoint triangle : , two cliques with no edges between them. The same argument shows for any complete bipartite graph.
How many spanning subgraphs does the triangle (vertices , edges ) have? A spanning subgraph keeps all 3 vertices and any subset of the 3 edges, and every edge subset is allowed since removing edges can never break the "both ends present" rule. So the count is the number of subsets of a 3-element set, : the empty graph, three graphs with one edge, three with two edges (each a path on all 3 vertices), and itself, and checks against .
Spanning is not the same as induced. The spanning subgraph above (edges ) has every vertex of but is missing edges (, ) whose endpoints are both still there — so . "Induced by " is a strong promise: ALL edges inside survive, not merely some choice of them.
Let have vertices and edges . Find .
Show the answerHide the answer
Of the pairs on 4 vertices, the cycle uses 4 (), leaving 2: and — the two diagonals. So has edges , a single pair of disjoint edges: .
Graph Isomorphism
Graphs and are isomorphic, written , if there is a bijection such that for all . Such a is an isomorphism; an isomorphism from to itself is an automorphism.
A drawing of a graph names its vertices and places them on the page, but neither the names nor the positions are part of the graph itself — only who is adjacent to whom. Isomorphism makes that precise: it says two drawings describe the same adjacency pattern after relabeling, in BOTH directions at once (""), so edges never appear or vanish under . Because is a bijection, it in particular matches to and sends each vertex to one of matching degree, which is the first and simplest test the next section builds on.
Let have vertices and edges — the standard pentagon. Let have vertices and edges listed out of order: . Reading 's edges in sequence traces the cycle , so both graphs are 5-cycles. The map sends , , , , — every edge of lands on an edge of , and since both have exactly 5 edges none are left over, so is an isomorphism.
The star (center , leaves , edges ) and the path (, edges ) both have 4 vertices and 3 edges. But has a vertex of degree 3 and three of degree 1, while every vertex of has degree 1 or 2 — no vertex of has degree 3. Since an isomorphism would have to send the degree-3 vertex of to a vertex of the same degree in , and none exists, .
How many automorphisms does (vertices , edges ) have? An automorphism is a relabeling of that preserves this exact edge set. Rotating the labels around the cycle (, etc.) gives 4 automorphisms, and reflecting (e.g. fixing and swapping ) gives 4 more — 8 in total, matching the 8 symmetries (4 rotations, 4 reflections) of a square. No other relabeling can work: a vertex and its two cycle-neighbors must go to a vertex and its two neighbors, which pins down the whole map once one edge's image is chosen, and there are exactly ways to choose it.
Matching degree sequences do not guarantee an isomorphism. (, edges ) and (a triangle on plus a disjoint edge : edges ) both have degree sequence and both have 4 edges — yet is a single connected path with no triangle, while is disconnected and does contain a triangle. They cannot be isomorphic: an isomorphism would have to carry 's connectedness and triangle-free-ness over unchanged.
Are (vertices , edges ) and (same vertices, edges ) isomorphic?
Show the answerHide the answer
In , vertex has degree 3 (a universal vertex), the edge joins two of its neighbors, and is a pendant attached only to . In , vertex again has degree 3, the edge joins two of its neighbors, and is the pendant. Matching universal-to-universal, pendant-to-pendant, and the remaining two neighbors to each other gives . Check: , , , — all four land in . **Yes, isomorphic, via .**
Invariants That Tell Graphs Apart
A graph invariant is any quantity computed from a graph that is equal for isomorphic graphs — , , the degree sequence, the number of connected components, and the number of triangles are all invariants. If two graphs differ in some invariant, they are NOT isomorphic; matching every invariant you check is never a proof that they ARE, only growing evidence.
Checking an invariant is cheap — count something — while checking isomorphism directly means searching among all bijections (or finding a clever one, as the last section did by hand). Invariants turn "prove these are different" into a one-line computation, which is why they are the first tool reached for. They cannot certify isomorphism, though: no finite checklist of simple invariants captures a graph completely, which is part of why deciding isomorphism in general is a genuinely hard problem. This section builds a working toolkit — components, triangles, and the degree sequence itself used systematically — and the next section shows its limits.
(vertices , edges ) and (two disjoint triangles and : edges ) both have 6 vertices, 6 edges, and every vertex of degree 2 — identical degree sequences. But is a single connected cycle, while splits into two components. "Number of connected components" is an invariant (an isomorphism maps components to components), and , so .
The complete bipartite graph (parts , , all 9 cross edges) and the triangular prism (two triangles , joined by a matching , also 9 edges) are both 3-regular on 6 vertices — same , , and degree sequence. has no triangle at all: every edge runs between the two parts, so three vertices forming a triangle would need an edge within a part, and there is none. The prism has exactly 2 triangles ( and ; the matching edges join the triangles but create no new one, e.g. has edges but not ). Since , the graphs are not isomorphic even though every invariant checked so far agreed.
Up to isomorphism there are only 3 graphs on 4 vertices with exactly 3 edges, and the degree sequence sorts them instantly: is the star ; is the path ; is the triangle plus an isolated vertex. Every other way of placing 3 edges on 4 vertices is a relabeling of one of these three, since there is no room left for a fourth shape once these degree sequences are fixed.
Even a long list of matching invariants can fail to force an isomorphism. The two trees on 6 vertices (a "spider" with legs of length from center ) and (a spider with legs from center ) have the same degree sequence , both are trees (one component, zero triangles) — yet they are not isomorphic, because an isomorphism of these "spiders" would have to match up their leg lengths as a set, and .
The "bowtie" (two triangles sharing one vertex: center joined to , plus edges and ) and the "house" (a square with a roof vertex joined to and ) both have 5 vertices and 6 edges. Are they isomorphic?
Show the answerHide the answer
The bowtie's center has degree 4 (joined to all of ), and the other four vertices each have degree 2, giving degree sequence . In the house, the two roof-corners have degree 3 (two square edges plus the roof) and the rest have degree 2, giving . **Not isomorphic: .**
Self-Complementary Graphs
A graph on vertices is self-complementary if . If so, , and since (Section 1), must be even — which forces or .
A self-complementary graph is a fixed point of the complement operation up to relabeling: exactly half the possible edges of are present, arranged so that filling in the OTHER half gives back something indistinguishable from the start. That "exactly half" is a strict headcount, so it rules out most immediately — no self-complementary graph can exist on 3, 6, or 7 vertices, since , , are all odd. It is also true, though harder to show, that a self-complementary graph exists for EVERY ; the next two examples build the smallest two by hand.
Let : vertices , edges . Of the pairs, the 3 not used are , so has edges . Those three edges form the path (consecutive pairs share endpoints in a chain) — a path on 4 vertices, the same shape as . The relabeling carries 's edges to , exactly 's edge set. So .
Let : vertices , edges . The pairs split into these 5 and the other 5: . Tracing adjacencies in — to ; to ; to ; to ; to — links up into the single cycle , another 5-cycle. So as well: is the smallest self-complementary graph with no isolated structure to exploit, unlike .
Check for : . Only the even values survive the necessary condition: (), (), and (); the odd values (at ) are impossible. That matches exactly: , , , while .
Every graph is automatically edge-disjoint from its complement — that is just the definition, true for and the empty graph on 4 vertices as much as for . It does NOT make them self-complementary. has 6 edges and its complement (the empty graph on 4 vertices) has 0; they are not remotely isomorphic. Self-complementary demands the much stronger ISOMORPHISM , not merely that and share no edge.
Is the "paw" graph (triangle plus a pendant edge ) self-complementary?
Show the answerHide the answer
The paw has 4 vertices and 4 edges. A self-complementary graph on 4 vertices needs exactly half of edges, namely 3 — but the paw has 4. **No: the edge count already rules it out, with no isomorphism check needed.**
Counting Graphs
A simple graph on labeled vertices is exactly a choice of which of the possible edges to include, so there are labeled graphs on vertices. Relabeling never changes the graph up to isomorphism, so these labeled graphs fall into far fewer isomorphism classes (unlabeled graphs) — but not many, since graphs with extra symmetry get over-counted less by the relabelings.
The labeled count is easy because the possible edges are independent, all-or-nothing choices — a direct instance of counting subsets of a set (proved in full in "Why It Works"). The unlabeled count is a genuinely different, harder question: the relabelings of a labeled graph often produce the SAME labeled graph back (whenever the relabeling is an automorphism), so dividing by overcorrects for symmetric graphs and undercorrects for asymmetric ones. The worked examples below total both counts directly for small to see exactly where the naive division goes wrong.
On vertices there are labeled graphs (independently include or exclude ), and every one of them is a relabeling of exactly one of 4 shapes: the empty graph (1 labeled copy), a single edge (3 labeled copies — one for each edge choice), a path on all 3 vertices (3 labeled copies — one for each choice of the missing edge), or the full triangle (1 labeled copy). These counts total , matching exactly, and there are shapes up to isomorphism.
On 4 vertices, , so there are labeled graphs. Sorting these 64 by isomorphism class (by hand or by computer, checking every candidate pair of graphs for a relabeling) gives exactly 11 shapes — far fewer than , which is not even an integer, let alone the right answer.
How many labeled graphs on 5 vertices have exactly 3 edges, and how many shapes do they represent up to isomorphism? There are ways to choose 3 of the possible edges, so 120 labeled graphs. Up to isomorphism there are exactly 4 shapes: a triangle plus 2 isolated vertices, a path plus 1 isolated vertex, a star plus 1 isolated vertex, and a disjoint path-plus-edge using all 5 vertices with none isolated — every other placement of 3 edges on 5 vertices is a relabeling of one of these.
Dividing the labeled count by does not give the unlabeled count, and the 3-vertex case shows it fails outright: , not even a whole number, while the true unlabeled count is 4. The division assumes every graph is turned into DIFFERENT labeled graphs by relabeling, which is false exactly when a graph has a nontrivial automorphism — the empty graph and the triangle are each fixed by all relabelings, contributing only 1 labeled graph apiece instead of 6, which is why and not something closer to .
How many labeled simple graphs are there on 6 vertices?
Show the answerHide the answer
There are possible edges, each independently in or out, so the count is . and , so .
Why It Works
Reflexive: the identity map is a bijection with trivially, so . Symmetric: if is an isomorphism then is also a bijection, and applying the iff in both directions, (substitute into the defining property of ), so . Transitive: if and are isomorphisms, their composite is a bijection (a composite of bijections is a bijection), and , so . All three properties hold, so partitions every collection of graphs into isomorphism classes.
Suppose on vertices. Isomorphic graphs have the same number of edges, so ; combined with (every pair is an edge of exactly one of ), this gives , an even number. Now , so . Since and are consecutive, exactly one is even. If is even: is odd, so forces , i.e. (if instead then , not ). If is odd: is even, so by the same argument , i.e. (if instead , i.e. , then again ). So in every case or .
A simple graph on vertex set is, by definition, a set of edges , the set of all unordered pairs — nothing more, since the vertex set is fixed and simple graphs forbid loops and repeated edges. Conversely every subset of is a valid edge set. So labeled graphs on correspond exactly, one-to-one, to subsets of a set of size . A set of size has exactly subsets (each of the elements is independently in or out, by the product rule), so there are exactly labeled graphs on vertices.