Skip to main content

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 GG consists of a vertex set V(G)V(G) and an edge family E(G)E(G) 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 deg(v)\deg(v) of a vertex vv is the number of incident edge ends; a loop contributes 22 to the degree because both ends are incident with the same vertex. A vertex of degree 00 is isolated, and a vertex of degree 11 is an end-vertex or leaf.

A subgraph HH of GG has V(H)V(G)V(H) \subseteq V(G) and E(H)E(G)E(H) \subseteq E(G), with every edge of HH incident only with vertices of HH. An induced subgraph G[S]G[S] on a vertex set SV(G)S \subseteq V(G) includes every edge of GG whose endpoints both lie in SS. A spanning subgraph has all the vertices of GG but only some of its edges.

Two graphs GG and HH are isomorphic if there is a bijection ϕ:V(G)V(H)\phi:V(G)\to V(H) such that uvE(G)uv \in E(G) exactly when ϕ(u)ϕ(v)E(H)\phi(u)\phi(v)\in E(H). 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:

GraphVerticesEdgesKey feature
NnN_nnn00Null graph
KnK_nnn(n2)\binom n2Every pair adjacent
PnP_nnnn1n-1One path through all vertices
CnC_nnnnnA cycle, n3n \ge 3
Kr,sK_{r,s}r+sr+srsrsComplete bipartite graph
QkQ_k2k2^kk2k1k2^{k-1}Vertices are binary strings

For a simple graph GG, the complement G\overline{G} has the same vertex set and has uvuv as an edge exactly when uvuv is not an edge of GG. A graph is regular of degree rr, or rr-regular, if every vertex has degree rr.

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,

vV(G)deg(v)=2E(G).\sum_{v\in V(G)} \deg(v)=2|E(G)|.

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 nn vertices, there are

2(n2)2^{\binom n2}

simple graphs. There are (n2)\binom n2 possible unordered pairs, and each pair is independently either present or absent.

Complement degree formula. If GG is a simple graph with nn vertices, then

degG(v)=n1degG(v).\deg_{\overline{G}}(v)=n-1-\deg_G(v).

Each vertex has n1n-1 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,

VertexNeighborsDegree
PPQ,TQ,T2
QQP,R,SP,R,S3
RRQ,SQ,S2
SSQ,R,TQ,R,T3
TTP,SP,S2

The degree sum is 2+3+2+3+2=122+3+2+3+2=12, so the graph has 12/2=612/2=6 edges.

Worked example 1: Count edges and degrees in K3,4K_{3,4}

Problem. Find the number of vertices, number of edges, and degree sequence of the complete bipartite graph K3,4K_{3,4}.

Method.

  1. Split the vertex set into two parts: AA with 33 vertices and BB with 44 vertices.
  2. In K3,4K_{3,4}, every vertex of AA is adjacent to every vertex of BB.
  3. No two vertices inside the same part are adjacent.
  4. Therefore each of the 33 vertices in AA has degree 44.
  5. Each of the 44 vertices in BB has degree 33.

The number of vertices is

3+4=7.3+4=7.

The number of edges can be counted directly:

34=12.3\cdot 4=12.

The degree sequence, sorted in nondecreasing order, is

(3,3,3,3,4,4,4).(3,3,3,3,4,4,4).

Check. The sum of degrees is

43+34=12+12=24,4\cdot 3+3\cdot 4=12+12=24,

and 2E=212=242\vert E\vert =2\cdot 12=24. This agrees with the handshaking lemma.

Worked example 2: Compare a graph with its complement

Problem. Let GG be the graph on vertices {1,2,3,4,5}\{1,2,3,4,5\} with edges

12, 23, 34, 45, 51, 13.12,\ 23,\ 34,\ 45,\ 51,\ 13.

Find the degree sequence of GG, then find the degree sequence and edge set of G\overline{G}.

Method.

  1. Count the degree of each vertex in GG.
    • Vertex 11 is incident with 12,51,1312,51,13, so degG(1)=3\deg_G(1)=3.
    • Vertex 22 is incident with 12,2312,23, so degG(2)=2\deg_G(2)=2.
    • Vertex 33 is incident with 23,34,1323,34,13, so degG(3)=3\deg_G(3)=3.
    • Vertex 44 is incident with 34,4534,45, so degG(4)=2\deg_G(4)=2.
    • Vertex 55 is incident with 45,5145,51, so degG(5)=2\deg_G(5)=2.
  2. The sorted degree sequence of GG is (2,2,2,3,3)(2,2,2,3,3).
  3. A simple graph on 55 vertices has (52)=10\binom52=10 possible edges.
  4. Since GG has 66 edges, its complement has 106=410-6=4 edges.
  5. List the missing pairs:
14, 24, 25, 35.14,\ 24,\ 25,\ 35.

So

E(G)={14,24,25,35}.E(\overline{G})=\{14,24,25,35\}.

Using the complement degree formula with n=5n=5,

degG(v)=4degG(v).\deg_{\overline{G}}(v)=4-\deg_G(v).

Thus the complement degrees are 1,2,1,2,21,2,1,2,2, and the sorted degree sequence is

(1,1,2,2,2).(1,1,2,2,2).

Check. The complement degree sum is 88, so G\overline{G} has 8/2=48/2=4 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 22 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 Kr,sK_{r,s} as (r+s2)\binom{r+s}{2}. Only cross-part pairs are edges, so the count is rsrs.
  • Writing complement formulas for graphs with loops or multiple edges. The usual complement is a simple-graph operation.

Connections