Professional Documents
Culture Documents
Graph theory
Objectives
I To define a graph by specifying a set of vertices and a set of edges.
I To represent graphs using diagrams and matrices.
I To define the degree of a vertex, and to use the fact that the sum of the degrees of all
the vertices of a graph is equal to twice the number of edges.
I To understand what it means for two graphs to be isomorphic, and what it means for
one graph to be a subgraph of another graph.
I To define simple graphs, connected graphs, complete graphs, bipartite graphs
and trees.
I To introduce Euler circuits, Euler trails, Hamiltonian cycles and Hamiltonian paths.
I To count the number of walks of a given length between two vertices of a graph.
I To introduce planar graphs, and to prove and apply Euler’s formula v − e + f = 2 for
connected planar graphs.
Graph theory is useful for analysing ‘things that are connected to other things’, and so has
applications in a variety of areas, including genetics, linguistics, engineering and sociology.
There are many useful techniques in graph theory that are suitable for solving real-world
problems – particularly optimisation problems.
The Seven Bridges of Königsberg is a famous A
historical problem in graph theory. The question
is whether or not you can walk around the city of B D Pregel River
Königsberg crossing each of the seven bridges
exactly once and returning to your starting point. C
We investigate this problem in Section 12B.
e2 Edge Endpoints
v1 v6 e1 {v1 , v2 }
e1 v2 e3 e2 {v1 , v6 }
e7 e4
e3 {v2 , v6 }
v5 e8 v4 e4 {v4 , v6 }
e6 e5 e5 {v3 , v4 }
v3 e6 {v3 , v5 }
e7 {v1 , v5 }
e8 {v2 , v3 }
This is a diagram for a graph. In this diagram, it does not matter how we arrange the vertices,
or whether the edges are drawn as straight, curved or intersecting lines.
Two vertices of a graph are adjacent if they are joined by an edge. The adjacency matrix of
a graph with vertices v1 , v2 , . . . , vn is an n × n matrix such that the entry in row i and column j
is the number of edges joining vertices vi and v j . For example, the adjacency matrix of the
graph shown above is
v1 v2 v3 v4 v5 v6
v1 0 1 0 0 1 1
v2 1 0 1 0 0 1
v3 0 1 0 1 1 0
A=
v4 0 0 1 0 0 1
v5 1 0 1 0 0 0
v6 1 1 0 1 0 0
v1 v2
v4 v3
This graph has multiple edges, as there are two edges joining vertices v2 and v3 .
There is an edge joining v4 to itself; this edge is called a loop.
Vertex v1 is not an endpoint of any edge; it is called an isolated vertex.
The edge-endpoint function and the adjacency matrix for this graph are shown below.
Edge Endpoints v1 v2 v3 v4
v1 0 0 0 0
e1 {v2 , v3 }
v2 0 0 2 0
e2 {v2 , v3 }
v3 0 2 0 1
e3 {v3 , v4 }
v4 0 0 1 1
e4 {v4 }
Note: There is only one edge joining v4 to itself. So this loop only contributes 1 to the
corresponding entry of the adjacency matrix.
Example 1
The following graph represents three houses, A, B and C, that are each connected to
three utilities, gas (G), water (W) and electricity (E). Construct the adjacency matrix for
this graph.
A B C
Solution
A B C G W E
A 0 0 0 1 1 1
B 0 0 0 1 1 1
C 0 0 0 1 1 1
G 1 1 1 0 0 0
W 1 1 1 0 0 0
E 1 1 1 0 0 0
Graph drawing
The same graph can be drawn in very different ways. For example, the graph in Example 1
can also be represented by a different looking diagram, as shown below. The information that
we get from the two diagrams about the vertices and edges is exactly the same. These two
diagrams represent the same graph.
A B C Water B
Electricity
A
Isomorphism
Two graphs that have exactly the same ‘structure’ are said to be isomorphic. If you ignore
the labels on the vertices, then isomorphic graphs can be represented by the same diagram.
Isomorphic graphs
Two graphs are isomorphic if there is a one-to-one correspondence between their vertices
that preserves the ways the vertices are connected by edges.
That is, two graphs G and H are isomorphic if graph H can be obtained from graph G by
simply relabelling its vertices.
For example, the graphs G and H represented by the following two diagrams are isomorphic.
A B W X
D C Z Y
Graph G Graph H
Example 2
Give three reasons why the two graphs shown
C D Y Z
on the right could not possibly be isomorphic.
A B W X
Graph G Graph H
Solution
There are many possible answers to this question. Here are three possible reasons:
Graph G does not have multiple edges, while graph H has multiple edges.
Graph G has three edges, while graph H has four edges.
Graph G has one vertex where three edges meet, while graph H has two such vertices.
For the small graphs in the previous example, it is easy to see that they are not isomorphic.
But it can sometimes be very difficult to tell whether or not two large graphs are isomorphic.
Degree of a vertex
Let v be a vertex of a graph G. The degree of v is equal to the number of edges that
have vertex v as an endpoint, with each edge that is a loop counted twice.
We denote the degree of v by deg(v).
The total degree of the graph G is the sum of the degrees of all the vertices.
For the graph G shown below, the degrees of the vertices are given in the table.
v1 v2 Vertex Degree
v1 0
v2 2
v4 v3 v3 3
v4 3
Handshaking lemma
The total degree of any graph is equal to twice the number of edges of the graph.
Proof Each edge of the graph has two ends, and so each edge contributes exactly 2 to the
sum of the vertex degrees.
Simple graphs
A simple graph is a graph with no loops or multiple edges.
An example of a simple graph is shown below, together with its adjacency matrix.
v5 v1 v2 v3 v4 v5
v1 0 1 0 1 1
v1 v4 v2
1 0 1 0 0
v3 0 1 0 1 0
v4 1 0 1 0 1
v2 v3 v5 1 0 0 1 0
In the adjacency matrix of a simple graph, every entry is either 0 or 1, and the entries on the
main diagonal (top-left to bottom-right) are all 0.
Subgraphs
A subgraph is a graph whose vertices and edges are subsets of another graph.
v5 v5
v1 v4 v1 v4
v2 v3 v2
Graph G A subgraph of G
Summary 12A
A graph G consists of:
1 a finite non-empty set of elements called vertices
2 a finite set of elements called edges
3 an edge-endpoint function that indicates the endpoints of each edge – this function
maps each edge to a set of either one or two vertices.
Exercise 12A
Example 1 1 Houses X and Y are each connected to four utilities: gas (G), water (W), electricity (E)
and broadband (B).
a Draw a graph to depict these connections.
b Redraw your graph so that the edges do not cross.
c Construct the adjacency matrix for this graph.
3 There are five football teams in a conference: Alphington (A), Burlington (B),
Carlington (C), Darrington (D) and Eddington (E).
A has played: B, C, C, D B has played: A, D, E, E C has played: A, A, D
D has played: A, B, C E has played: B, B
a Draw a graph that models this situation.
b Construct the adjacency matrix for this graph.
c Give a reason why this is not a simple graph.
ISBN 978-1-009-11053-2 © Michael Evans et al. 2022 Cambridge University Press
Photocopying is restricted under law and this material must not be transferred to another party.
12A 12A Graphs and adjacency matrices 389
4 Six people are seated at a round table. For each of the following, draw a graph that
models the situation:
a Each person shakes hands with the two people they are sitting next to.
b Each person shakes hands with the person they are sitting opposite.
c Each person shakes hands with every other person.
5 Draw a graph such that each state and territory of Australia is represented as a vertex.
Connect two vertices by an edge if the states or territories that they represent share a
land border.
6 For each of the following graphs, give the adjacency matrix:
a C b A B c A B
B C D
D
C D
A
d e A B f A B
E F
D C
A
D C
g h C
B
B D
A
C A
10 For each of the following, draw the graph corresponding to the given adjacency matrix:
a v1 v2 v3 v4 b v1 v2 v3
v1 0 1 1 0 v1 0 1 1
v2 1 0 1 1 v2 1 0 1
v3 1 1 0 0 v3 1 1 1
v4 0 1 0 0
c v1 v2 v3 v4 d v1 v2 v3
v1 0 1 0 1 v1 1 0 1
v2 1 0 1 0 v2 0 0 2
v3 0 1 0 1 v3 1 2 0
v4 1 0 1 0
A B W X A B W X W X
Graph G Graph H Graph I Graph J Graph K
15 a Draw two different graphs with two vertices, each of which has degree 2.
b Explain why there is no graph with three vertices, each of which has degree 3.
c Draw all non-isomorphic graphs with three vertices, each of which has degree 2.
18 There are 11 different simple graphs with four vertices. Draw them.
19 Let G be a graph with n vertices and exactly n − 1 edges. Prove that G has either a
vertex of degree 1 or an isolated vertex. (Hint: Prove this result by contradiction.)
20 a Draw a graph with three vertices whose total degree is 10.
b Consider all graphs with three vertices whose total degree is 10. Prove that each of
these graphs has some vertex with degree at least 4.
Walks in graphs
Consider the graph shown on the right.
The walk shown in red from v1 to v5 can be described v1
by the sequence of vertices v1 , v2 , v3 , v5 . e1 e4
For the walk shown in green from v4 to v1 , we must
v2 e5 e6 v4
also list the edges taken, as there is more than one edge
joining v3 and v1 . This walk can be described by the e2 e3
v3
sequence v4 , e3 , v3 , e6 , v1 .
e7
A walk can include vertices and edges more than once.
For instance, the walk v2 , v1 , v4 , v1 visits vertex v1 twice v5
and also uses edge e4 twice.
Walks in graphs
A walk in a graph is an alternating sequence of vertices and edges
v1 , e1 , v2 , e2 , . . . , vn−1 , en−1 , vn
where the edge ei joins the vertices vi and vi+1 .
If each pair of adjacent vertices in a walk is joined by only one edge, then the walk can be
described by the sequence of vertices v1 , v2 , . . . , vn .
A graph is said to be connected if there is a walk between each pair of distinct vertices.
Otherwise, the graph is said to be disconnected. The graph G shown below is connected,
while the graph H is disconnected.
v1 v2 v1 v2
v4 v3 v4 v3
Euler circuits
A trail is a walk in a graph that does not use the same edge more than once. In this section,
we are interested in trails that use all the edges.
v2 v4 v2 v4
v1 v1
v3 v5 v3 v5
Note: In an Euler trail, some vertices may be visited more than once.
Euler circuits get their name from the Swiss mathematician Leonhard Euler, who considered
the following famous problem in a paper published in 1736.
Proof Let G be a graph with an Euler circuit. We need to prove that every vertex has even
degree. Suppose that the Euler circuit starts and ends at the vertex v0 .
First consider a vertex v of the graph other than v0 . Each time an edge of the Euler
circuit enters v, there must be a corresponding exit edge. Since the Euler circuit
includes every edge exactly once, it follows that the degree of v is even.
Now consider the starting vertex v0 . The initial edge that leads out of v0 can be paired
with the final edge that leads into v0 . If the vertex v0 is revisited in the middle of the
Euler circuit, then there must be a different entry edge and a corresponding exit edge.
Hence, the degree of v0 is also even.
We are still to prove that, if every vertex has even degree, then the graph has an Euler
circuit. We will complete this half of the proof in Section 12H.
A
Returning to the seven bridges problem, we see that the graph has
no Euler circuit, since the degree of each vertex is odd.
B D
Example 3
For each of the following graphs, name an Euler circuit if one exists:
a v v2 b v v2
1 1
v5
v6
v4 v3 v4 v3
Solution
a The degree of every vertex is even. Therefore the graph has an Euler circuit. One such
circuit is v4 , v1 , v2 , v5 , v4 , v3 , v2 , v6 , v4 . There are many others.
b This graph has vertices of odd degree. Therefore it does not have an Euler circuit.
Euler trails
We recall that an Euler trail in a graph includes every edge exactly once, but does not have to
start and end at the same vertex.
We can easily identify whether an Euler trail exists in a graph by using the next theorem.
Proof (⇒) Let G be a graph that has an Euler trail. Using the theorem for Euler circuits, we
can assume that the Euler trail starts and ends at different vertices v1 and v2 . Add an
edge joining v1 and v2 . The new graph has an Euler circuit, and so every vertex has
even degree. Remove the new edge, and we see that v1 and v2 have odd degree in G.
Therefore the graph G has exactly two vertices with odd degree.
(⇐) We know that, if every vertex has even degree, then there is an Euler circuit. So
consider a connected graph G with exactly two vertices of odd degree. Let these be v1
and v2 . Add an edge joining v1 and v2 . We obtain a connected graph such that every
vertex has even degree, and so it has an Euler circuit. Remove the new edge, and we
have an Euler trail in the graph G from v1 to v2 .
If a connected graph has exactly two vertices of odd degree, then every Euler trail in the
graph must start at one of these vertices and end at the other.
Example 4
For each of the following graphs, name an Euler trail if one exists:
a v v2 b v v2
1 1
v4 v3 v4 v3
Solution
a Vertices v1 and v3 have odd degree. Any Euler trail must start and end at these vertices.
The walk v1 , v3 , v2 , v1 , v4 , v3 is an Euler trail. There are many others.
b This graph has more than two vertices of odd degree. Therefore it does not have an
Euler trail.
Fleury’s algorithm
For small graphs, it is easy to find an Euler trail. But graphs used in real-world problems can
have millions of vertices, and so a trial-and-error approach will not always work.
One systematic approach to finding an Euler trail is called Fleury’s algorithm. The basic
idea behind this algorithm can be recalled with the help a familiar motto:
Don’t burn your bridges (unless you have to).
In a connected graph, a bridge is any edge whose deletion would
cause the resulting graph to become disconnected.
An example of a bridge is shown in the graph on the right.
bridge
Deleting this edge would disconnect the graph.
Fleury’s algorithm
To find an Euler trail in a connected graph such that every vertex has even degree or
exactly two vertices have odd degree:
Step 1 If there are two vertices of odd degree, then start from one of them. Otherwise,
start from any vertex.
Step 2 Move from the current vertex across an edge to an adjacent vertex. Always
choose a non-bridge edge unless there is no alternative.
Step 3 Delete the edge that you have just traversed.
Step 4 Repeat from Step 2 until there are no edges left.
We will apply Fleury’s algorithm to the graph shown in the top-left of the following table.
The vertices A and E have odd degree. We choose to start at vertex A.
A C A C A C
B B B
E D E D E D
There is only one edge There are three edges at B. There is only one edge
at A. We must pick A-B. However B-E is a bridge. at D. We must pick D-C.
Delete this edge. We pick B-D. Delete this edge.
Delete this edge.
A C A C A C
B B B
E D E D E D
There is only one edge There is only one edge All edges are deleted.
at C. We must pick C-B. at B. We must pick B-E. An Euler trail is
Delete this edge. Delete this edge. A-B-D-C-B-E.
ISBN 978-1-009-11053-2 © Michael Evans et al. 2022 Cambridge University Press
Photocopying is restricted under law and this material must not be transferred to another party.
396 Chapter 12: Graph theory 12B
Summary 12B
A walk in a graph is an alternating sequence of vertices and edges.
An Euler trail is a walk in a graph that uses every edge exactly once.
An Euler circuit is a walk in a graph that uses every edge exactly once and that starts
and ends at the same vertex.
A connected graph has an Euler circuit if and only if the degree of every vertex is even.
A connected graph has an Euler trail if and only if every vertex has even degree or
exactly two vertices have odd degree.
Skill-
sheet Exercise 12B
v2 v5 v4
c v2 v3 d v1 v3 v2
v6 v7
v5 v8
v1 v4 v6 v5 v4
e v2 v3 v4 f v5 v1
v6 v2
v1 v5 v4 v3
4 Is it possible for a graph with a vertex of degree 1 to have an Euler circuit? If so, draw
one. If not, explain why not. What about an Euler trail?
5 Can you trace the edges of the following polyhedra without lifting your pencil or tracing
over the same edge twice? (Hint: First find the degree of each vertex.)
a b c
10 Prove that, if a connected graph has exactly two vertices of odd degree, then every Euler
trail in the graph must start at one of these vertices and end at the other.
11 Prove that, if all the vertices of a connected graph have even degree, then every Euler
trail in the graph is an Euler circuit. (Hint: Try a proof by contradiction.)
This walk gives the order in which we can seat the students at the A B
round table.
D C
F E
Hamiltonian paths and cycles
A path is a walk in a graph that does not repeat any vertices (and therefore does not repeat
any edges). A cycle is a walk that starts and ends at the same vertex and otherwise does not
repeat any vertices or edges. In this section, we are interested in paths and cycles that visit all
the vertices.
v2 v3 v2 v3
v5 v5
v1 v4 v1 v4
Example 5
Eight towns are represented by the vertices v1 , v2 , . . . , v8 . The v2
roads that connect these towns are represented as edges. Starting v1 v3
and ending at v1 , how can a salesperson visit every town exactly
once? v4 v5
v6 v8
v7
Solution
We seek a Hamiltonian cycle starting and ending at v1 . v2
v1 v3
One such cycle is v1 , v2 , v3 , v5 , v8 , v7 , v6 , v4 , v1 . This is shown
in red. There are many others. v4 v5
v6 v8
v7
Notes:
It is easy to remember the difference between Euler circuits and Hamiltonian cycles:
EULER circuits are defined in terms of EDGES.
A graph can have an Euler circuit but no Hamiltonian cycle. This can be
seen in the graph on the right.
A graph can have a Hamiltonian cycle but no Euler circuit. This can be
seen in the graph on the right. It has vertices of odd degree.
Summary 12C
A Hamiltonian path is a walk in a graph that visits every vertex exactly once.
A Hamiltonian cycle is a walk in a graph that starts and ends at the same vertex and
visits every other vertex exactly once (without repeating any edges).
Skill-
sheet Exercise 12C
c v2 d v3
v1 v2 v4 v6 v7
v3 v1
v4
v5
3 List a Hamiltonian cycle starting from v1 for each of the following graphs:
a v1 b v2
v1 v3
v3 v4
v4 v5
v2
v6
c v3 d v3
v4 v4 v6 v7
v2 v1
v1 v2
v5 v5
8 For the graphs in this question, each vertex represents a student. Two vertices are joined
by an edge if the two students that they represent are friends.
a Consider the group of students represented by the graph on A
the right. Can these students be seated at a round table so I B
that students are only sitting next to their friends?
H C
Hint: It will help to consider the vertices of degree 2.
G D
F E
F E
Now consider any graph such that every vertex has degree 3. Suppose that the graph
also has a Hamiltonian cycle.
c Use the handshaking lemma to prove that the graph has an even number of vertices.
d Hence, explain why it is possible to colour the edges of the graph using three colours
so that every vertex has three edges with three different colours.
v1 v2 v3
v1 1 2 1
A= v2 2 0 3
v1 v2 v3
v3 1 3 1
There is one direct route from v1 to v3 . This is called a walk of length 1. There are also
several walks from v1 to v3 via v2 . These are called walks of length 2.
In general, the length of a walk in a graph is the number of edges in the walk. (If you use
the same edge more than once, then you must count that edge more than once.)
In the graph shown above, how many different walks of length 2 are there from v1 to v3 ?
There are three cases to consider.
Case 1: v1 → v1 → v3
There is 1 edge from v1 to v1 and then 1 edge from v1 to v3 . This gives 1 × 1 = 1 walk.
Case 2: v1 → v2 → v3
There are 2 edges from v1 to v2 and then 3 edges from v2 to v3 . This gives 2 × 3 = 6 walks.
Case 3: v1 → v3 → v3
There is 1 edge from v1 to v3 and then 1 edge from v3 to v3 . This gives 1 × 1 = 1 walk.
Therefore the total number of walks of length 2 from v1 to v3 is given by:
↓ ↓ ↓
1 1 + 2 3 + 1 1 = 8
× × ×
Note that this calculation can also be obtained by multiplying the first row of A by the third
column of A. The entries corresponding to this product are shown in red below.
v1 v2 v3 v1 v2 v3 v1 v2 v3
v1 1 2 1 v1 1 2 1 v1 6 5 8
v3 1 3 1 v3 1 3 1 v3 8 5 11
In general, the entries of A2 give the number of walks of length 2 between each pair of
vertices. Likewise, the entries of A3 give the number of walks of length 3. In fact, a simple
induction argument will prove the following.
If A is the adjacency matrix of a graph G, then the number of walks of length n from
vertex vi to vertex v j is equal to the entry of An in row i and column j.
Note: It is helpful to define A0 = I, where I is the identity matrix. We can then also consider
walks of length 0. We say that there is one walk of length 0 from any vertex to itself.
Example 6
Find the number of walks of length 3 from vertex v1 to vertex v3 in
the graph shown.
v2
v3 v1
Solution
We construct the adjacency matrix A of the graph and then calculate A3 :
v1 v2 v3 v1 v2 v3
v1 0 1 2 v1 5 9 13
v3 2 1 0 v3 13 9 5
The number of walks of length 3 from v1 to v3 is the entry of A3 in row 1 and column 3.
Therefore there are 13 walks.
Summary 12D
The length of a walk in a graph is the number of edges in the walk. (If you use the
same edge more than once, then you must count that edge more than once.)
If A is the adjacency matrix of a graph G, then the number of walks of length n from
vertex vi to vertex v j is equal to the entry of An in row i and column j.
Skill-
sheet Exercise 12D
Example 6 1 A graph with four vertices has the following adjacency matrix.
v1 v2 v3 v4
v1 0 1 2 0
v2 1 0 2 0
A=
v3 2 2 0 1
v4 0 0 1 0
Regular graphs
A graph is said to be regular if all its vertices have the
same degree.
Proof Each of the n vertices has degree r, so the sum of the degrees of all the vertices is nr.
nr
Therefore, by the handshaking lemma, there are edges.
2
We now look at two special examples of regular graphs.
Cycle graphs
A cycle graph is a graph consisting of a single cycle
of vertices and edges. For n ≥ 3, the cycle graph with
n vertices is denoted by Cn .
Complete graphs
A complete graph is a simple graph with one edge
joining each pair of distinct vertices. The complete
graph with n vertices is denoted by Kn .
Proof Each of the n vertices has degree n − 1, so the sum of the degrees of all the vertices
n(n − 1)
is n(n − 1). Therefore, by the handshaking lemma, there are edges.
2
If G is a simple graph, then its complement is the simple graph G defined as follows:
1 G and G have the same set of vertices
2 two vertices are adjacent in G if and only if they are not adjacent in G.
Note: To generate the complement of a simple graph, fill in all the missing edges required to
form a complete graph and then remove all the edges of the original graph.
Example 7
a How many edges does the complete graph K5 have?
b Draw K5 .
c Draw the cycle graph C5 and draw the complement of C5 .
Solution
5(5 − 1)
a The graph K5 has = 10 edges.
2
b K5
c C5 K5 C5
Bipartite graphs
A bipartite graph is a graph whose vertices can be divided into a1 a2
two disjoint subsets A and B such that every edge of the graph
joins a vertex in A to a vertex in B.
The complete bipartite graph Km,n has m + n vertices and mn edges. The graph above is K2,3 .
The utility graph from Example 1 corresponds A B C
to the complete bipartite graph K3,3 .
Example 8
Draw the complete bipartite graph K2,4 and give its adjacency matrix.
Solution
Each of the two vertices in the set A = {a1 , a2 } is joined to each of the four vertices in the
set B = {b1 , b2 , b3 , b4 }.
a1 a2 a1 a2 b1 b2 b3 b4
a1 0 0 1 1 1 1
a2 0 0 1 1 1 1
b1 1 1 0 0 0 0
A=
b1 b2 b3 b4 b2 1 1 0 0 0 0
b3 1 1 0 0 0 0
b4 1 1 0 0 0 0
Every cycle graph with an even number of vertices is a bipartite graph. This is illustrated in
the next example.
Example 9
a Show that the cycle graph C6 is a bipartite graph by dividing the set of vertices into two
suitable disjoint subsets.
b Hence show that C6 is a subgraph of K3,3 .
Solution
a It helps to colour the vertices with alternating colours. The vertices are then split into
two disjoint subsets according to their colour.
A B
A C E
F C
E D B D F
B D F
Summary 12E
A graph is regular if all its vertices have the same degree.
nr
If G is a regular graph with n vertices of degree r, then G has edges.
2
The cycle graph Cn is a graph consisting of a single cycle of n vertices and n edges.
The complete graph Kn is a simple graph with n vertices such that every pair of
distinct vertices is joined by an edge.
A simple graph G and its complement G have the same set of vertices. Two vertices
are adjacent in G if and only if they are not adjacent in G.
The vertices of a bipartite graph can be divided into two disjoint subsets A and B such
that every edge joins a vertex in A to a vertex in B.
Skill-
sheet Exercise 12E
3 There are six teams in a competition. Each team plays every other team exactly once.
a How many matches are there?
b Represent this competition with the complete graph K6 .
Example 8 6 a Draw the complete bipartite graph K3,3 and its complement.
b Is it true that the complement of a bipartite graph is also bipartite?
7 Find the maximum number of handshakes that can take place between eight people.
Represent this with the complete graph K8 .
8 Draw a regular graph with eight vertices where each vertex has degree:
a 3 b 4 c 5
9 For each of the following, draw the complete bipartite graph and give its adjacency
matrix:
a K1,3 b K2,3
10 Show that the complete bipartite graph K2,2 is isomorphic to the cycle graph C4 .
12 Prove that the complete bipartite graph Km,n has a Hamiltonian cycle if and only
if m = n.
13 a Prove that the complete bipartite graph Km,n has an Euler circuit if and only if both
m and n are even.
b Find an Euler circuit in K2,4 .
Example 9 14 a Show that the cycle graph C8 is bipartite by dividing the set of vertices into two
suitable disjoint subsets.
b Hence show that C8 is a subgraph of K4,4 .
16 Recall that a graph is connected if there is a walk between each pair of distinct vertices.
Let G be a simple graph. Show that either G or its complement G is connected.
12F Trees
Recall that a cycle is a walk in a graph that starts and ends at the same vertex and otherwise
does not repeat any vertices or edges. (By convention, a cycle must include at least one edge.)
The cycle in graph G below is indicated by red edges. Graph H has no cycles.
Trees get their name from the fact that they can often be
drawn in a way that resembles a branching tree. A tree has no
loops or multiple edges. The smallest tree is a single vertex.
Example 10
Draw the three trees with five vertices.
Solution
Trees have many important properties, some of which you will prove in Exercise 12F.
Properties of trees
A tree with n vertices has n − 1 edges.
In any tree, there is exactly one path between each pair of distinct vertices.
Every tree is a bipartite graph.
Example 11
Show that this tree is a bipartite graph by dividing its
vertices into two suitable disjoint subsets.
Solution
It helps to colour the vertices with alternating colours. The vertices are then split into two
disjoint subsets according to their colour.
E A C H F
C D
A B H B D E G
F G
Spanning trees
Let G be a connected graph. A spanning tree of G is a subgraph of G that is a tree with
the same set of vertices as G.
A graph may have many spanning trees. For example, the cycle graph C4 has four spanning
trees. These are shown in red below.
The proof of this theorem is suggested by the following algorithm for finding a spanning tree
of any connected graph. You will complete the proof in Exercise 12F (Question 11).
Example 12
Find a spanning tree for the complete graph K5 .
Solution
Start with K5 . Then successively delete edges belonging to cycles, until the graph has no
cycles. An example is shown below. There are many other possibilities.
Summary 12F
A tree is a connected graph that contains no cycles.
A spanning tree of a connected graph G is a subgraph of G that is a tree with the same
set of vertices as G.
Every connected graph has a spanning tree.
Exercise 12F
Example 10 1 There are two trees with four vertices. Draw them.
2 a There are eight trees with five or fewer vertices. Draw them.
b There are six trees with six vertices. Draw them.
c By using the six trees with six vertices, draw the eleven trees with seven vertices.
Example 11 3 Show that each of the following trees is a bipartite graph by dividing the set of vertices
into two suitable disjoint subsets:
a F b G c G
E F D
A B C D A B C
E C F
A B E
D
Example 12 4 By successively deleting edges belonging to cycles, find a spanning tree for each of the
following graphs:
a b c d
5 Usually a connected graph will have more than one spanning tree.
a Show that all the spanning trees of C3 are isomorphic.
b Draw the eight spanning trees of the graph shown on the right. Put
these spanning trees into two groups of isomorphic graphs.
6 Use a proof by contradiction to show that the addition of an edge to a tree cannot form
more than one cycle.
7 a Consider a tree with at least two vertices. Prove that at least two of its vertices have
degree 1. (Hint: Consider the endpoints of a path of maximal length.)
b Prove that every tree with n vertices has n − 1 edges. (Hint: Use part a and
mathematical induction.)
8 Recall that a path is a walk in a graph that does not visit the same vertex more than
once. Prove that, in a connected graph, there is a path between each pair of distinct
vertices. (Hint: Consider a walk between the vertices of minimal length.)
A graph G is called a planar graph if it can be drawn in the plane so that its edges only
intersect at their endpoints. Any such drawing is called a plane drawing of G.
Not all graphs are planar. The complete graph K5 is not planar, as it
is not possible to draw this graph so that its edges do not cross. You
will prove this in Exercise 12G.
Proof The original planar graph can be drawn so that the edges do not cross. As the edges of
a subgraph form a subset of the edges of the original graph, the edges of the subgraph
also do not cross.
This theorem seems rather trivial, but it is surprisingly useful. To show that a graph is not
planar, it is enough to find a subgraph that is not planar.
Euler’s formula
Faces of a planar graph
If G is a planar graph, then any plane drawing of G
f5
divides the plane into regions, called faces. The bounded
faces are those bordered by edges. The region that is not f2
bordered by edges is called the unbounded face. f1 f4
f3
For the graph shown on the right, the faces f1 , f2 , f3 and f4
are bounded, while the face f5 is unbounded.
Euler discovered a remarkable result about planar graphs that relates the number of vertices,
edges and faces.
Proof We start with a plane drawing of the graph G. Since G is connected, we can
successively delete edges belonging to cycles until we obtain a spanning tree of G.
f1
Each time we delete an edge, the number of faces decreases by 1, the number of
edges decreases by 1 and the number of vertices is unchanged. Therefore the value of
v − e + f is unchanged each time we delete an edge.
The spanning tree has v vertices. As it is a tree, it therefore has v − 1 edges. This tree
has just one face, the unbounded face f1 . Therefore, the spanning tree satisfies
v − e + f = v − (v − 1) + 1 = 2
Moreover, since the value of v − e + f did not change as each edge was deleted, this
formula is also satisfied by the original graph G.
Example 13
Verify Euler’s formula for the planar graph shown.
Solution
There are 8 vertices, 13 edges and 7 faces (including the unbounded face).
Therefore v = 8, e = 13 and f = 7, giving
v − e + f = 8 − 13 + 7
=2
The next theorem says that, if a planar graph has many edges, then it must also have many
vertices.
Proof Let f be the number of faces in a plane drawing of G. As the graph is simple, it has
no loops or multiple edges, so every face is bordered by at least three edges. (If the
face lies on both sides of an edge, then the edge is counted twice.)
Therefore
2e = sum of edges around each face (each edge is double counted)
≥ 3f (each face has at least three edges)
= 3(2 − v + e) (by Euler’s formula)
= 6 − 3v + 3e
Overall, we find that 2e ≥ 6 − 3v + 3e. By rearranging the terms in this inequality, we
obtain e ≤ 3v − 6.
This theorem provides a simple test to show that a connected simple graph is not planar.
Example 14
A connected simple graph has 6 vertices and 14 edges. Show that this graph is not planar.
Solution
If the graph were planar, then e ≤ 3v − 6. However, for this graph we have
3v − 6 = 12 < 14 = e
Note: This theorem can be used to show that a graph is not planar, but it cannot be used to
show that a graph is planar.
Polyhedral graphs
A polyhedron is a three-dimensional solid formed from a collection of polygons joined along
their edges.
Here we show the process for obtaining a planar graph from the cube:
In general, start by resting a convex polyhedron on a flat surface and selecting one of the
upturned faces. Create an open box by removing this face. Then flatten the box by pulling
on the edges, leaving a network of points and edges on the flat plane. This network is a
planar graph of the polyhedron. Graphs so obtained are called polyhedral graphs. The face
removed in this process can be thought of as the unbounded face that surrounds the graph.
Example 15
A pentagonal prism is shown on the right.
a Give a plane drawing of the graph that represents the
pentagonal prism.
b Verify Euler’s formula for this graph.
Solution
a b Here v = 10, e = 15 and f = 7. Thus
v − e + f = 10 − 15 + 7
=2
There are five Platonic solids. These are shown below, along with their polyhedral graphs.
We can use Euler’s formula to prove that there are no other Platonic solids. You should seek
out other proofs of this beautiful result.
Theorem
There are only five Platonic solids.
Proof Listed above are five Platonic solids. We will show that there are no more. Consider
a Platonic solid with m edges around each face and n edges meeting at each vertex.
Let v, e and f be the number of vertices, edges and faces in a planar representation of
this polyhedron. Then
m f = 2e = nv
Substituting in Euler’s formula gives
2e 2e
−e+ =2
n m
Hence
1 1 1 1
+ = +
m n 2 e
and therefore
1 1 1
+ >
m n 2
Rearranging gives
2(m + n)
>1
mn
2(m + n) > mn
mn − 2(m + n) + 4 < 4
(m − 2)(n − 2) < 4
Since both m and n must be at least 3, there are only five possibilities for (m, n). These
are (3, 3), (3, 4), (4, 3), (3, 5) and (5, 3). Hence there are at most five Platonic solids.
ISBN 978-1-009-11053-2 © Michael Evans et al. 2022 Cambridge University Press
Photocopying is restricted under law and this material must not be transferred to another party.
12G 12G Euler’s formula and the Platonic solids 419
Summary 12G
A graph G is called a planar graph if it can be drawn in the plane so that its edges
only intersect at their endpoints.
Euler’s formula If G is a connected planar graph with v vertices, e edges and f faces,
then v − e + f = 2.
Let G be a connected simple graph with v vertices and e edges, where v ≥ 3. If the
graph G is planar, then e ≤ 3v − 6.
Every convex polyhedron can be drawn as a connected planar graph.
Euler’s formula can be used to show that there are only five Platonic solids.
Skill-
sheet Exercise 12G
1 Show that each of the following graphs is planar by redrawing it so that the edges do
not cross:
a A B b A B C
C D
D E F
c A B C D d A B
E F C D E
Example 13 2 Verify Euler’s formula for each of the following planar graphs:
a b
c d
3 Use Euler’s formula to explain why there is no connected planar graph with the
following properties:
a the numbers of vertices, edges and faces are all odd
b the numbers of vertices, edges and faces are all multiples of 4.
Example 14 5 a Draw a simple, connected and planar graph with 4 vertices and 6 edges.
b Show that there is no simple, connected and planar graph with 4 vertices and 7 edges.
6 a Draw a simple, connected and planar graph with 5 vertices and 9 edges.
b Show that there is no simple, connected and planar graph with 5 vertices and
10 edges.
9 By drawing a suitable diagram, show that the complete bipartite graph K2,n is planar for
all n ∈ N.
12 A polyhedron has v vertices. Meeting at each vertex there are three square faces and one
triangular face.
3v
a Explain why the total number of square faces is .
4
v
b Explain why the total number of triangular faces is .
3
c Explain why the total number of edges of this polyhedron is 2v.
d Hence, using Euler’s formula, find the number of vertices, edges and faces.
e A traditional soccer ball is a polyhedron called a truncated icosahedron. Meeting
at each of the v vertices there are two hexagonal faces and one pentagonal face.
Determine the number of vertices, edges and faces of a truncated icosahedron.
In Section 12B we proved only half of this result. We are still to prove that if the degree of
every vertex is even, then the connected graph has an Euler circuit. Our proof of this result
requires the following theorem.
Theorem
Let G be a graph in which every vertex has even degree. Then G can be split into cycles,
no two of which have an edge in common.
Proof Begin at any non-isolated vertex and start ‘moving along edges’, without using the
same edge twice. Every vertex has even degree, so if we arrive at a new vertex along
an edge, there must be an unused edge by which we can leave the vertex. There are
finitely many vertices, so at some stage we will return to a vertex that we have visited
before. Therefore we have a cycle, A1 . Remove the edges of A1 from the graph.
Removing this cycle eliminates edges in pairs at each vertex. Therefore every vertex
of the new graph has even degree. Repeat this process until there are no edges left. In
this way, we can split the graph into cycles A1 , A2 , . . . , An with no edges in common.
Notice that the proofs of these two theorems give an algorithm for finding an Euler circuit in
a connected graph if all its vertices have even degree. The first proof describes a method for
splitting the graph into cycles, and then the second proof describes a method for combining
these cycles into an Euler circuit.
Exercise 12H
1 Each vertex of the graph G shown below has even degree. We have shown one way to
split this graph into cycles with no edges in common.
F F F
A B C D A D B C
E E E
2 Each vertex of the graph H shown below has even degree. We have shown one way to
split this graph into cycles with no edges in common.
B B B
A C
A C
A C
Review
Chapter summary
A graph consists of a finite non-empty set of vertices, a finite set of edges and an
edge-endpoint function that maps each edge to a set of either one or two vertices.
Assign-
ment A graph can be represented by a diagram or an adjacency matrix.
K L K L M N
Nrich
K 0 2 1 1
L 2 0 0 1
N
M M 1 0 0 1
N 1 1 1 1
The degree of a vertex v is the number of edges that have v as an endpoint, with each edge
that is a loop counted twice.
The sum of the degrees of all the vertices of a graph is equal to twice the number of edges.
Two graphs are isomorphic if one can be obtained from the other by relabelling vertices.
A subgraph is a graph whose vertices and edges are subsets of another graph.
Types of graphs
simple graph a graph with no loops or multiple edges
connected graph there is a walk between each pair of distinct vertices
complete graph a simple graph with each pair of distinct vertices joined by an edge
bipartite graph the vertex set can be divided into two disjoint subsets A and B such
that each edge joins a vertex in A and a vertex in B
tree a connected graph with no cycles
planar graph a graph that can be drawn in the plane so that its edges do not cross
Notation for graphs
Cn the cycle graph with n vertices
Kn the complete graph with n vertices
Km,n the complete bipartite graph where A has m vertices and B has n vertices
Walks in graphs
An Euler circuit is a walk that starts and ends at the same vertex and uses every edge of
the graph exactly once. A connected graph has an Euler circuit if and only if every vertex
has even degree.
A Hamiltonian cycle is a walk that starts and ends at the same vertex and visits every
other vertex exactly once (without repeating any edges).
If A is the adjacency matrix of a graph G, then the number of walks of length n from
vertex vi to vertex v j is equal to the entry of An in row i and column j.
Euler’s formula
Let G be a connected planar graph, and let v, e and f denote the number of vertices, edges
and faces in a plane drawing of G. Then v − e + f = 2.
ISBN 978-1-009-11053-2 © Michael Evans et al. 2022 Cambridge University Press
Photocopying is restricted under law and this material must not be transferred to another party.
Review 424 Chapter 12: Graph theory
Technology-free questions
1 a Six people are seated at a round table. Draw a graph to represent each of the
following situations:
i Each person shakes hands with the two people sitting on either side.
ii Each person shakes hands with the person sitting opposite.
iii Each person shakes hands with exactly three other people.
b Explain why it is not possible to draw a graph representing a group of seven people
such that each person shakes hands with exactly three other people.
7 a Show that the graph on the right is planar by drawing it in the plane
without any edges crossing.
b Verify Euler’s formula for this graph.
8 a Draw two different connected planar graphs that have 4 vertices, 6 edges and 4 faces.
b Give three reasons why your two graphs cannot be isomorphic.
Review
Multiple-choice questions
1 Which one of the following statements is false?
A The total degree of a graph is equal to twice the number of edges of the graph.
B A graph must have an even number of vertices with odd degree.
C A graph can have an odd number of vertices with odd degree.
D The total degree of a graph is always even.
E A graph can have an even number of vertices with even degree.
3 The graph on the right has an Euler trail that starts and ends at
which one of the following pairs of vertices?
A v1 and v2 B v1 and v3 C v1 and v4 v1 v2 v3 v4
D v2 and v3 E v2 and v4
4 For which one of the following adjacency matrices does the corresponding graph not
have an Euler circuit?
0 1 1 0 2 2 0 3 3 0 3 1 0 2 1
A 1 0 1 B 2 0 2 C 3 0 1 D 3 0 1 E 2 0 3
1 1 0 2 2 0 3 1 0 1 1 0 1 3 0
6 The graph G shown on the right does not have an Euler circuit. C
A B
Which one of the following edges should be added to G so that the
new graph has an Euler circuit?
A {A, D} B {B, E} C {C, F} D {A, F} E {C, D}
D E F
7 Which one of the following graphs has an Euler circuit?
A the complete graph K4 B the complete graph K5
C the complete graph K6 D the complete bipartite graph K1,3
E the complete bipartite graph K3,3
8 The complete bipartite graph Km,n has a Hamiltonian cycle if and only if
A m=n B m≥n C m≤n D m<n E m>n
9 For the graph shown on the right, the number of walks of length 6 from D C
vertex A to vertex A is
A 90 B 91 C 92 D 93 E 94 A B
11 Which one of the following complete bipartite graphs has 10 vertices and 24 edges?
A K3,8 B K2,8 C K2,12 D K4,6 E K5,5
14 A connected simple graph G has 6 vertices and 13 edges. We can find a spanning tree
for G by deleting edges belonging to cycles. How many edges will be deleted?
A 5 B 6 C 7 D 8 E 9
Extended-response questions
A3 = C 13 13 12 13 13
The trace of a square matrix A, denoted
D 13 13 13 12 13
by tr(A), is the sum of the entries of A on the
E 13 13 13 13 12
main diagonal (top-left to bottom-right).
c If A is the adjacency matrix of any simple graph, explain why:
i tr(A) = 0
ii tr(A2 ) = 2 × the number of edges of the graph
iii tr(A3 ) = 6 × the number of triangles of the graph
d Let A be the adjacency matrix of any simple graph G. Prove that if the trace of any
odd power of A is non-zero, then the graph G is not bipartite.
ISBN 978-1-009-11053-2 © Michael Evans et al. 2022 Cambridge University Press
Photocopying is restricted under law and this material must not be transferred to another party.
Chapter 12 review 427
Review
2 Samira has four cubes with faces coloured red, green, blue or
yellow. Cube 1 has three green faces and one each of red, blue
and yellow.
The blue face is opposite the red face.
Two of the green faces are opposite one another.
The other green face is opposite the yellow face.
This information is illustrated by the coloured net on the right. G Y
We can also summarise the information in the graph with four
vertices R, G, B and Y shown on the right.
a Cube 2 has a green face opposite a blue face, another green B R
face opposite a red face and a second red face opposite a Cube 1
yellow face. Draw a graph to represent this information.
b Cube 3 is represented by the graph on the right, which
indicates its opposite faces. Draw an example of a coloured G Y
net for this cube. (Note: There is more than one possibility.)
c Cube 4 has one green face, two yellow faces, one blue face
B R
and two red faces. The green face is opposite a yellow face,
Cube 3
and the blue face is opposite a red face. Fill in the missing
information and then draw a graph to represent the opposite
faces of cube 4.
4
Samira wants to stack her four cubes into a tower as shown on the right,
in such a way that all four colours are used on each of the four vertical 3
faces of the tower. We can use a graph to help with this.
2
First we combine the four graphs representing the opposite faces of the
four cubes into a single graph. Each edge of this graph is labelled 1, 2, 3 1
or 4 to indicate which cube it comes from.
d The labelled graph on the right shows cubes 1 and 3
combined together. Copy and complete this graph so 1 G 1 Y 3
that it represents all four cubes.
From the graph representing all four cubes, we will find 3 1
a subgraph that represents the front and back faces of the
tower. Each face of the tower uses each colour once. This B R
3
means that the graph representing the front and back faces
must be a subgraph of the answer to part d with four edges Cubes 1 and 3
labelled 1, 2, 3 and 4 and four vertices of degree 2.
e If we include the loop labelled 1 on vertex G, it is not possible to form a subgraph
with four edges labelled 1, 2, 3 and 4 and four vertices of degree 2. Explain why.
f Suppose that we include the edge labelled 1 that joins B and R. Draw a subgraph that
has the required properties.
g Using part f, show the two possible colourings of the front face of the tower.
Challenge: Can you find the colourings of the two side faces of the tower?
B 1 0 1 0 1 0
C 0 1 0 1 0 0
A=
D 0 0 1 0 1 1
E 1 1 0 1 0 0
F 1 0 0 1 0 0