Definitions and Examples
Graphs are a way to keep only the incidence pattern of a network: which objects are present, and which pairs are joined. A road map, a molecule, a tournament schedule, a circuit diagram, and a friendship relation may look very different in the plane, but the graph-theoretic data are the same kind of data: vertices and edges. This separation is one of the main themes in introductory graph theory. Geometry may help us draw the object, but adjacency is what the graph records.
This page fixes the vocabulary used throughout the graph theory section. The point is not to memorize names in isolation, but to recognize which features survive under redrawing, relabelling, deletion, contraction, and passage to standard families such as complete graphs, cycles, wheels, and bipartite graphs.
Definitions
A graph consists of a vertex set and an edge family whose members join vertices. In a simple graph, every edge is an unordered pair of two distinct vertices, and no pair occurs more than once. Thus a simple graph has no loops and no multiple edges. In a more general graph, a loop has both ends at the same vertex, and parallel edges are two or more edges with the same pair of endpoints.
Two vertices are adjacent if an edge joins them. A vertex and an edge are incident if the vertex is an endpoint of the edge. The degree of a vertex is the number of incident edge ends; a loop contributes to the degree because both ends are incident with the same vertex. A vertex of degree is isolated, and a vertex of degree is an end-vertex or leaf.
A subgraph of has and , with every edge of incident only with vertices of . An induced subgraph on a vertex set includes every edge of whose endpoints both lie in . A spanning subgraph has all the vertices of but only some of its edges.
Two graphs and are isomorphic if there is a bijection such that exactly when . Isomorphism formalizes the phrase "same graph with different labels." Degree sequences, numbers of vertices and edges, and counts of triangles are isomorphism invariants, though no single one of these invariants is a complete test in general.
Standard families appear repeatedly:
| Graph | Vertices | Edges | Key feature |
|---|---|---|---|
| Null graph | |||
| Every pair adjacent | |||
| One path through all vertices | |||
| A cycle, | |||
| Complete bipartite graph | |||
| Vertices are binary strings |
For a simple graph , the complement has the same vertex set and has as an edge exactly when is not an edge of . A graph is regular of degree , or -regular, if every vertex has degree .
A useful convention when reading examples is to ask which category the graph belongs to before applying a formula. Complete-graph, complete-bipartite, path, cycle, wheel, cube, and null-graph formulas have different hypotheses. Most counting mistakes on early exercises come from recognizing the drawing visually but then applying the wrong family name.
Key results
Handshaking lemma. For any finite graph,
Proof sketch: count incident edge ends. Each ordinary edge contributes one end at each endpoint, and each loop contributes two ends at its single endpoint. Therefore summing degrees counts two ends for every edge.
Odd-degree corollary. Every finite graph has an even number of vertices of odd degree.
This follows because the degree sum is even. The even-degree vertices contribute an even sum, so the odd-degree vertices must also contribute an even sum. A sum of odd integers is even only when there are an even number of summands.
Counting labelled simple graphs. On a fixed labelled vertex set with vertices, there are
simple graphs. There are possible unordered pairs, and each pair is independently either present or absent.
Complement degree formula. If is a simple graph with vertices, then
Each vertex has possible neighbors. The complement supplies exactly the missing adjacencies.
Visual
The same abstract graph can be drawn in different ways. The diagram below records adjacency only; the layout and edge lengths are not part of the graph.
For this graph,
| Vertex | Neighbors | Degree |
|---|---|---|
| 2 | ||
| 3 | ||
| 2 | ||
| 3 | ||
| 2 |
The degree sum is , so the graph has edges.
Worked example 1: Count edges and degrees in
Problem. Find the number of vertices, number of edges, and degree sequence of the complete bipartite graph .
Method.
- Split the vertex set into two parts: with vertices and with vertices.
- In , every vertex of is adjacent to every vertex of .
- No two vertices inside the same part are adjacent.
- Therefore each of the vertices in has degree .
- Each of the vertices in has degree .
The number of vertices is
The number of edges can be counted directly:
The degree sequence, sorted in nondecreasing order, is
Check. The sum of degrees is
and . This agrees with the handshaking lemma.
Worked example 2: Compare a graph with its complement
Problem. Let be the graph on vertices with edges
Find the degree sequence of , then find the degree sequence and edge set of .
Method.
- Count the degree of each vertex in .
- Vertex is incident with , so .
- Vertex is incident with , so .
- Vertex is incident with , so .
- Vertex is incident with , so .
- Vertex is incident with , so .
- The sorted degree sequence of is .
- A simple graph on vertices has possible edges.
- Since has edges, its complement has edges.
- List the missing pairs:
So
Using the complement degree formula with ,
Thus the complement degrees are , and the sorted degree sequence is
Check. The complement degree sum is , so has edges, matching the missing-pair count.
Code
The following pure Python code stores a simple graph as adjacency sets and checks the handshaking lemma, complement formula, and edge count.
from itertools import combinations
def make_graph(vertices, edges):
adj = {v: set() for v in vertices}
for u, v in edges:
if u == v:
raise ValueError("simple graph cannot contain a loop")
adj[u].add(v)
adj[v].add(u)
return adj
def edge_count(adj):
return sum(len(nbrs) for nbrs in adj.values()) // 2
def complement(adj):
vertices = list(adj)
comp_edges = []
for u, v in combinations(vertices, 2):
if v not in adj[u]:
comp_edges.append((u, v))
return make_graph(vertices, comp_edges)
G = make_graph([1, 2, 3, 4, 5], [(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (1, 3)])
Gc = complement(G)
print(sorted(len(nbrs) for nbrs in G.values()))
print(sorted(len(nbrs) for nbrs in Gc.values()))
print(edge_count(G), edge_count(Gc))
assert sum(len(nbrs) for nbrs in G.values()) == 2 * edge_count(G)
Before moving on, practice translating each drawing into three forms: a vertex set, an edge set, and an adjacency list. These representations force precision. The vertex and edge sets are best for definitions and counting; the adjacency list is best for computing degrees and neighborhoods; the drawing is best for intuition. If all three agree, most basic graph questions become routine.
Common pitfalls
- Treating a drawing as part of the graph. Unless the topic is planarity or geometry, crossings and edge lengths in a drawing usually do not matter.
- Forgetting that a loop contributes to degree in a general graph.
- Confusing a subgraph with an induced subgraph. A subgraph may omit edges; an induced subgraph must include all available edges among its chosen vertices.
- Assuming equal degree sequences imply isomorphism. They are useful necessary conditions, not sufficient conditions.
- Counting edges of as . Only cross-part pairs are edges, so the count is .
- Writing complement formulas for graphs with loops or multiple edges. The usual complement is a simple-graph operation.