Lecture Notes
Lecture Notes
(MATH342)
Lecture Notes
Compiled by:
Dr. Z.B. Shozi
University of KwaZulu-Natal
School of Mathematics, Statistics & Computer Science
College of Agriculture, Engineering & Science
Office 430, H1 Building
Westville Campus
shoziz1@ukzn.ac.za
About Me
I am a lecturer in the School of Mathematics, Statistics & Computer Science at the University of
KwaZulu-Natal. My research interest is mainly in graph theory and group theory.
i
Contents
1 An Introduction to Graphs 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 What is a graph? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Examples of Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Operations in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 The Degree of a Vertex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 Isomorphic Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Connectivity 18
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 Connected Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3 Distance in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4 Cut-vertices and Bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4 Trees 36
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.2 Properties of Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3 Constructing Minimum Spanning Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5 Eulerian Graphs 45
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2 Eulerian Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.3 Fleury’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.4 The Chinese Postman Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6 Planar Graphs 55
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.2 Properties of Planar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.3 The Four Colour Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7 Hamiltonian Graphs 63
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.2 Which Graphs Are Hamiltonian? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.3 The Closure Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8 Networks 70
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.2 Digraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.3 An Introduction to Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.4 The Max-Flow Min-Cut Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
ii
8.5 The Max-Flow Min-Cut Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
References 87
1. An Introduction to Graphs
1.1 Introduction
Recent years have seen increased demand for application of mathematics. Graph theory has proven
to be particularly useful to a large number of rather diverse fields. The exciting and rapidly growing
area of graph theory is rich in theoretical results as well as applications to real-word problems. With the
increasing importance of the computer, there has been a significant movement away from the traditional
calculus courses and towards courses on discrete mathematics, including graph theory.
One of the primary activities of an applied mathematician is modelling. In a mathematical model, we
represent or identify a real-life situation or problem with a mathematical system. One of the best-known
examples of this representation is plane Euclidean geometry which gives useful results for describing
small regions, such as measuring distances.
For graph theorists, the modelling process involves formulating a problem in such a way that it can
be attacked by techniques of graph theory. This is not always easy; the way in which the modelling is
carried out, and the degree to which the mathematical model accurately represents the original problem,
varies considerably from problem to problem.
Many real-life situations can be described by means of a diagram consisting of a set of points with lines
joining certain pairs of points. Loosely speaking (we shall be more precise shortly), such a diagram is
what we mean by a graph. Graph theory is one area of mathematics that is particularly well-studied to
model building. The two main themes of this course are the development of graph theory as a subject
in its own right, and the modelling of problems.
Instances of graphs abound: for example, the points might represent cities with lines representing direct
flights between certain pairs of these cities in some airline system, or perhaps the lines representing
pipelines between certain pairs of these cities in an oil network. On the other hand, points might
represent factories with lines representing communication links between them. Electrical networks,
multiprocessor computers or switching circuits may clearly be represented by graphs. In chemistry,
graphs may sometimes be helpful in describing the structure of molecules. A chemical molecule can
be represented as a graph whose ’points’ correspond to the atoms and whose ’lines’ correspond to
the chemical bonds connecting them. The problem of counting the alkanes (paraffins) Cn H2n+2 is
essentially a tree-counting problem. (Trees are a class of graphs which we will study in Chapter 4).
For the sociologist, a graph depict the manner in which people (or groups of people) exert influence
over one another. Graphs can arise in several seemingly unrelated contexts, such as genetics, ecology,
archaeology, music, and the phasing of traffic lights. In order to investigate such relationships more
deeply, we need to study the theory of graphs in greater detail.
An important part of learning graph theory is problem solving, and for this reason a number of problems
at the end of most sections have been included. Many of these are routine exercises, designed to test
understanding of the material in this text, but some are more challenging and less routine. The large
variety of proofs used in the course can help strengthen our use of mathematical techniques.
1
Section 1.2. What is a graph? Page 2
concept of a graph.
Definition 1.2.1 (Graph).
A graph G is a finite nonempty set of objects, called vertices (the singular is vertex), together with
a (possibly empty) set of unordered pairs of distinct vertices, called edges. The set of vertices of the
graph G is called vertex set of G, denoted by V (G), and the set of edges is called edge set of G,
denoted by E(G). The edge e = {u, v} is said to join the vertices u and v. If e = {u, v} is an edge
of G, then u and v are adjacent vertices, while u and e are incident, as are v and e. Furthermore, if
e1 and e2 are distinct edges of G incident with a common vertex, then e1 and e2 are adjacent edges.
It is convenient to henceforth denote an edge by uv or vu rather than by {u, v}. The cardinality of
the vertex set of a graph G is called the order of G and is denoted by n(G), or more simply by n
when the graph under consideration is clear, while the cardinality of the edge set is the size, denoted
by m(G) or m. An (n, m) graph has order n and size m. The graph of order n = 1 is called a trivial
graph. A nontrivial graph has at least two vertices.
It is customary to define or describe a graph by means of a diagram in which each vertex is represented
by a point (which we draw as a small circle) and each edge edge e = uv is represented by a line segment
or curve joining the points corresponding to u and v.
To illustrate these definitions, consider the graph G defined by the sets V (G) = {v1 , v2 , v3 , v4 } and
E(G) = {v1 v2 , v2 v3 , v2 v4 , v3 v4 }. A diagram of this graph is shown in Figure 1.1. This graph has order
4 and size 4. Furthermore, observe that v1 and v2 are adjacent, but v1 and v3 are not adjacent. The
vertex v2 is incident to the edge v2 v3 , but v4 is not incident to v2 v3 . The edges v1 v2 and v2 v3 are
adjacent, but v1 v2 and v3 v4 are not adjacent.
We also need the concept of a subgraph of a graph. It is a common feature of mathematics that we
study complicated objects by looking at simpler objects of the same type contained inside them, and
these smaller objects are often indicated by the prefix “sub”. For example, we study subsets of sets,
subsystems of systems, and so on. In graph theory, we make the following definition.
Section 1.2. What is a graph? Page 3
For example, if G is the graph shown in Figure 1.1, then the graphs H1 , H2 and H3 shown in Figure
1.2 are all subgraphs of G. (Note that G is regarded as a subgraph of itself)
For example, if G is the graph shown in Figure 1.1, and H1 and H2 are the subgraphs of G shown in
Figure 1.2, then H1 = G[F ] and H2 = G[W ], where F = {v1 v2 , v3 v4 } and W = {v2 , v3 , v4 }.
Section 1.2. What is a graph? Page 4
Learning Opportunities
1.1. Draw the graph with vertex set V = {v1 , v2 , v3 , v4 , v5 } and edge set E = {v1 v2 , v1 v4 , v1 v5 , v2 v3 ,
v3 v5 , v4 v5 }.
1.2. Write down the vertex set and the edge set of the following graph:
1.3. Which of the following graphs are subgraphs of the graoh G in Learning Opportunity 1.2.?
1.4. Six Sol Plaatje University teams A, B, C, D, E and F belong to the same league and have played
a number of matches: A has played C, D and E; B has played C and E; C has played A, B and
D; D has played A, C and E; E has played A, B and D; F has not yet played. Let G be a graph
with vertex set V (G) = {A, B, C, D, E, F } and let two vertices of G be adjacent if and only if
the corresponding teams have played a match.
1.4.1. Write down E(G), the set of edges of the graph G.
1.4.2. Draw the graph G.
Section 1.3. Examples of Graphs Page 5
We can distinguish the vertices in V1 from those in V2 by drawing the former in blue and the latter in
white, so each edge is incident with a blue vertex and a white vertex. Some examples of bipartite graphs
are shown below.
A graph G is k-partite, k ≥ 2 if its vertex set V (G) can be partitioned into k subsets V1 , V2 , . . . , Vk
(called partite sets) in such a way that each edge of G joins a vertex of Vi to a vertex of Vj , i ̸= j.
A complete k-partite graph is a k-partite graph with partite sets V1 , V2 , . . . , Vk having the added
property that every vertex of Vi is adjacent to every vertex of Vj for 1 ≤ i < j ≤ k. If |Vi | = ni , then
this graph is denoted by K(n1 , n2 , . . . , nk ). If ni = n for all i, then we denote this graph simply by
Kk (n). A graph is a complete multipartite graph if it is a complete k-partite graph for some k ≥ 2.
Section 1.4. Operations in Graphs Page 7
Learning Opportunities
1.7. Draw the following graphs:
1.7.1. K6
1.7.2. K4,4
1.7.3. K2,5
1.8. How many edges does a complete bipartite graph Km,s have?
v1 = w1 and v2 w2 ∈ E(G2 )
or
v2 = w2 and v1 w1 ∈ E(G1 ).
For example, the compliment of Kn is Kn . Figure 1.10 shows a graph G and its compliment G. Note
that if we take the complement of G, then we get back the original graph G.
Learning Opportunities
1.9. Draw the following graphs:
1.9.1. 3K3
1.9.2. K2,2 × K2
1.9.3. K2,3
1.10. For i = 1, 2, let Gi be an (ni , mi )-graph. Determine the order and size of G1 × G2 in terms of
n1 , n2 , m1 , m2 .
In Figure 1.11, a graph is shown together with the degrees of its vertices.
Section 1.5. The Degree of a Vertex Page 10
Observe that for the graph G in Figure 1.11, n(G) = 10 and m(G) = 11, while the sum of the degrees
of its vertices is 22. The fact that this last number equals 2m(G) is no mere coincidence, as we now
show.
Theorem 1.5.3 (Handshaking Lemma).
In any graph, the sum of all the vertex degrees is equal to twice the number of edges.
Proof. Every edge is incident with two vertices; hence, when the degrees of the vertices are summed,
each edge is counted twice.
The above theorem is sometimes called the handshaking lemma. This name arises from the fact that
a graph can be used to represent a group of people shaking hands at a party. In such a graph, the
people are represented by the vertices, and an edge is included whenever the corresponding people have
shaken hands. With this interpretation, the number of edges represents the total number of handshakes,
the degree of a vertex is the number of hands shaken by the corresponding person, and the sum of the
degrees is the total number of hands shaken. So the handshaking lemma states simply that the total
number of hands shaken is equal to twice the number of handshakes–the reason being, of course, that
Section 1.5. The Degree of a Vertex Page 11
exactly two hands are involved in each handshake. There are some important consequences of the
handshaking lemma.
Corollary 1.5.4.
In any graph, there is an even number of odd vertices.
Proof. Let G be a graph of order n and size m. If G has no odd vertices, then the result follows
immediately. Suppose that G contains k(≥ 1) odd vertices v1 , v2 , . . . , vk . If G contains even vertices
as well, then denote these by vk+1 , . . . , vn . By Theorem 1.5.3,
k
X n
X
deg vi + deg vi = 2m.
i=1 i=k+1
n
X
Since each of the numbers deg vk+1 , . . . , deg vn is even, deg vi is even, so
i=k+1
k
X n
X
deg vi = 2m − deg vi
i=1 i=k+1
is even. However, each of the numbers deg v1 , deg v2 , . . . , deg vk is odd. Since the sum of an odd
number of odd numbers is odd, it follows that k must be even; that is, G has an even number of odd
vertices. If G has no even vertices, then we have deg v1 , deg v2 + · · · + deg vk = 2m, from which we
again conclude that k is even.
It is often convenient to list the degrees of vertices of a graph; this is usually done by writing them in
nonincreasing order (that is, in decreasing order but allowing ’repeats’ where necessary). The resulting
list is called the degree sequence of a graph. Given a graph G, the degree sequence of G can be easily
determined (we simply find the degree of each of its vertices). For example, the graph in Figure 1.11
has degree sequence 5, 4, 3, 3, 2, 2, 1, 1, 1, 0. Several interesting questions about degree sequence now
come to mind.
The first question you might think of is, can we reverse this process? By this we mean, given a degree
sequence s, can we determine a graph with s as a degree sequence? Perhaps a better question is: Can
we determine when a sequence of integers represents the degree sequence of a graph? This leads us to
the following definition.
Definition 1.5.5 (Graphical).
A sequence of integers is said to be graphical if it is the degree sequence of some graph. A graph G
with degree sequence s is called a realization of s.
Let us begin with the question: When is a sequence s : d1 , d2 , . . . , dn of integers the degree sequence
of some graph? Certain conditions are clearly important. First, degrees are nonnegative integers, so
di ≥ 0 for all i. Next, di ≤ n − 1, because no vertex in a graph of order n can be adjacent to more
than n − 1 vertices. Furthermore, Theorem 1.5.3 tells us that the sum of the degrees of the vertices
n
X
in any graph must be an even number, so di is even. The above three conditions are all necessary
i=1
for a sequence to be graphical, but these conditions are not sufficient. The sequence 3, 3, 3, 1 is not
graphical, for example. A necessary and sufficient condition for a sequence to be graphical was found
by Havel [16] (1955) and later rediscovered by Hakimi [15] (1962).
Section 1.5. The Degree of a Vertex Page 12
With the aid of Theorem 1.5.6, we may now present a procedure, or algorithm, that allows us to
determine whether a finite sequence of nonnegative integers is graphical or not.
Algorithm 1.5.7 (Havel-Hakimi).
Given a sequence of n(≥ 1) nonnegative integers:
1. If some integer in the sequence exceeds n − 1, the the sequence is not graphical.
2. If all the integers in the sequence are 0, then the sequence is graphical.
3. If the sequence contains a negative integer, then the sequence is not graphical.
4. Reorder the sequence (if necessary) so that it is nonincreasing.
5. Delete the first number, say t, from the sequence and subtract 1 from the next t numbers in the
sequence to form a new sequence. Return to step 2.
To illustrate Algorithm 1.5.7, consider the sequence:
s : 4, 4, 4, 3, 3, 2.
Step 1 is satisfied, and we begin the loop of Step 2 to 5. The tests in Step 2 and 3 do not immediately
halt us. Proceeding to Step 5, we get
s′1 = 3, 3, 2, 2, 2
s1 = 3, 3, 2, 2, 2. re-orderring
Section 1.5. The Degree of a Vertex Page 13
s′2 = 2, 1, 1, 2
s2 = 2, 2, 1, 1. re-orderring
s′3 = 1, 0, 1
s3 = 1, 1, 0. re-orderring
s′4 = 0, 0
s4 = 0, 0. re-orderring
Algorithm 9.5.7 shows that s is graphical, since 0, 0 is the degree sequence of the empty graph K2 on
two vertices.
To construct a graph with degree sequence s1 , we proceed in reverse from s′2 to s1 , observing that a
vertex should be added to G2 so that it is adjacent to one vertex of degree 2 and two vertices of degree
1 in G2 . We therefore obtain a graph G1 with degree sequence s1 . Proceeding from s′1 to s, we again
add a new vertex joining it to two vertices of degree 3 and two vertices of degree 2 in G1 . This gives a
graph G with degree sequence s.
It should be pointed out that the graph G in Figure 1.13 is not the only graph with degree sequence
s. The graphs G and H in Figure 1.14 both have the same degree sequence, namely 2, 2, 2, 2, 2, 2. So
degree sequences do not always provide enough information to uniquely describe a graph.
Learning Opportunities
1.11. For the graph G in the accompanying figure, write down the degrees of all the vertices and the
degree sequence of G. Verify the handshaking lemma for the graph G.
Section 1.6. Isomorphic Graphs Page 14
say G2 , so it appears identical to G1 . For example, the graphs G1 and G2 of Figure 1.15 have this
property.
Two graphs often have the same structures differing only in the way their vertices edges are labelled
or in the way they are drawn. To make this idea more exact, we introduce the following concept of
isomorphism.
Definition 1.6.1 (Isomorphism).
Two graphs G and H are isomorphic if H can be obtained from G by relabelling the vertices– that is,
there is a one-to-one correspondence between the vertices of G and those of H such that an edge joins
any pair of vertices in G if and only if the edge joins the corresponding pair of vertices in H. Hence
G is isomorphic to H if there exists a one-to-one mapping ϕ, called an isomorphism from V (G) to
V (H) such that ϕ preserves adjacency; that is, uv ∈ E(G) if and only if ϕ(u)ϕ(v) ∈ E(H). If G and
H are isomorphic, then we write G ∼ = H. Two graphs are nonisomporphic if they are not isomorphic.
is an isomorphism. On the other hand, although each of G1 and G3 is a (6, 9) graph, G1 ≇ G3 . To see
this, consider any one-to-one mapping ϕ from V (G1 ) to V (G3 ). The vertices v1 , v2 and v3 of G3 are
pairwise adjacent, and ϕ must map three vertices of G1 into v1 , v2 and v3 . If ϕ is an isomorphism, then
two vertices of G1 are adjacent if and only if the two image vertices of G3 under ϕ are adjacent. This
implies that the three vertices of G1 whose images are v1 , v2 and v3 also must be pairwise adjacent;
however, G1 does not contain three pairwise adjacent vertices. Hence there is no isomorphism from
V (G1 ) to V (G3 ). Thus G1 ≇ G3 .
Clearly, two graphs may be isomorphic yet not identical. The graphs G1 and G2 of Figure 1.16 are
not identical (even though V (G1 ) = V (G2 ) and G1 ∼= G2 ) since, for example v1 v5 ∈ E(G1 ) and
v1 v5 ∈
/ E(G2 ).
Learning Opportunities
1.18. Determine all (pairwise nonisomorphic) graphs of
1.18.1. order 3.
1.18.2. order 4.
1.19 Show that the graphs F1 and F2 are isomorphic by proving the existence of an isomorphism from
F1 to F2 or of an isomorphism from F2 to F1 .
1.20. Show that the following two graphs G and H are isomorphic.
Section 1.6. Isomorphic Graphs Page 17
Note that we do not require all edges or vertices in a walk to be different. Often only the vertices of a walk
are listed, for the edges present are then obvious. For example, v3 , v3 v2 , v2 , v2 v6 , v6 , v6 v3 , v3 , v3 v4 , v4 , v4 v5 ,
v5 , v5 v4 , v4 is a v3 -v4 walk in the graph G of Figure 2.1. The walk just described can be expressed more
simply as v3 , v2 , v6 , v3 , v4 , v5 , v4 . This walk has length 6.
Figure 2.1
18
Section 2.2. Connected Graphs Page 19
The v3 -v4 walk described above is not a trail (since the edge v4 v5 occurs twice). However, v3 , v2 , v6 , v3 , v4
is a v3 -v4 trail in the graph G of Figure 2.1. This trail is not a path (since the vertex v3 is repeated).
However, v3 , v5 , v4 is a v3 -v4 path. It is useful to have a special terms for those walks or trails which
start and finish at the same vertex.
Definition 2.2.3 (Closed Walk, Closed Trail).
A u-v walk is closed if u = v and open otherwise. A closed walk in which all the edges are different is
a closed trail. A closed trail which contains at least three vertices is called a circuit. A circuit which
does not repeat any vertices (except the first and last) is called a cycle. An acyclic graph has no
cycles. The length of a cycle (or circuit) is the number of edges in the cycle (or circuit). A cycle of
length n is an n-cycle. A 3-cycle is called a triangle. A cycle is even if its length is even, otherwise
it is odd.
In the graph G of Figure 2.2, v1 , v2 , v3 , v4 , v5 , v2 , v6 , v1 is a circuit (of length 7) that is not a cycle,
while v2 , v4 , v3 , v5 , v2 is a cycle (as well as a circuit) of length 4.
Figure 2.2
By definition, every path is a trail and every trail is a walk. Although the converse of each of these
statements fails to hold, we do have a result that relates walks and paths.
Theorem 2.2.4 (Walks, Paths).
Every u-v walk in a graph contains a u-v path.
Proof. Let W be a u-v walk in a graph G. If W is closed, then the result is easy; we simply use the
trivial path u. Thus, assume W is an open walk, say W : u = u0 , u1 , u2 , . . . , uk = v. Note that a
vertex may have received more than one label if it occurs more than once in W . If no vertex is repeated,
Section 2.2. Connected Graphs Page 20
then W is already a path. Otherwise, there are vertices of G that occur in W twice or more. Let i and
j be distinct integers with i < j such that ui = uj . That is, the vertex ui is repeated as uj . If we now
delete the vertices ui , ui+1 , . . . , uj−1 from W , we obtain a u-v walk W1 which is shorter than W and
has fewer repeated vertices. If W1 is a path, we are done; if not, we continue this process until finally
we reach a stage where no vertices are repeated and a u-v path is obtained.
Figure 2.3
Figure 2.4
Learning Opportunities
2.1. Give an example of a disconnected graph with four components where each component is complete.
2.2. Give an example of a disconnected graph with three components where every two components are
isomorphic.
2.3. Consider the graph G below:
Give an example of
2.3.1. a circuit which is not a cycle;
2.3.2. a trail which is not a path;
2.3.3. a path;
2.3.4. a cycle.
2.4. Show that if G is a graph with minimum degree δ ≥ 2, then G contains a cycle of length at least
δ + 1. (Hint: Consider a longest path P in G. Let u be an end-vertex of P and consider the
vertices adjacent to u in G.)
2.5. Show that if G is a bipartite graph with minimum degree δ ≥ 1, then G contains a path of order
at least 2δ.
2.6. Prove that a graph and its complement cannot be both disconnected.
2.7. A graph is self-complementary if it is isomorphic to its complement.
Section 2.3. Distance in Graphs Page 22
n2 − 2n
m= .
4
(Hint : Try a calculus argument). If G has this size, what does G look like?
2.9. Let G be a graph of order n such that deg v ≥ n−1
2 for every v ∈ V (G). Prove that G is connected
(Hint: Try a proof by contradiction: Assume, to the contrary, that G is disconnected. This
means that G has two or more components. What can be said about the number of vertices in
each component?)
n−2
2.10. Let G be a graph of order n ≥ 2 such that deg v ≥ 2 for every v ∈ V (G). Show that G need
not be connected if n is even.
2.11. Suppose that G is a graph having no vertex of degree 0 and no induced subgraph with exactly
two edges. Prove firstly that G is connected. Hence prove that G is a complete graph.
2.12. Suppose that G is a connected graph having no vertex of degree 0 and no induced subgraph with
exactly three edges. Prove that G has maximum degree 2. Hence prove that G has at most four
vertices.
Figure 2.6
Section 2.3. Distance in Graphs Page 23
The distance function d(u, v) on pairs of vertices is a metric, that is, it satisfies the following fundamental
properties:
Theorem 2.3.2 (The Distance Function).
Let G be a graph and let u, v, w ∈ V (G). Then
(i) d(u, v) ≥ 0 and d(u, v) = 0 if and only if u = v;
(ii) d(u, v) = d(v, u) (symmetric property);
(iii) d(u, v) ≤ d(u, w) + d(w, v) (triangle inequality).
The proof of Theorem 2.3.2 is left as an exercise (see Learning Opportunity 2.13). We now present a
useful characterization of bipartite graphs.
Theorem 2.3.3 (Characterization of Bipartite Graphs).
A nontrivial graph is bipartite if and only if it contains no odd cycles.
Proof. Let G be a bipartite graph with partite sets V1 and V2 . Suppose C : v1 , v2 , . . . , vk , v1 is a cycle
of G. Without loss of generality, we may assume that v1 ∈ V1 . However, then v2 ∈ V2 , v3 ∈ V1 ,
v4 ∈ V2 , and so on. In general, v2i ∈ V2 and v2i−1 ∈ V1 . This implies that, since vk ∈ V2 , k = 2s for
some positive integer s; hence, C has even length.
For the converse, it suffices to prove that every nontrivial connected graph G without odd cycles is
bipartite, since a nontrivial graph is bipartite if and only if each of its components is bipartite. Let
v ∈ V (G) and denote by V1 the subset of V (G) consisting of v and all vertices u of G with the property
that any shortest u − v path of G has even length. Let V2 = V (G) − V1 . Thus
and
V2 = {u ∈ V (G) | d(u, v) is odd}.
We now prove that the partition V1 ∪ V2 of V (G) has the appropriate properties to show that G is
bipartite. Let u and w be elements of V1 , and suppose uw ∈ E(G). Necessarily, then, neither u nor w
is the vertex v. Let P : v = u1 , u2 , . . . , v2r+1 = u, r ≥ 1, and Q : v = w1 , w2 , . . . , w2s+1 = w, s ≥ 1,
be a shortest v − u path and a shortest v − w path of G, respectively. Now let w′ denote the last vertex
that the two paths P and Q have in common (possibly, w′ = v). This means that the w′ − u subpath
of P and the w′ − w subpath of Q have only the vertex w′ in common. The two v − w′ subpaths so
determines are then the shortest v − w′ paths (for otherwise, we may find a shorter v − u path or v − w
path than P or Q, respectively.) This means that there exists an i such that w′ = ui = wi . However,
proceeding for ui to u along the path P , and then from u to w along the edge uw, and following the
path Q from w back to wi (= ui ) produces a cycle of G, namely
This cycle has length (2r + 1 − i) + (2s + 1 − i) = 2(r + s + 1 − i) + 1, which is odd. We have
shown, therefore, that G contains an odd cycle, which is a contradiction to our hypothesis. We deduce,
therefore, that no two vertices of V1 are adjacent. Similarly, no two vertices of V2 are adjacent. Hence
G is a bipartite graph with partite sets V1 and V2 .
Applications of distance in graphs abound. For example, suppose a town planning committee wishes to
locate certain facilities, such as a fire or police station, in such a way as to minimise the response time
Section 2.3. Distance in Graphs Page 24
between the facility and the location of a possible emergency. How would the committee determine
the most convenient sites for these facilities? To attempt to answer such questions, we introduce the
following concepts.
Definition 2.3.4 (Eccentricity, Radius, Diameter).
The eccentricity e(v) of a vertex v in a graph G is the maximum distance of a vertex from v; that
is, e(v) is the distance from v to a vertex furthest from v. The radius rad(G) of G is the minimum
eccentricity among the vertices of G, while the diameter diam(G) is maximum eccentricity. A vertex
v is a central vertex if e(v) = rad(G), while v is a peripheral vertex if e(v) = diam(G).
Notice that the diameter of G is maximum distance between any two vertices in G. Furthermore, if
rad(G) = 1, then G contains a vertex that is adjacent to every other vertex. In Figure 2.7, the vertices
of the graph G are labelled with their eccentricities. For this graph G, rad(G) = 3 and diam(G) = 5.
The next result shows that the diameter of a graph is at most twice its radius.
Theorem 2.3.5 (Diameter, Radius).
For every connected graph G, rad(G) ≤ diam(G) ≤ 2 rad(G).
Proof. The inequality rad(G) ≤ diam(G) follows directly from the definitions. To verify the inequality
diam(G) ≤ 2 rad(G), let u and v be vertices in G satisfying d(u, v) = diam(G). Furthermore, let w
be a central vertex of G. Since the distance function satisfies the triangle inequality (see Property (iii)
of Theorem 2.3.2), diam(G) = d(u, v) ≤ d(u, w) + d(w, v) ≤ e(w) + e(w) = 2 e(w) = 2 rad(G).
The lower bound of Theorem 2.3.5 is sharp; that is, there exists a graph G for which rad(G) = diam(G).
In fact, the family Kn (n ≥ 2), of complete graphs satisfies this equation, as does the family of all
cycles. The upper bound is also sharp. To see this, let G belong to the family of paths of odd order;
that is, G ∼
= P2k+1 , k ≥ 1. Then rad(G) = k and diam(G) = 2k. Hence for each positive integer k,
there exists a graph G such that diam(G) = 2 rad(G).
Returning to our facility location problem, a possible location for the emergency facility is a vertex in
the centre of the graph that models the street system.
The centre of a graph need not consider a single vertex. For example, the centre of the graph G of
Figure 2.7 is the subgraph induced by the three vertices of eccentricity 3, i.e., C(G) ∼
= P3 . Thus P3 is
the centre of some graph. In fact, Hedetnieml showed that every graph is the centre of some graph.
Theorem 2.3.7 (Centre).
Every graph is the centre of some connected graph.
Proof. Let H be a given graph. Let G be the graph constructed from H by adding four new vertices
v1 , v2 , w1 , w2 and, for i = 1, 2, joining vi to every vertex of H and to wi . For each vertex v in H,
eG (v) = 2, while for i = 1, 2, e(vi ) = 3 and e(wi ) = 4. Thus rad(G) = 2 and the centre of G is the
subgraph induced by the vertices of H; that is, C(G) = H.
Learning Opportunities
2.13. Prove Properties (i), (ii) and (iii) of Theorem 2.3.2.
2.14. Consider the graph G below:
Find
2.14.1. the eccentricity of each vertex.
2.14.2. the radius and diameter of G.
2.14.3. the centre of G.
2.15. If u and v are adjacent vertices in a graph G, then show that |e(u) − e(v)| ≤ 1.
2.16. Show that if G is a graph of order n and size n4 , then either G contains an odd cycle or G ∼
2
= K n2 , n2 .
(Hint: Suppose G contains no odd cycles. Then by Theorem 2.3.3, G is bipartite. Show that
G∼= K n2 , n2 .)
2.17. Given a positive integer r and d with r ≤ d ≤ 2r, construct a graph G with rad(G) = r and
diam(G) = d. (Hint: construct such a graph with one cycle.)
Section 2.4. Cut-vertices and Bridges Page 26
Figure 2.8
The vertex v3 of the graph G in Figure 2.8 is cut-vertex; however, no other vertex of the graph is
a cut-vertex. The edge e4 of the graph of the graph G in Figure 2.8 is a bridge, but no other edge
of that graph is a bridge. If v is a cut-vertex of a connected graph G, then G − v contains two or
more components. However, if e is a bridge of a connected graph G, then G − e contains exactly two
components.
Theorem 2.4.3 (Cut-vertex).
A vertex v of a connected graph G is a cut-vertex of G if and only if there exists vertices u and w
(u ̸= w) such that v is on every u − w path.
Proof. Let v be a cut-vertex of G so that G − v is disconnected. If u and w are vertices in different
components of G − v, then there are no u − w paths in G − v, However, since G is connected, there are
u − w paths in G. Thus, v must lie on every u − w path. Conversely, suppose that there exists vertices
u and w such that v lies on every u − w path in G. Then, in G − v, there are no u − w paths, and so
G − v is disconnected. Thus, v is a cut-vertex of G.
Section 2.4. Cut-vertices and Bridges Page 27
Bridges are characterised in a manner similar to that of cut-vertices; the proof too is similar to that of
Theorem 2.4.3 and is left as an exercise (see Learning Opportunity 2.19).
Learning Opportunities
2.18. In the graph G shown below, determine the cut-vertices and the bridges of G.
Consider the weighted graph G of Figure 3.1. The path P : v2 , v1 , v3 , v4 is a shortest v2 − v4 path (of
length 4). Notice that the path Q : v2 , v3 , v5 (of length 5) is not a shortest v2 − v4 path for G, even
though Q has fewer edges than P .
For example, an airline service can be represented by a weighted graph with the vertices representing
the cities serviced, edges representing the direct flying routes, and with the weight of an edge being
the cost of a direct fight. Finding the distance between two vertices in this weighted graph corresponds
to finding the minimum cost of flying from one city to another, while a shortest path is a flying route
between two cities with the lowest cost.
Definition 3.2.2 (The Weight Matrix).
Let G be a weighted graph with vertex set V (G) = {v1 , v2 , . . . , vn }. It is convenient to represent G
by means of a weight matrix W (G) defined as follows: W (G) = (wi,j ) is an n × n matrix, where
(
w(vi vj ) if vi vj ∈ E(G)
wi,j =
∞ if vi vj ∈
/ E(G).
(By ′ ∞′ we shall mean a number larger than any weight actually occurring in our calculations.) For
example, a graph and its weight matrix are shown in Figure 3.1, where the weights of edges are indicated
in the diagram.
29
Section 3.3. Dijkstra’s Algorithm Page 30
P : x = w0 , w1 , w2 , . . . , wn = v.
where wi−1 = parent(wi ) for i = 1, 2, . . . , n. We are now prepared to present Dijkstra’s algorithm.
As an example, we apply Dijkstra’s algorithm to the graph G of Figure 3.1 to determine the distance
from the vertex x = v1 to every other vertex of G and to find a shortest x − vi ) path for i = 1, 2, 3, 4.
Table 3.1 has three columns corresponding to the vertices v2 , v3 , v4 . The ordered pairs in the columns
corresponding to the vertex vi indicate (l(vi ), parent(vi )) for i = 2, 3, 4 at a given point in the algorithm.
Table 3.1
To understand how we obtained Table 3.1, let us apply Dijkstra’s algorithm to the graph G of Figure
3.1. We start by assigning to x = v1 the label l(x) = 0, and to every other vertex vi the label l(vi ) = ∞.
Initially, we set S = {x, v2 , v3 , v4 }.
We select x, since it has the smallest label among all vertices in S. The label l(x) = 0 is now the
permanent label of x. Next we examine the vertices in S adjacent to x, namely v2 , v3 , v4 . Since
l(v2 ) = ∞ > 1 = l(x) + w(xv2 ), we replace l(v2 ) by 1 and assign to parent(v2 ) the vertex x.
Furthermore, we replace l(v3 ) by l(x) + w(xv3 ) = 2 and assign to parent(v3 ) the vertex x, and we
replace l(v4 ) by l(x) + w(xv4 ) = 5 and assign to parent(v4 ) the vertex x. We then remove x from S
to obtain S = {v2 , v3 , v4 } and return to Step 2 of the algorithm.
We select v2 , since it has the smallest label among all vertices in S. The label l(v2 ) = 1 is now the
permanent label of v2 . Next we examine the vertices in S adjacent to v2 . Since l(v3 ) = 2 ≤ 5 =
l(v2 ) + w(v2 v3 ), the label l(v3 ) remains unchanged. We then remove v2 from S to obtain S = {v3 , v4 }
and return to Step 2 of the algorithm.
We select v3 , since it has the smallest label among all vertices in S. The label l(v3 ) = 2 is now the
permanent label of v3 . Next we examine the vertices in S adjacent to v3 . Since l(v4 ) = 5 > 3 =
l(v3 ) + w(v3 v4 ), we replace l(v4 ) by 3 and assign to parent(v4 ) the vertex v3 . We then remove v3 from
S to obtain S = {v4 } and return to Step 2 of the algorithm. Since |S| = 1, the algorithm terminates.
Our results may be summarized as shown in Table 3.2. Using Table 3.1 we obtain, for each i = 2, 3, 4,
the distance from x = v1 to vi and a shortest x − vi path Pi .
v d(x, v) Pi
v2 l(v2 ) = 1 x, v2
v3 l(v3 ) = 2 x, v3
v4 l(v4 ) = 3 x, v3 , v4
Table 3.2
As a second example, we apply Dijkstra’s algorithm to the graph G of Figure 3.2 to determine the
distance from the vertex x to every other vertex of G and to find the shortest x-vi path for i = 1, 2, . . . , 5.
Section 3.3. Dijkstra’s Algorithm Page 32
Table 3.3 has five columns corresponding to the vertices v1 , v2 , . . . , v5 . As in the previous example, the
ordered pairs in the column corresponding to the vertex vi indicate (l(vi ), parent(vi )) for i = 1, 2, . . . , 5
at a given point in the algorithm.
Table 3.3
Our results may be summarized as shown in Table 3.4. Using Table 3.3 we obtain, for each i = 1, 2, . . . , 5,
the distance from x to vi and a shortest x-vi path Qi .
v d(x, v) Qi
v1 l(v1 ) = 18 x, v5 , v1
v2 l(v2 ) = 13 x, v2
v3 l(v3 ) = 19 x, v5 , v1 , v3
v4 l(v4 ) = 15 x, v5 , v4
v5 l(v5 ) = 8 x, v5
Table 3.4
We now verify that on completion, Dijkstra’s algorithm has labelled the vertices with their proper
distances from x. To do this, we first prove the following tow lemmas.
Lemma 3.3.2.
At the termination of Dijkstra’s algorithm, l(v) is finite for all v ∈ V (G).
Section 3.3. Dijkstra’s Algorithm Page 33
Proof. Assume, to the contrary, that on completion of Dijkstra’s algorithm not all vertices have finite
labels. Let w be the first vertex selected from S with an infinite label. Since w was chosen as a vertex
of S with minimum label, all vertices of S when w was selected have infinite labels, while all vertices
already deleted from S have finite labels. But then there is no edge from V (G) − S to S (since if such
an edge e = uv with u ∈ V (G) − S and v ∈ S did exist, then u was selected as the current vertex
in Step 3 of the algorithm, the label l(v) of v would have dropped from ∞ to l(u) + w(uv), which is
finite). Thus there is no path from a vertex of S to a vertex of V (G) − S. Hence G is disconnected,
which produces a contradiction.
Lemma 3.3.3.
At the termination of Dijkstra’s algorithm, d(x, v) ≤ l(v) for all v ∈ V (G).
Proof. If v = x, then d(x, v) = 0 = l(v). If v = ̸ x, then by Lemma 3.3.2, l(v) is finite. Consider
the x − v path P : x = w0 , w1 , w2 , . . . , wk = v where wi−1 = parent(wi ) for i = 1, 2, . . . , k. The
k
X
path P has weight w(P ) = w(wi−1 wi ). Since wk−1 is the vertex used to label wk , we know that
i=1
l(v) = l(wk ) = l(wk−1 ) + w(wk−1 wk ). After this labelling, the vertex wk−1 is removed from S (in
Step 5), and hence its label can never change again. Repeating this backtracking search, we have
l(wk−1 ) = l(wk−2 ) + w(wk−2 wk−1 ), so l(v) = l(wk−2 ) + w(wk−2 wk−1 ) + w(wk−1 wk ). Eventually we
will backtrack to x. Thus l(v) = l(w0 ) + w(w0 w1 ) + w(w1 w2 ) + · · · + w(wk−1 wk ) = w(P ), since
l(x) = l(w0 ) = 0. Thus P has weight l(v). Since d(x, v) is the length of a shortest x − v path,
d(x, v) ≤ l(v).
This, however, contradicts the fact that v was chosen before vi+1 , so l(v) ≤ l(vi+1 ). Hence vi+1 = v
Section 3.3. Dijkstra’s Algorithm Page 34
and so
Learning Opportunities
3.1. A company has branches in each of the six cities c1 , c2 , c3 , c4 , c5 and c6 . The fare for a direct
flight from ci to cj is given by the (i, j)th entry in the matrix C (where ∞ indicates that there is
no direct flight). Use Dijkstra’s algorithm to find the cheapest route (and its length) from c1 to
all five other cities.
500 ∞ 400 250 100
0
500
0 150 200 ∞ 250
∞ 150 0 100 200 ∞
C=
400 200 100 0 100 250
250 ∞ 200 100 0 550
100 250 ∞ 250 550 0
3.2. Let G be the weighted graph in the accompanying figure. Use Dijkstra’s algorithm to compute
d(x, v) for each v ∈ V (G) and to determine the shortest x-v6 path.
3.3. Let G be the weighted graph with V (G) = {v1 , v2 , . . . , v7 } and the weight matrix W (G) as shown
below:
0 8 1 4 2 7 ∞
8 0 7 1 ∞ ∞ 4
1 7 0 ∞ 2 ∞ ∞
W (G) =
4 1 ∞ 0 ∞ 3 6
2 ∞ 2 ∞ 0 5 ∞
7 ∞ ∞ 3 5 0 4
∞ 4 ∞ 6 ∞ 4 0
Figure 4.1 shows three trees. Trees are the simplest connected graphs. These graphs are perhaps
the most useful of all special cases of graphs. Recently, there has been considerable interest in tree
structures arising in the computer sciences and in artificial intelligence. We often meet such structures
when organising data in a computer memory store or when organising the flow of information through
a system. Trees also have applications in chemistry (for example, in counting the alkanes Cn , H2n+1 ),
sociology, and many other studies. The sorting of mail according to zip code is done according to a
tree (called a decision tree). In computer programming and switching theory, we frequently deal with
decision trees with only two alternatives at each intermediate vertex. Both theory and applications of
trees will be discussed in this chapter.
36
Section 4.2. Properties of Trees Page 37
for example, any two vertices of a tree are connected by exactly one path.
Theorem 4.2.1 (Path Uniqueness).
A graph T is a tree if and only if every two distinct vertices are joined by a unique path.
Proof. If T is a tree, then by definition it is connected. Hence, any two vertices are joined by at least
one path. Suppose there are vertices u and v of T that are joined two or more different paths. Let P
and Q be two different u − v paths in T . Then there must be a vertex x (possibly x = u) on both paths
such that the vertex immediately following x on P is different from the vertex immediately following x
on Q. Let y be the first vertex of P following x that also belongs to Q (possibly y = v). Then the
section of P from x to y and the section of Q from x to y produce two x − y paths that have only x
and y in common. These paths produce a cycle in T , which contradicts the fact that T is a tree. Hence
every two distinct vertices of T are joined by a unique path.
On the other hand, suppose T is a graph in which any two distinct vertices are joined by a unique path.
This implies that T is connected. If T has a cycle containing vertices u and v, then u and v are joined
by at least two paths, contradicting our hypothesis. Hence T is acyclic so that T is a tree.
The sizes of the trees shown in Figure 4.1 are one less than their orders. We now verify this simple but
important relationship between the number of vertices and the number edges in any tree.
Theorem 4.2.2 (Size of a tree).
A tree T of order n has size m = n − 1.
Proof. We prove by induction on n. If n = 1, then T ∼ = K1 and T has size m = 0, as required. Let
k ≥ 2 be an integer, and suppose the result is true for all trees of order n < k. Let T be a tree of order
n = k and size m, let e = uv be an edge of T . Since every edge of a tree is a bridge, the graph T − e
is disconnected. In fact, T − e is a forest with exactly two components, namely a tree T1 containing u
and a tree T2 containing v. Let Ti (i = 1, 2) be a tree of order ni and size mi . Then ni < k (i = 1, 2).
Hence, by inductive hypothesis, we know that mi = ni − 1 for i = 1, 2. Since n = n1 + n2 and
m = m1 + m2 + 1 (the + 1 is for the removed edge e),
m = (n1 − 1) + (n2 − 1) + 1
= n1 + n2 − 1
= n − 1.
Thus, by induction, the size of a tree is one less than its order.
size n − 2, which is a contradiction (see Learning Opportunity 4.3). Therefore T has no cycles. Thus
(ii) =⇒ (iii).
Suppose that T has no cycles and size n − 1. In order to prove that T is a tree, we must show that T is
connected. Let T1 , T2 , . . . , Tk be the components of T (k ≥ 1), where Ti has order ni and size mi for
i = 1, 2, . . . , k. Since each component Ti (i = 1, 2, . . . , k) is a connected graph with no cycles, each Ti
is a tree. Thus, by Theorem 4.2.2, mi = ni − 1. Hence
k
X k
X k
X k
X
n−1=m= mi = (ni − 1) = ni − 1 = n − k,
i=1 i=1 i=1 i=1
Each of the trees shown in Figure 4.1 has at least two end-vertices. Using Theorem 4.2.2, we show that
this is also true in general.
Theorem 4.2.4 (Tree, End-vertices).
Every nontrivial tree contains at least two end-vertices.
Proof. Suppose that T is a tree of order n and size m, and let d1 , d2 , . . . , dn denote the degrees of
its vertices, ordered so that d1 ≤ d2 ≤ · · · ≤ dn . Since T is connected and nontrivial, di ≥ 1 for each
i (1 ≤ i ≤ n). If T does not contain at least two end-vertices, then d1 ≥ 1 and di ≥ 2 for 2 ≤ i ≤ n.
So
n
X n
X
di = d1 + di ≥ 1 + 2m = 1 + 2(n − 1) = 2n − 1.
i=1 i=2
which contradicts the previous inequality. Hence T contains at least two end-vertices.
Learning Opportunities
4.1. How many different trees (pairwise nonisomorphic) are there of order 6? Find all such trees.
4.2. Let G be a graph of order n and size n − 1. Show that G need not be a tree.
4.3. Prove that if G is a connected graph of order n and size m, then m ≥ n−1. (Hint: Use induction
on the order n of a connected graph.)
4.4. Let T be a forest of order n, size m and having k components. Show that m = n − k.
4.5. Construct a forest with 12 vertices and 9 edges.
4.6. Show that if T is a tree and e is an edge of T , then T − e has exactly two components.
4.7. Show that the sequence d1 , d2 , . . . , dn of positive integers is the degree sequence of a tree if and
n
X
only if the graph is connected and di = 2(n − 1).
i=1
Section 4.3. Constructing Minimum Spanning Trees Page 39
4.8. Let G be a graph of order n and size m with m ≥ n ≥ 3. Show that G must contain at least one
cycle.
4.9. Suppose T is a tree of order n that contains only vertices of degree 1 and 3. Prove that T contains
n−2
2 vertices of degree 3.
A connected graph may actually have several nonisomorphic spanning trees. Figure 4.2 shows a graph
G and three of its spanning trees T1 , T2 and T3 .
Every connected graph G contains a spanning tree. We can find such a spanning tree as follows: If
G has no cycles, then the graph G itself is a spanning tree. If there are cycles in G, then choose any
cycle in G and remove one of its edges. By removing one cycle edge in G, we still remain with a
connected graph. We now repeat this procedure, removing cycle edges one at a time, until finally only
bridges remain; this gives our spanning tree. So it is easy to find a spanning tree in a connected graph.
However, a much stronger statement can be made.
Definition 4.3.2 (Distance preserving).
A spanning tree T of a connected graph G is said to be distance preserving from a vertex v in G if
dT (u, v) = dG (u, v) for every vertex u.
Since G is connected, it follows that every vertex u ̸= v belongs to Di (v) for some i (1 ≤ i ≤ n).
Furthermore, such a vertex u is adjacent to at least one vertex of Di−1 (v) and possibly to vertices in
Section 4.3. Constructing Minimum Spanning Trees Page 40
Di (v) and Di+1 (v) as well. Delete all but one edge that joins u to a vertex of Di−1 (v). Also, remove
every edge joining u to a vertex of Di (v). Repeat this process for each u = ̸ v. Let T denote the
resulting graph.
From the manner in which T was constructed, it is clear that T is connected since u − v path exists for
each u ̸= v. It is also clear that T is distance-preserving from v. It remains for us to verify that T is a
tree. We only need to show that T is acyclic. If this is not the case, then there is a cycle C in T . Let w
be a vertex in C whose distance from v is maximum, and let w1 and w2 be the vertices adjacent to w
on C. Suppose w ∈ Dk . Then wi ∈ Dk or wi ∈ Dk−1 for i = 1, 2. If w1 ∈ Dk or w2 ∈ Dk , then this
contradicts the way in which T was constructed (no edge in T joins two vertices in same set Di (v)).
Thus, both w1 and w2 belong to the set Dk−1 . Once again, this contradicts the way in which T was
constructed (exactly one edge in T joins a vertex in Di to a vertex in Di−1 ). We deduce, therefore,
that T is acyclic and hence T is a tree.
Figure 4.3: A connected graph G (with vertex v) and a spanning tree T that is distance-preserving
from v.
be built along some existing roads that connect the villages with each other. We wish to erect these
telephone line in such a way that every pair of villages can communicate by telephone. Moreover, the
total number of kilometres of telephone lines is to be minimised. The problem with which we are faced
is to determine along which roads these telephone lines should be erected to produce the desired system.
This amounts to finding the a minimum spanning tree in the connected weighted graph.
A number of algorithmic solutions to the Minimum Connector Problem have been given. Perhaps the
most famous of these algorithms is one due to Kruskal [21] in 1956. The strategy of the algorithm is
very simple. We begin by choosing an edge of minimum weight that does not form a cycle with any of
the edges we have already chosen. We continue in this fashion until a spanning tree is formed.
Algorithm 4.3.5 (Kruskal).
To construct a minimum spanning tree in a connected weighted graph G, successfully choose edges
of G of minimum weight in such a way that no cycles are created.
Kruskal’s algorithm is an example of a type of algorithm known as a greedy algorithm. This name
arises from the fact that at each stage we make the greediest choice available (that is, the edge involving
the smallest weight) with no concern for what is happening else where in the graph. Algorithms of this
kind can sometimes work very well as we will show in the case of Kruskal’s algorithm. However, in
practice, the greedy approach does not always succeed.
To illustrate Kruskal’s algorithm, we find a minimum spanning tree in the connected weighted graph G
shown in Figure 4.4.
Fifth Choice: We cannot now include eg in the tree, since it would create a cycle (c, d, e, g, c). The
edge of next smallest weight is dg with weight 4. Since this edge would create a cycle (c, d, g, c), we
choose instead one of the edges ab, ag, or af with weight 6. Let us choose ag.
Sixth Choice: The edges of next smallest weight are ab and af with weight 6. Since ab would create
a cycle (a, b, c, g, a), we choose af .
This completes the spanning tree T , since the addition of any further edge would create a cycle. The
tree T (shown in Figure 4.5) is a minimum spanning tree of weight
w(T ) = w(de) + w(bc) + w(cg) + w(cd) + w(ag) + w(af )
=1+2+2+3+6+6
= 20.
It is clear that Kruskal’s algorithm will produce a spanning tree of any connected weighted graph to
which it is applied. It is not obvious, though, that it produces a minimum spanning tree. This requires
a proof.
Theorem 4.3.6 (Kruskal).
Kruskal’s algorithm produces a minimum spanning tree in a connected weighted graph.
Proof. Let G be a nontrivial connected weighted graph of order n, and let T be the subgraph produced
by Kruskal’s algorithm. By the way in which T was constructed, it has no cycles. Also, T is connected,
since otherwise we could add another edge of G without creating a cycle. Also, T contains every vertex
of G, since if it did not contain some vertex, then we could ass an edge incident with that vertex without
creating a cycle. Therefore, T is a spanning tree of G (and so has size n − 1 by Theorem 4.2.2). Let
E(T ) = {e1 , e2 , . . . , en−1 },
where e1 , e2 , . . . , en−1 is the order in which the edges were chosen, so w(e1 ) ≤ w(e2 ) ≤ · · · ≤ w(en−1 ).
Therefore, the weight of T is
n−1
X
w(T ) = w(ei ).
i=1
Section 4.3. Constructing Minimum Spanning Trees Page 43
We must show that T is a minimum spanning tree of G. We do this by contradiction. Suppose, the
contrary, that T is not a minimum spanning tree of G. Then, among all the minimum spanning trees
of G, choose one, call it T ∗ , which has a maximum number of edges in common with T . Since T is not
a minimum spanning tree, the trees T and T ∗ are not identical. So T has at least one edge that does
not belong to T ∗ . Using the ordering on the edges of T , we let ei (1 ≤ i ≤ n − 1) be the first edge of
T that is not in T ∗ . If we now insert the edge ei into T ∗ , we get a graph H that is not in T . We now
consider the graph T0 = H − e. Since e is not a bridge of H, the graph T0 is connected and has size
n − 1. Hence, by Theorem 4.2.3, the graph T0 is also a spanning tree of G and
Since w(T ∗ ) ≤ w(T0 ), it follows that w(e) ≤ w(ei ). However, by the manner in which T was con-
structed, ei is an edge of smallest weight which can be added to the edges e1 , e2 , . . . , ei−1 without
creating a cycle. However, since all the edges e1 , e2 , . . . , ei−1 and e come from the tree T ∗ , we note
that if e is added to the edges e1 , e2 , . . . , ei−1 , then no cycle is produced. Thus, we have w(ei ) ≤ w(e),
so w(ei ) = w(e). Hence, w(T0 ) = w(T ∗ ), which implies that T0 is also a minimum spanning tree of
G. But T0 has more edges in common with T than does T ∗ . This contradicts our choice of T ∗ . We
deduce, therefore, that T is a minimum spanning tree of G.
Learning Opportunities
4.10. Apply Kruskal’s algorithm to find a minimum spanning tree in the weighted graph G shown below.
Section 4.3. Constructing Minimum Spanning Trees Page 44
4.11. Apply Kruskal’s algorithm to find a minimum spanning tree in the weighted graph H shown below.
4.12. Let G be a connected weighted graph whose edges have distinct weights. Show that G has a
unique spanning tree.
5. Eulerian Graphs
5.1 Introduction
Probably the oldest and best known of all problems in graph theory is the problem of the seven Königsberg
bridges.
The Königsberg bridges problem. In the eighteenth century, the medieval city of Königsberg in
Eastern Prussia contained a central island called Kneiphof, around which the river Prigel flowed before
dividing into two. The four parts of the city were interconnected by seven bridges, as shown in Figure
5.1. The legend says that the citizens of Königsberg amused themselves by trying to find a route crossing
each bridge exactly once, and returning to the starting point. Can this be done?
Try as they might, the citizens of Königsberg could find no route crossing each bridge exactly once
and returning to the starting point, and they all came to believe that such a route was not possible.
However, it was not until Leonard Euler [10] investigated the problem that it was proved to be impossible.
Although Euler’s proof in 1736 was not written in the language of graphs, the ideas in it are essentially
graph-theoretical in nature. Before proceeding further, we introduce the concept of a multigraph.
Definition 5.1.1 (Multigraph).
A A Multigraph is a graph in which one allows more than one edge (but a finite number) to join pairs
of vertices.
We can now express the Königsberg bridges in terms of a multigraph by taking the four land areas
as vertices and the seven bridges as edges joining the corresponding pairs of vertices. This gives the
45
Section 5.2. Eulerian Graphs Page 46
multigraph M shown in Figure 5.2. The Königsberg bridges problem is now reduced to determining
whether the multigraph M has a trail that contains all its edges.
We use Euler’s reasoning to show why such a trail does not exist in M . Suppose, to the contrary, that
M contains a trail T . Then T can be represented by a sequence of eight letters (from {A, B, C, D}),
in which each pair of consecutive letters in the sequence represents an edge. Since five five bridges
lead to region A, Euler observed that the letter A has to appear at least three times-twice to indicate
entrance to and exit from region A. Similarly, since T accounts for all edges of M , each of the letters
B, C, and D must appear at least twice in the sequence. However, this means that at least nine letters
are needed in the sequence, which produces a contradiction. Thus our assumption that T exists must
be false. The townfolk’s suspicion that no walk through Königsberg would traverse each bridge exactly
once was therefore well-founded.
The graph H of Figure 5.3 is eulerian since it contains an eulerian circuit (for example, C : a, e, b, c, d, e,
f, g, h, i, g, j, k, e, g, k, f, j, e, l, a). Note, however, that H does not contain an eulerian trail. The graph
G of Figure 5.3 has an eulerian trail T : u, v, w, x, v, z, x, y, z, but no eulerian circuit.
Section 5.2. Eulerian Graphs Page 47
The rule that Euler presented (in different terminology) is: to test whether a given connected (multi)graph
is eulerian, look at the degrees of vertices: if they are all even, then the graph is is eulerian; if not, then
the graph is not eulerian. That is, a necessary condition for a graph to be eulerian is that every vertex
has even degree. In Euler’s original paper [10] he stated that this condition is also sufficient. However,
the first published proof of the result was given by Hierholzer [18] in 1873.
It follows from Theorem 5.2.2 and Theorem 5.2.3 that the multigraph of Figure 5.2 contains neither an
eulerian trail nor an eulerian circuit.
Learning Opportunities
5.1. In present day Königsberg (Kalingrad), there are two additional bridges, one between regions B
and C, and one between regions B and D. Is it now possible to devise a route over all bridges of
Königsberg without crossing any of them?
5.2. Show how the citizens of Königsberg could have built two new bridges in such a way that they
could have taken their tour and returned to their starting point.
5.3. For what positive integers n are the following graphs eulerian?
5.3.1. Cn
5.3.2. Kn
5.3.3. Km,n
5.4. Decide whether each of the following graphs has an eulerian circuit, eulerian trail, or neither.
5.5. Show that if a multigraph G has 2k vertices of degree, then the smallest number of continuous
penstrokes needed to covert all the edges of G is k.
Section 5.3. Fleury’s Algorithm Page 49
This algorithm is very easy to apply. At each stage, we choose a bridge only as a last resort. The
postponing of the use of bridges is really the critical feature of this algorithm. This feature is clearly
essential, since once we have traversed a bridge, we cannot return to the part of the graph we have just
left.
We illustrate the use of Fleury’s algorithm by applying it to the graph of Figure 5.4(a).
Figure 5.4
Starting at x, we may choose the edge xa, followed by ab. Erasing the edges (and the vertex a) gives
us the graph shown in Figure 5.4(b). We cannot use the edge bx since it is a bridge, so we may choose
the edge bc, followed by cd and db. Erasing these edges (and the vertices c and d) gives the graph
shown in Figure 5.4(c). Now there is no alternative–we have to traverse the bridge bx. Traversing the
Section 5.4. The Chinese Postman Problem Page 50
Learning Opportunities
5.6. Using Fleury’s algorithm, find an eulerian circuit in the accompanying graph G.
postman needs to visit some parts of the route more than once, and wants to minimize the amount of
retracing.
Similar problems have arisen in other contexts. For example, there was a major study of snow-clearing
routes in Zurich some years ago. Since snow-clearing equipment is expensive to operate, it was necessary
to arrange a route which involved reclearing streets as little as possible. Other cities have initiated similar
investigation into the sweeping or cleaning of the streets.
If the graph under consideration is not an eulerian graph, then the Chinese postman problem can be
solved by a good algorithm provided by Edmonds and Johnson. However, their algorithm is too involved
to present here. To get an idea of what is involved, we consider the particular case of a graph with just
two odd vertices of odd degree.
Suppose that G is a connected weighted graph with exactly two vertices u and v of odd degree. Let
T be a tour of G. For each edge e of G, let m(e) + 1 be the number of times T traverses the edge e
(where we may have m(e) = 0). WE now form a new graph G∗ from G as follows: Let G∗ be obtained
from G by joining the ends of the edge e by m(e) new edges of weight w(e) for each edge e of G with
m(e) > 0. Now T may be transformed into an eulerian circuit T ∗ of G∗ : if an edge e needs to be
traversed n times by T in G, then there are n copies of this edge in G, and so we may replace each
occurrence of e in T by one of the n edges in such a way that none of them is repeated in T ∗ .
So G∗ is an eulerian graph. Thus by Theorem 5.2.2, every vertex of G∗ has even degree. But u and v
have odd degree in G. Hence at least one new edge incident with u, and at least one edge incident with
v, must have been added to G to produce G∗ . Let E ∗ be the set of edges of G8 that do not belong
to G, so E ∗ = E(G∗ ) − E(G). WE now consider the subgraph H formed by the edges in E ∗ . (So the
edge set of H is E ∗ , and the vertex set of H consists of those vertices that are incident with some edge
in E ∗ .) Necessarily, each of u and v is in H. Observe that for each vertex w of H, the degree of w in
H is given by
Furthermore, degG∗ w is even and if w is distinct from u and v, then degG w is even, while degG w is
odd if w = u or w = v. It follows that u and v are the only vertices of H of odd degree. This means
(see Corollary 1.5.4) that u and v must lie in the same component of H. Hence u and v are connected
by a u-v path P ∗ (say) in H. (Note that this path P ∗ consists solely of new (duplicated) edges of G.)
Now
X X
w(T ) = w(e) + w(e)
e∈E(G) e∈E(G∗ )
w(e) + w(P ∗ )
X
≥
e∈E(G)
X
≥ w(e) + w(P ),
e∈E(G)
X
where P is a shortest u-v path in G. Thus, w(e) is a minimum when G∗ is obtained from G by
e∈E(G∗ )
duplicating each of the edges on a shortest u-v path in G. (In other words, the best situation would be
for H to contain a shortest u-v path and nothing else.) Thus T is an optimal tour if it is an eulerian
circuit of the graph G∗ obtained from G by duplicating each of the edges on a shortest u-v path.
Section 5.4. The Chinese Postman Problem Page 52
We illustrate the use of Algorithm 5.4.2 by applying it to the graph of Figure 5.5.
Figure 5.5
Observe that G has exactly two vertices of odd degree, namely a and b. We apply Dijkstra’s algorithm to
determine a shortest a-b path in G. Table 5.1 given below has four columns corresponding to the vertices
b, c, d, e. The ordered pairs in the columns corresponding to the vertex v indicate (ℓ(v), parent(v)) at
a given point in the algorithm.
Table 5.1
On applying Dijkstra’s algorithm, we find that d(a, b) = 6 and that P : a, d, c, b is a shortest a-b path
in G. We now for the multigraph G∗ by duplicating the edges ad, dc, and cb in the graph G of Figure
5.5. The multigraph G∗ is shown in Figure 5.6.
Section 5.4. The Chinese Postman Problem Page 53
Figure 5.6
We now apply Fleury’s algorithm to the eulerian multigraph G∗ shown in Figure 5.6. Starting at a,
we may choose the edge e1 = ae, followed by e2 = ed(a bridge, but there is no alternative), e3 = da,
e4 = ad, and e5 = db. We now cannot use the edge ba since it is a bridge, so we may choose one of
the edges bc, say e6 = bc. Since cb is a bridge of the resulting graph, we must traverse cd, say e7 = cd.
Traversing the path d, c, b, a completes the eulerian circuit, so we choose e8 = dc, e9 = cb and e10 = ba.
The circuit T ∗ is therefore
T : a, e1 , e, e2 , d, e3 , a, e4 , d, e5 , b, e6 , c, e7 , d, e8 , c, e9 , b, e10 , a
T : a, e, d, a, d, b, c, d, c, b, a
Learning Opportunities
5.7. Use Algorithm 5.4.2 to find optimal tours in weighted graphs G and H shown in the accompanying
figure.
6. Planar Graphs
6.1 Introduction
In this chapter, we consider graphs that can be drawn in the plane without their edges crossing. Such
graphs we call planar graphs.
Definition 6.1.1 (A Planar Graph).
A planar graph is a graph that can be drawn in the plane in such a way that no two edges meet each
other except at a vertex to which they are both incident. A graph that is drawn in the plane is said to
be embedded in the plane. A planar graph that is embedded in the plane is called a plane graph.
The graph G ≡ K4 of Figure 6.1(a) is drawn with intersecting edges. Nevertheless, G is a planar graph
because it can be drawn in the plane without any of its edges intersecting. Figure 6.1(b) shows G
redrawn with no edges crossing. Thus, the graph of Figure 6.1(a), though planar, is not a plane graph.
On the other hand, the graph of Figure 6.1(b) is a plane graph. The drawing of a planar graph in the
plane is not unique. Indeed, a given planar graph can give rise to several different plane graphs.
Planar graphs have many practical applications, such as to circuit layout problems. In the design of
electronic chips, we wish to locate several nodes on a circuit board (a flat board of insulating material)
and connect certain pairs of these nodes by electrical wires (or conducting strips) printed directly onto
the circuit board. The electrical wires may not cross, since this would lead to undesirable electrical
contact at crossing points. Can we connect the nodes in such a way that no two of the connecting wires
cross? In graph theory terms, the problem is to determine whether the graph associated with the circuit
(where vertices represent nodes, and edges correspond to electrical wires connecting pairs of nodes) is
planar.
Another area where planar graphs are important is in utility problems. Suppose, for example, we have
three houses and three utilities, namely, electricity, gas, and water. Is it possible to connect each utility
with each of the three houses without the utility lines crossing? This well-known problem is referred to
as the Three Houses and Three Utility Problem. This situation can be represented by the complete
bipartite graph K3,3 .
55
Section 6.2. Properties of Planar Graphs Page 56
So the Three Houses and Three Utility Problem can be restated in graph theory terms: Is K3,3 a planar
graph? We will return to question once we have established a few basic results about planar graphs.
We close this introduction to planar graphs with the following poem:
In Central Spain, in mainly rain
Three houses stood upon the plain
The houses of our mystery
To which, from realms of industry
Came wires with power light and heat
And pipes with gas to cook their meat
And other pipes with water sweet.
To illustrate these concepts, consider the plane graph G of Figure 6.3. The plane graph G has five
regions, labelled R1 , R2 , . . . , R5 . The boundary of R1 consists of four vertices v1 , v2 , v8 , v9 , and four
edges v1 v2 , v2 v9 , v9 v8 , v8 v1 . The boundary of the exterior region consists of all the vertices of G, except
v9 , and the eight edges v1 v2 , v2 v3 , v3 v4 , v3 v5 , v5 v6 , v6 v7 , v7 v8 and v8 v1 . Observe that each cycle edge
belongs to the boundary of two regions, while each bridge is on the boundary of only one region.
The plane graph G of Figure 6.3 has n = 9 vertices, m = 12 edges, and r = 5 regions. Thus, the graph
G satisfies n − m + r = 2. This equality always hold in a connected plane graph. This well-known
formula was discovered by Euler [10] in 1752, and it is a classical result of graph theory.
n − m + r = 2.
Proof. We proceed by induction on m. If m = 0, then G ≡ K1 ; so n = 1, r = 1 and n − m + r = 2.
Thus, the result is true if m = 0. Assume that the result holds for all connected plane graphs with fewer
than m edges, where m ≥ 1, and let G be a connected plane graph with m edges. Suppose that G has
n vertices and r regions. We show that n − m + r = 2. If G is a tree, then r = 1 and, by Theorem
4.2.2, m = n − 1, so n − m + r = n − (n − 1) + 1 = 2, and we have the desired formula. On the other
hand, if G is not a tree, then G contains a cycle edge e. Then G − e is a connected plane graph with
n vertices and m − 1 edges. Furthermore, the two regions incident with e in G produce one region in
Section 6.2. Properties of Planar Graphs Page 58
n − (m − 1) + (r − 1) = 2,
or, equivalently, n − m + r = 2.
It follows from Theorem 6.2.2 that no matter how a connected planar graph is embedded on the plane,
the number of regions of the resulting plane graph is always the same. Thus one can speak of the
number of regions of a planar graph. Our next result shows that a planar graph on a fixed number n of
vertices cannot have too many edges.
Theorem 6.2.3.
If G is a planar graph with n ≥ 3 vertices and m edges, then
m ≤ 3n − 6.
Proof. Consider an embedding of G in the plane (as a plane graph), resulting in r regions. Every edge
lies on the boundary of either one or two regions. Therefore, if the number of edges on the boundary
of a region is summed over all the regions, the result is at most 2m. However, the boundary of every
region contains at least three edges, so such a sum is a least 3r. Hence, 3r ≤ 2m, or r ≤ 2m
3 . Applying
Theorem 6.2.2, we obtain
2m m
2=n−m+r ≤n−m+ =n− .
3 3
Therefore, m ≤ 3n − 6.
We are now in a position to return to our question of whether or not the graph K3,3 is planar.
Theorem 6.2.4.
The graph K3,3 is nonplanar.
Proof. Assume, to the contrary, that K3,3 is planar. Consider any embedding of K3,3 on the plane,
resulting in r regions. Since K3,3 is a bipartite graph, it has no triangles; so the boundary of every region
contains at least four edges. Let x be the number of edges on the boundary of a region summed over all r
regions. Then x ≥ 4r. However, since K3,3 contains no bridges, every edge lies on a boundary of exactly
two regions. Thus, the sum x counts each edge twice; that is, x = 2m = 18. Therefore, 4r ≤ x = 18,
or, equivalently, r ≤ 29 . Thus, r ≤ 4. However, by Theorem 6.2.2, r = 2 + m − n = 2 + 9 − 6 = 5.
This produces a contradiction. We deduce, therefore, that K3,3 is nonplanar.
Theorem 6.2.5.
The graph K5 is nonplanar.
Proof. Assume, to the contrary, that K5 is planar. Since K5 has n = 5 vertices and m = 10 edges,
10 = m > 3n − 6 = 9,
We close this subsection wit a well-known characterization of planar graphs due to Kuratowski. For this
purpose, we define a relation on a graph called a subdivision.
Section 6.2. Properties of Planar Graphs Page 59
We are now in a position to state Kuratowski’s Theorem. However, we omit the proof which is too
involved and lengthy to present here.
Theorem 6.2.7 (Kuratowski’s Theorem).
A graph is planar if and only if it contains no subgraph that is isomorphic to a subdivision of K5 or
K3,3 .
Learning Opportunity
6.1. Suppose the Three Houses and Three Utilities problem were the Four Houses and Two Utilities
problem. What would the solution be?
6.2. Show that the graph K2,n is planar for every positive integer n.
6.3. For the plane graph G in the accompanying figure, determine the vertices and the edges of the
boundary of the exterior region.
Section 6.3. The Four Colour Problem Page 60
6.4. Show that the graph obtained from K5 by removing an edge is planar.
6.5. For which values of n is the complete graph Kn planar?
6.6. Prove or disprove: If G is a connected graph on n vertices and m edges with m = 3n − 6, then
G is planar.
6.7. .
6.7.1. Show that if a shortest cycle in a planar graph with n vertices and m edges has length k,
then
k(n − 2)
m≤ .
k−2
6.7.2. Deduce that a planar bipartite graph of order n ≥ 4 has at most 2n − 4 edges.
6.7.3. Use this result to show that K3,3 is nonplanar.
6.8. Prove that if a graph G and its complement G are both planar, then G has at most 10 vertices.
We now return to the Four Colour Problem. With each map, we can associate a graph G whose vertices
correspond to the countries, and where two vertices are adjacent if the corresponding countries are
adjacent. Such a graph G is a planar graph. The Four Colour Problem can thus be restated as follows:
Theorem 6.3.2 (The Four Colour Theorem).
Every planar graph is 4-colourable.
Although the Four Colour Problem is difficult to solve, Heawood [17] was able to prove the Five Colour
Theorem with surprising ease. To prove this theorem, the following result is useful.
Theorem 6.3.3.
Every planar graph contains a vertex of degree at most 5.
Proof. Let G be a planar graph with n vertices and m edges, and with V (G) = {v1 , v2 , . . . , vn }. If
n ≤ 6, then the degree of every vertex is at most 5. So we may assume that n ≥ 7. By Theorem 6.2.3,
m ≤ 3n − 6. Therefore,
n
X
deg vi = 2m ≤ 6n − 12.
i=1
Figure 6.5
Suppose there is no v1 -v3 path in G − v all whose vertices are coloured 1 or 3 (see Figure 6.5(a)). Let
H be the subgraph consisting of all paths that start at v1 all whose vertices are coloured 1 or 3. Then
v3 does not belong to H. Moreover, no vertex adjacent to v3 is in H. We now interchange the colours
of the vertices of H. This produces a new 5-colouring of G − v in which both v1 and v3 are coloured
with colour 3. Thus, we may assign colour 1 to v produce a 5-colouring of G.
On the other hand, suppose there is a v1 -v3 path P in G − v all whose vertices are coloured 1 or 3
(see Figure 6.5(b)). The path P together with the path v3 , v, v1 produces a cycle in G which either
encloses v2 or encloses v4 and v5 . Hence there does not exist a v2 -v4 path in G − v all whose vertices
are coloured 2 or 4. Let F be a subgraph consisting of all paths that start at v2 all of whose vertices are
coloured 2 or 4. This subgraph does not contain v4 or any vertex adjacent with v4 Interchanging the
colours of the vertices of F produces a new 5-colouring of G − v in which both v2 and v4 are coloured
with colour 4. Thus, we may assign colour 2 to v to produce a 5-colouring of G.
Learning Opportunities
6.9. What is the smallest order of a graph that is 4-colourable?
6.10. Show that there exists a planar graph that contains no vertex of degree 4 or less.
6.11. Show that every planar graph of order at least 2 contains at least two vertices of degree 5 or less.
7. Hamiltonian Graphs
7.1 Introduction
In this chapter, we turn our attention to hamiltonian graphs – graphs in which there is a cycle passing
through every vertex. The name “hamiltonian” is derived from a game invented by the famous Irish
mathematician Sir William Rowan Hamilton. In 1867, Hamilton introduced a game consisting of a solid
regular dodecahedron (see Figure 7.1) made of wood, twenty pegs (one inserted at each vertex), and a
supply of string. Every vertex was given a name of an important city of the time – Brussels, Canton,
Delhi, . . . , Zanzibar. The aim of the game called “A Voyage Round the World”, was to find a route
along the edges of a dodecahedron that visits each city exactly once and that ended at the city where
it began. In order for the player to keep track of the cities visited, the player used the string to join the
pegs in the order in which the route was traversed. Hamilton sold the idea of his game to a wholesale
dealer of game and puzzles for £25. However the game did not prove to be very popular, possibly
because a desired route is easy to find.
The above game suggests the graphical concept which we term as “hamiltonian”.
Definition 7.1.1 (Hamiltonian Cycle, Hamiltonian Graph, Hamiltonian Path).
A cycle of a graph G containing every vertex of G is called a hamiltonian cycle. A hamiltonian
graph is a graph possessing a hamiltonian cycle. A path of G containing every vertex of G is called a
hamiltonian path.
Thus, A Voyage Round the World game asks the player to find a hamiltonian cycle in a graph of the
dodecahedron. An earlier example of a problem which can be expressed in terms of hamiltonian cycles
is the knight’s tour problem.
Knight’s Tour Problem. Can a knight visit each square of a standard 8 × 8 chessboard exactly once
by a sequence of knight’s moves, and finish on the same square as it began?
In order to see the connection between this problem and that of finding hamiltonian cycles in graphs,
note that the knight’s tour problem can be represented by a graph in which each vertex corresponds
to a square of the chessboard, and edges correspond to those pairs of squares connected by a knight’s
63
Section 7.2. Which Graphs Are Hamiltonian? Page 64
move. The resulting graph, which has order 64 and size 186, actually contains several hamiltonian
cycles. Figure 7.2 illustrates one such knight’s tour on a standard 8 × 8 chessboard.
Proof. If n = 3, then δ(G) ≥ 2. This implies that G ≡ K3 and, hence, G is hamiltonian. So we may
assume that n ≥ 4, for otherwise there is nothing left to prove.
Let P : v1 , v2 , . . . , vp be a longest path in G. Then every vertex adjacent to v1 lies on P and every
vertex adjacent to vn lies on P ; otherwise there would be a longer path than P . Hence,
n
p = |V (P )| ≥ deg v1 + 1 ≥ δ(G) + 1 ≥ + 1.
2
We show that there must exist some vertex vi , where 2 ≤ i ≤ p, such that v1 is adjacent to vi , and vp
is adjacent to vi−1 . If this is not the case, then, whenever v1 is adjacent tp a vertex vi , the vertex vp
is not adjacent to vi−1 . Since at least n2 vertices are adjacent to to v1 , at least n2 of the n − 1 vertices
different from vp are not adjacent to vp . Hence,
Section 7.2. Which Graphs Are Hamiltonian? Page 65
n n
deg vp ≤ |V (P ) − {vp }| − deg v1 ≤ (n − 1) − <
2 2
which contradicts the fact that deg vp ≥ δ(G) ≥ n2 . Hence, as claimed, there must exist some vertex
vi (2 ≤ i ≤ p) adjacent to v1 with vi−1 adjacent to vp . Thus, G has a cycle
that contains all the vertices of P . We show that C is a hamiltonian cycle of G. If this is not the
case, then there is some vertex u of G that does no belong to C. By hypothesis, deg u ≥ n2 . Since P
contains p ≥ n2 + 1 vertices, there are fewer than n vertices not on C. So u must be adjacent to some
vertex v that lies on C. However, the edge uv together with the cycle C contain a path whose length
exceeds that of P , which contradicts our choice of P . Hence C contains all the vertices of G. Thus, G
is hamiltonian.
The sufficient condition in Theorem 7.2.1 is not necessary condition for a graph to be hamiltonian. For
example, the cycles Cn (n ≥ 5) are hamiltonian but have minimum degree 2, which is less than n2 .
Many other hamiltonian graphs cannot be shown to be hamiltonian using Theorem 7.2.1.
A corresponding degree condition to that presented in Theorem 7.2.1 also exists to prove that a graph
has a hamiltonian path.
Corollary 7.2.2.
n−1
Let G be a graph of order n. If δ(G) ≥ 2 , then G contains a hamiltonian path.
Proof. If n = 1, then G ≡ K1 , and G contains a (trivial) hamiltonian path. So we may assume that
n ≥ 2, for otherwise there is nothing left to prove. Let H be the graph obtained from G by adding a
new vertex v and joining v with an edge to every vertex of G. Then H has order n + 1, so v has degree
n in H. Moreover, for every vertex u of G,
If G is a bipartite hamiltonian graph with partite sets V1 and V2 , then it follows that |V1 | = |V2 | (see
Learning Opportunity 7.5). Corollary 7.2.2 extents Dirac’s Theorem 7.2.1 to this class of graphs.
Theorem 7.2.3.
n
Let G be a bipartite graph with partite sets V1 and V2 such that |V1 | = |V2 | = n ≥ 2. If δ(G) > 2,
then G is hamiltonian.
Proof. Assume, to the contrary, that the theorem is false. Then there exists a nonhamiltonian bipartite
graph G satisfying the hypothesis of the theorem. Let G be maximal such graph; that is, G is a
nonhamiltonian bipartite graph but the addition of any edge between the two partite sets would make it
hamiltonian. Since Kn,n is hamiltonian, the graph G must contain a pair u, v of nonadjacent vertices
with u ∈ V1 and v ∈ V2 .
Section 7.3. The Closure Function Page 66
The maximality of G implies that G + uv has a hamiltonian cycle, which must contain the edge uv.
Hence, G contains a hamiltonian u-v path
P : u = v1 , v2 , . . . , v2n = v,
is a hamiltonian cycle of G (which would contradict the fact that G is nonhamiltonian). Hence for each
vertex of {v2 , v4 , . . . , v2n } adjacent to v1 , there is a vertex of {v1 , v3 , . . . , v2n−1 } not adjacent to v2n .
Thus,
n n
deg v2n ≤ n − deg v1 < n − = ,
2 2
which contradicts the hypothesis.
Learning Opportunities
7.1. Prove that it is not possible for a knight to tour a 4 × 4 chessboard, visit each square exactly
once, and return to the initial square.
7.2. Prove that if n is odd, then it is not possible for a knight to tour an n × n chessboard, visit each
square exactly once, and return to the initial square.
7.3. Prove that Kn,n+1 is hamiltonian for every positive integer n.
7.4. Use 7.3. to show that lowering the bound of Theorem 7.2.1 from n2 to n2 − 1 will not guarantee
that the graph G is hamiltonian. (Thus, the bound n2 in Theorem 7.2.1 is “sharp”.)
7.5. Show that if G is a hamiltonian bipartite graph with partite sets V1 and V2 , the |V1 | = |V2 |.
7.6. Show that the bouind presented in Theorem 7.2.3 is sharp by finding a class of nonhamiltonian
bipartite graphs G with partite sets V1 and V2 such that |V1 | = |V2 | = n ≥ 2 and δ(G) ≥ n2 .
7.7. A mouse eats his way through a 3 × 3 × 3 cube of cheese, tunnelling through all 27 of the 1 × 1 × 1
cubes. If the mouse starts at a corner, can he finish at the centre?
We show that there must exist some vertex vi , where 2 ≤ i ≤ p, such that v1 vi ∈ E(G), and vi−1 vp ∈
E(G). If this is not the case, then, whenever v1 vi ∈ E(G), 2 ≤ i ≤ p), we have vi−1 vp ∈ / E(G). Hence
for each vertex of {v2 , v3 , . . . , vp } adjacent ot v1 there is a vertex of {v1 , v2 , . . . , vp−1 } not adjacent to
vp . Thus, deg un ≤ (n − 1) − deg ui so that
deg u + deg v ≤ n − 1,
which is a contradiction. Hence there must exist some vertex vi (2 ≤ i ≤ p) such that v1 vi ∈ E(G),
and vi−1 vp ∈ E(G). Thus,
v1 , vi , vi+1 , . . . , vp , vi−1 , vi−2 , . . . , v2 , v1
is a hamiltonian cycle of G and G is hamiltonian.
Our next theorem is a simple consequence of the definition and Theorem 7.3.3.
Theorem 7.3.4.
A graph is hamiltonian if and only if its closure is hamiltonian.
Proof. If we apply Theorem 7.3.4 every time an edge is added in the formation of the closure, then we
see that a graph G is hamiltonian if and only if c(G) is hamiltonian.
Since each complete graph with at least three vertices is hamiltonian, we obtain the following sufficient
condition, due to Bondy and Chvátal, for a graph to be hamiltonian.
Corollary 7.3.5.
Let G be a graph of order n ≥ 3. If c(G) ≡ Kn , then G is hamiltonian.
Corollary 7.3.7.
Let G be a graph of order n ≥ 3 and size m. If
!
n−1
m≥ + 2,
2
then G is hamiltonian.
Proof. If G is complete, then G is hamiltonian. So we may assume that G is not complete and that
G satisfies the hypothesis of the corollary. Let u and v be two distinct nonadjacent vertices of G, and
define H = G − {u, v}. Then m(G) = m(H) + deg u + deg v. So, since
!
n−2
m(H) ≤ m(Kn−1 ) = ,
2
it follows that
! !
n−1 n−2
deg u + deg v = m(G) − m(H) ≥ +2− = n.
2 2
Learning Opportunities
7.8. Let u and v be distinct nonadjacent vertices of a graph G of order n ≥ 3 such that deg u+deg v ≥
n − 1. Prove or disprove: The graph G has a hamiltonian path if and only if G + uv has a
hamiltonian path.
7.9. Prove that if G is a hamiltonian graph, then for every proper nonempty subset S of the vertices
of G, k(G − S) ≤ |S|.
Section 7.3. The Closure Function Page 69
7.10. Decide whether each of the following graphs has a hamiltonian cycle, a hamiltonian path, or
neither.
7.11. Show that if a graph of order at least 3 has an isolated vertex, then its closure is not complete.
7.12. Show that the bound presented in Corollary 7.3.6 is sharp by finding a a class of nonhamiltonian
graphs of order n ≥ 3 such that deg u + deg v ≥ n − 1 for all pairs u, v of nonadjacent vertices
of G.
7.13. Show that the bound presented in Corollary 7.3.7 is sharp by finding a nonhamiltonian graph of
order n ≥ 3 with n−1
2 + 1 edges.
7.14. Let G be a bipartite graph with partite sets V1 and V2 such that |V1 | = |V2 | = n ≥ 2. Let u and
v be nonadjacent vertices of G with u ∈ V1 and v ∈ V2 such that deg u + deg v > n. Show that
G is hamiltonian if and only if G + uv is hamiltonian.
7.15. Define the bipartite closure of a bipartite graph with partite sets V1 and V2 such that |V1 | =
|V2 | = n ≥ 2. Show that the bipartite closure is unique.
8. Networks
8.1 Introduction
You are designing an oil pipeline. Oil is to be pumped from an unloading point s to a refinery t. To
minimize the possibility that pipe repairs will completely halt the flow of oil, there will be several routes.
There will be four stations u, v, x and y along the pipelines, which are linked as shown in Figure 8.1.
The arrows indicate the directions in which oil can flow and the capacities of the section of pipelines
are indicates (in 1000 barrels of oil per hour). The question we are faced with is to determine what is
the maximum volume of oil can be pumped into the system (through s) per hour? In the section, we
shall develop a method of solving problems of this type.
Figure 8.1
8.2 Digraphs
Although many problems lend themselves to a graph-theoretic formulation, the concept of a graph is
sometimes not quite adequate. When dealing with problems of traffic flow, for example, it is necessary
to show which roads are one-way, and in which direction traffic is permitted. We may deal with problems
involving flow in information or water, transport of some commodity, etc. To deal with such problems,
what we need is a graph in which every edge has been assigned a direction – “a digraph”. The terminology
used for digraphs is quite similar to that used for graphs.
Definition 8.2.1 (Digraph).
A digraph (or directed graph) D is a finite set of objects, called vertices, together with a (possibly
empty) set of ordered pairs of distinct vertices of D, called arcs (or directed edges). As with graphs,
the vertex set of D is denoted by V (D) and its arc set by E(D). If D has vertex set V and arc set E,
we write D = (V, E). The cardinality of the vertex set of D is called the order of D and is denoted
by n(D), or simply n, while the cardinality of its arc set is called its size, and is denoted by m(D), or
simply m.
As with graphs, digraphs can be represented by diagrams. The vertices of a digraph D are indicated by
70
Section 8.2. Digraphs Page 71
small circles, and an arc (uv) of D is represented by a curve or line segment directed by an arrow-head
from vertex u to vertex v. Since (u, v) and (v, u) are distinct arcs, two vertices can be joined by two
arcs if they have opposite direction.
Definition 8.2.2 (Underlying Graph).
With each digraph D, we can associate a graph G (on the same vertex set) called the underlying
graph of D that is obtained from D by deleting all directions from the arcs of D (equivalently, replacing
each arc (u, v) by the edge uv) and deleting an edge from a pair of multiple edges if multiple edges
should be produced.
A digraph D with V (D) = {u, v, w, x} and arc set E(D) = {(u, v), (v, u), (v, w), (x, v), (x, w)} is
shown in Figure 8.2 along with the underlying graph G of D.
Definition 8.2.3.
If (u, v) is an arc of D, then we say that u is adjacent to v, and v is adjacent from u. Further, the
arch (u, v) is incident from u and incident to v. The outdegree, denoted od(v), of a vertex v in
D is the number of vertices adjacent from v, and the indegree, denoted id(v), of v is the number of
vertices adjacent to v. The degree, denoted deg v, of v is defined by deg v = od(v) + id(v).
The outdegrees, indegrees, and degrees of the vertices of the digraph D of Figure 8.2 are given in Table
8.1
Table 8.1
Section 8.3. An Introduction to Networks Page 72
Definition 8.2.4.
For a vertex v in a digraph D, we define the out-neighborhood of v by the set N + (v) = {u ∈ V (D) |
(v, u) ∈ E(D)}. The in-neighborhood of v is defined by the set N − (v) = {u ∈ V (D) | (u, v) ∈
E(D)}. Hence, od(v) = |N + (v)|, while id(v) = |N − (v)|.
The First Theorem of Digraph Theory is analogous to the First Theorem of Graph Theory.
Theorem 8.2.5.
If D is a digraph of size m with vertex set V , then
X X
od(v) = id(v) = m.
v∈V v∈V
Proof. When the outdegrees of the vertices are summed, each arc is counted exactly once, since every
arc is incident from one vertex. Similarly, when the indegrees are summed, each arc is counted just once
since every arch is incident to exactly one vertex.
Definition 8.2.6.
Let u and v be two vertices of a digraph D. A u-w walk in D is a finite alternating sequence
u = u0 , a1 , u1 , a2 , . . . , uk−1 , ak−1 , uk = v
of vertices and arcs that begins with the vertex u and ends with the vertex v and such that ai =
(ui−1 , ui ) for i = 1, 2, . . . , k. The number of arcs in the walk is called the length of the walk. The
concepts of trail, path, and circuits in digraphs are defined analogously to those in graphs, except that
in digraphs, we always proceed in the direction of the arcs. Note that cycles of length 2 are possible
in digraphs.
u = u0 , a1 , u1 , a2 , . . . , uk−1 , ak−1 , uk = v
of vertices and arcs that begins with the vertex u and ends with the vertex v and such that either
ai = (ui−1 , ui ) or ai = (ui , ui−1 ) for i = 1, 2, . . . , k. If ai = (ui−1 , ui ), then we call ai a forward arc,
otherwise, we call ai a backward arc. The number of arcs in the semiwalk is called the length of the
semiwalk. If the vertices uo , u1 , . . . , uk are distinct, then the u-v semiwalk is called a u-v semipath.
Intuitively, the capacity c(x, y) of an arc (x, y) may be thought of as the maximum amount of some
material that can be transported from x to y per unit time. For example, the capacity of the arc (x, y)
may represent the number of seats available on a direct flight from city x to city y in some airline
system. On the other hand, this capacity might be the capacity of a pipeline from city x to city y
in an oil network. The problem in general, is to maximize the “flow” from the source s to the sink t
without exceeding the capacities of the arcs. fig:graph76 A network may be represented by drawing its
underlying digraph D and labelling each arc of D with its capacity. For example, Figure 8.1 shows a
network with c(u, v) = 5 and c(x, y) = 2.
and
f − (v) =
X
f (w, v).
w∈N − (v)
For a vertex v ∈ V (D), the net flow out of v is defined as f + (v) − f − (v), while the net flow into
v is defined as f − (v) − f + (v). The value f (N ) of a flow in N is the net flow
f (N ) = f + (s) − f − (s)
A flow is a mapping that describes the movement (or flow) of material along the arcs of the network,
while the capacity is a mapping that describes the maximum amount that can move along the arcs. The
capacity constraint states that the flow in an arc can never exceed its capacity, and the flow conservation
states that all that flows into a vertex, other than the source s and the sink t, also flows out of that
vertex.
Example 8.3.3 (Flow).
The zero flow assigns flow 0 to each arc in the network. Figure 8.3 shows a flow f in a network N .
Associated with each arc, we write an ordered pair where the first number denotes the capacity of the
arc and the second number denotes the flow in the arc. For example, f (u, v) = 1 while c(u, v) = 5.
The value of a flow is f (N ) = f + (s) − f − (v) = 8 − 0 = 8.
Section 8.3. An Introduction to Networks Page 74
Figure 8.3
Before presenting our first result on networks, we introduce some notation. Let D = (V, E) be a
digraph, and let X, Y ⊆ V with X, Y ̸= ∅. We write
(X, Y ) = {(x, y) ∈ E | x ∈ X, y ∈ Y }
to denote the set of all arcs directed from some vertex in X to some vertex in Y . For example, in
Figure 8.3, if X = {u, v, x} and Y = {x, y, t}, then (X, Y ) = {(u, y), (v, t), (x, y)}. For a flow f and
a capacity function c in a network N , we define
X X
f (X, Y ) = f (e) and c(X, Y ) = c(e)
e∈(X,Y ) e∈(X,Y )
Proof. By definition, f (N ) = f + (s) − f − (s). By the flow conservation constraint (2), we have
f + (v) = f − (v) for all v ∈ S − {v}. Hence we can write
(f + (v) − f − (v)).
X
f (N ) =
v∈S
while
X X
f (u, v) + f (u, v) = f (S, S) + f (S, S)
(u,v)∈(S,S) (u,v)∈(S,S)
Thus
as required.
f (N ) = f − (t) − f + (s).
Proof. Let D be the underlying digraph of N and let S = V (D) − {t}. Since S = t,
f (w, t) = f − (t)
X
f (S, S) =
w∈N − (t)
while
X
f (S, S) = f (t, w) = f + (t).
w∈N + (t)
Corollary 8.3.8.
Let f be a flow in a network N and let (S, S) be a cut of N . Then
f (N ) ≤ c(S, S).
Proof. By Theorem 8.3.6, the value of the flow f (N ) equals the net flow out of S. Thus, f (N ) =
f (S, S) − f (S, S) ≤ f (S, S) since f (S, S) ≥ 0. However by the capacity constraint (1), f (S, S) ≤
c(S, S), hence f (N ) ≤ c(S, S).
Section 8.3. An Introduction to Networks Page 76
Corollary 8.3.9.
Let f be a flow in a network N and let (S, S) be a cut of N . If f (N ) = c(S, S), then f is a maximum
flow and (S, S) is a minimum cut.
Proof. Let f ∗ be a maximum flow in N , and let (X, X) be a minimum cut of N . By Corollary 8.3.8,
f ∗ (N ) ≤ c(X, X). However, f ∗ is a maximum flow, and so f (N ) ≤ f ∗ (N ), while (X, X) is a minimum
cut, and so c(X, X) ≤ c(S, S). Thus, c(S, S) = f (N ) ≤ f ∗ (N ) ≤ c(X, X) ≤ c(S, S). Thus we must
have equality throughout this inequality chain. In particular, f (N ) = f ∗ (N ) and c(X, X) = c(S, S).
Hence, f is a maximum flow and (S, S) is a minimum cut.
Example 8.3.10.
Consider the network N shown in Figure 8.4, where as before, the first number associated with
an arc a is its capacity c(a) and the second number is its flow f (a). The value of a flow is f (N ) =
f + (s)−f − (s) = 10. If S = {s, x}, then (S, S) is a cut of N and c(S, S) = c(s, u)+c(x, v)+c(x, y) =
4 + 4 + 2 = 10. Thus, by Corollary 8.3.9, f is a maximum flow and (S, S) is a minimum cut.
Figure 8.4
Learning Opportunities
8.1. Let N be the network shown in Figure 8.1, where each arc is labelled with its capacity function.
A function f is defined on the arcs as follows:
f (s, u) = 2 f (s, x) = 2 f (u, v) = 1 f (u, y) = 2
f (v, t) = 2 f (x, v) = 1 f (x, y) = 1 f (y, t) = 3
Is f a flow? Explain.
8.2. For the network shown below, associated with each arc is an ordered pair where the first number
denotes the capacity of the arch and the second number denotes the flow in the arc. Determine
the values of the flows a, b and c.
Section 8.4. The Max-Flow Min-Cut Theorem Page 77
8.3. Consider the network N shown below, where as before, the first number associated with an arc s
is its capacity c(a) and the second number is its flow f (a). Use Corollary 8.3.9 to show that the
given flow is a maximum flow and find the corresponding minimum cut.
Definition 8.4.1.
Let N be a network with source s, sink t, capacity function c and flow f . Let P be an s-v semipath.
If every forward arc e on P has excess capacity (meaning f (e) < c(e)) and every backward arc on P
has nonzero flow (meaning f (e) > 0), then we call P an f -unsaturated s-v path from s to v. If
v = t, then we call P and f -augmenting path (even though it may not actually be a path).
For each arc e of P , we define ϵ(e) to be c(e) − f (e) if e is a forward arc and f (e) is e is a backward
arc. We define the leeway of P by ϵ(P ) = min{ϵ(e)}, where the minimum is taken over all arcs e on
P.
Intuitively, if a forward arc e on P has excess capacity, then we increase the flow along e, while if a
backward arch e on P has nonzero flow, then we can “push back” the flow along the arc e.‘
Example 8.4.2.
If f is the flow given in Figure 8.3, P : s, (s, x), x, (x, v), v(u, v), u, (u, y), y, (y, t), t is an f -augmenting
path. Further, ϵ(s, x) = 1, ϵ(x, v) = 2, ϵ(u, v) = 1, ϵ(u, y) = 3 and ϵ(y, t) = 3. Thus, ϵ(P ) = 1.
We are now in a position to present the max-flow min-cut theorem due to Ford and Fulkerson.
Theorem 8.4.3 (Ford and Fulkerson).
In every network, the value of a maximum flow equals the capacity of a minimum cut.
Proof. Let N be a network with underlying digraph D, source s, sink t, and capacity function c. We
define a sequence f0 , f1 , . . . of flows in N of strictly increasing value, i.e., with f0 (N ) < f1 (N ) <
f2 (N ) < · · · , as follows. We start with the zero flow, and so f0 (e) = 0 for all arcs e of D and
f0 (N ) = 0. For each flow fi , i ≥ 0, we denote by Si the set of all vertices v such that there is an
fi -unsaturated s-v semipath from s to v.
Suppose t ∈ Si . Then there is an f -augmenting path P in N . Let fi+1 be the function obtained from
fi by increasing flow by ϵ(P ) along forward arcs of P and decreasing flow by ϵ(P ) along backward arcs
of P and leaving flows on all remaining arcs unchanged. By the definition of the leeway ϵ(P ), we have
0 ≤ fi+1 (e) ≤ c(e) for every arc e, and so the capacity constraint (1) holds. To verify the conservation
constraint (2), we need only to consider vertices of P since the flow along all arcs not on P is unchanged.
However the net flow out of each vertex v on P different from s and t remains 0 (irrespective of the
direction of the two arcs incident with v on P ). Hence, fi+1 is indeed a flow in N . Further, the net
flow out of the source s is ϵ(P ) larger in fi+1 than in fi and so fi+1 (N ) = fi (N ) + ϵ(P ). Thus,
fi+1 (N ) > fi (N ), as desired.
Since a flow is an integer-valued function on E(D), f (N ) + 1 ≤ fi+1 (N ) for all i. By Corollary 8.3.8,
the value of any flow in N is bounded above by the capacity of any cut in N , and so our sequence
f0 , f1 , . . . of flows in N will terminate with some flow fn . Hence in fn , t ∈
/ Sn . Let S = Sn . We
now consider the cut (S, S). Suppose (u, v) ∈ (S, S) and f (u, v) < c(u, v). Then by taking an fn -
unsaturated s-u semipath from s to u, and then proceeding to v along the arc (u, v), we produce an
fn -unsaturated semipath s-v from s to v, contradicting the fact that v ∈ S. Hence if (u, v) ∈ (S, S),
then f (u, v) = c(u, v). Thus, f (S, S) = c(S, S). Further, if (v, u) ∈ (S, S), then f (v, u) = 0, for
otherwise f (v, u) > 0 we could find an fn -unsaturated s-v semipath from s to v, a contradiction.
Section 8.5. The Max-Flow Min-Cut Algorithm Page 79
s = u0 , a1 , u1 , a2 , . . . , un−1 , an−1 , un = t.
For i = 1, . . . , n, replace f (ai ) by f (ai ) + ϵ(t) if ai is a forward arc and by f (ai ) − ϵ(t) if ai is
backward arc.
6. Discard all labels, remove all vertices from L, and go to Step 2.
As shown in the proof of the max-flow min-cut theorem due to Ford and Fulkerson (Theorem 8.4.3),
Algorithm 8.5.1 terminates with a maximum flow f in N . Furthermore, if S is the set of labelled vertices
upon termination, then (S, S) is a minimum cut.
Example 8.5.2.
In this example, we shall use the Edmonds and Karp Algorithm to find a maximum flow and minimum
cut for the network shown in Figure 8.5. The labels on each arc a are the capacity c(a) of a and the
flow f (a) in a, respectively. We begin with the zero flow as shown in Figure 8.5
Figure 8.5
Section 8.5. The Max-Flow Min-Cut Algorithm Page 81
Initially, s is labelled (−, ∞), and L consists only of s. As the algorithm proceeds through Step 3
for the first time, we remove s from L. Since u is unlabelled, and (s, u) ∈ E satisfies f (s, u) <
c(s, u), we assign the label (s+ , 4) to the vertex u, and add u to the end of L. (Note that ϵ(u) =
min{ϵ(s), c(s, u) − f (s, u)} = min{∞, 4} = 4.) Furthermore, since x is unlabelled, and (s, x) ∈ E
satisfies f (s, x) < c(s, x), we assign the label (s+ , 5) to the vertex x, and add x to the end of L.
At this stage, L = {u, x}. Since t has not been labelled, we return to Step 3. We remove the first
element of L, namely u. We the assign the label (u+ , 4) to the vertex v, and add v to the end of
L. (Note that ϵ(v) = min{ϵ(u), c(u, v) − f (u, v)} = min{4, 5} = 4.). We then assign y the label
(u+ , 4), and add y to the end of L. At this stage, L = {x, v, y}. Since t has not been labelled, we
return to Step 3. We remove the first element of L, namely x. Since there are no unlabelled vertices
that can be labelled from x, we continue through Step 3 again (with L = {v, y}). We remove the first
element of L, namely v, and then assign the label (v + , 3) to the vertex t, and add t to the end of L.
(Note that ϵ(t) = min{ϵ(v), c(v, t) − f (v, t)} = min{4, 3} = 3.) We now reach Step 4 and proceed
to Step 5 to obtain the f -augmenting path P : s, (s, u), u, (u, v), v, (v, t), t. (See Figure 8.6)
Figure 8.6
We now increase by ϵ(t) = 3 along forward arcs of P and decrease flow decrease flow by ϵ(t) = 3
along backward arcs of P and leave flows on remaining arcs unchanged. The resulting flow is shown
in Figure 8.7.
Section 8.5. The Max-Flow Min-Cut Algorithm Page 82
Figure 8.7
Proceeding through Step 2 of the Edmonds-Karp algorithm, we assign to the vertices to labels shown
in Figure 8.7. Using the resulting f -augmenting path s, (s, u), u, (u, y), y, (y, t), t with leeway ϵ(t) = 1,
we increase the flow in each of the arcs if this path by ϵ(t) = 1. The resulting flow is shown in Figure
8.8.
Figure 8.8
Section 8.5. The Max-Flow Min-Cut Algorithm Page 83
Proceeding through Step 2 of the Edmonds-Karp algorithm, we assign to the vertices the labels shown
in Figure 8.8. Using the resulting f -augmenting path s, (s, x), x, (x, y), y, (y, t), t with leeway ϵ(t) = 2,
we increase the flow in each of the arcs if this path by ϵ(t) = 2. The resulting flow is shown in Figure
8.9.
Figure 8.9
Proceeding through Step 2 of the Edmonds-Karp algorithm, we assign to the vertices the labels shown
in Figure 8.9. Using the resulting f -augmenting path s, (s, x), x, (x, v), v, (u, v), u, (u, y), y, (y, t), t
with leeway ϵ(t) = 3, we increase the flow in each of the arcs if this path by ϵ(t) = 3 and decrease the
flow by ϵ(t) = 3 along backward arcs in this path. The resulting flow is shown in Figure 8.10.
Figure 8.10
Section 8.5. The Max-Flow Min-Cut Algorithm Page 84
Proceeding through Step 2 of the Edmonds-Karp algorithm, we are only able to label the source s
an no other vertex (including the sink t). Thus the given flow f is a maximum flow of value, and
the corresponding minimum cut is (S, S), where S = {s}. The value of the flow f is f (N ) =
f (S, S) − f (S, S) = 9, while c(S, S) = 9 .
Remark. When a vertex receives a label in the Edmonds-Karp algorithm, it is added to the bottom
of the “labelled but unscanned” list L. These vertices are scanned on a “first-labelled first scanned”
basis, which insures that a shortest f -augmenting path is selected. The importance of taking a shortest
f -augmenting path is illustrated by the network shown in Figure 8.11. If the f -augmenting path is taken
alternately along s, (s, x), x, (x, y), y, (y, t), t and s, (s, y), y, (x, y), x, (x, t), t, then we will need 2 × 106
steps before we obtain a maximum flow of 2 × 106 , whereas the Edmonds-Karp algorithm obtains a
maximum flow in two steps.
Figure 8.11
Section 8.5. The Max-Flow Min-Cut Algorithm Page 85
Learning Opportunities
8.4. For the networks shown below, associated with each arc is an ordered pair where the first number
denotes the capacity of the arc and the second arc denotes the flow in the arc. Starting with
the given flow, use the Edmonds-Karp algorithm to find a maximum flow and a minimum cut for
these networks.
8.4.1. .
8.4.1. .
References
[1] K. Appel and W. Haken. Every planar map is four colorable. Bulletin of the American mathematical
Society, 82(5):711–712, 1976.
[2] N. Biggs, E. K. Lloyd, and R. J. Wilson. Graph Theory, 1736-1936. Oxford University Press, 1986.
[3] B. Bollobás. Graph Theory: An Introductory Course. Springer Verlag, 1979.
[4] J. Bondy and U. S. R. Murty. Graph theory with applications. North-Holland New York, 1976.
[5] G. Chartrand. Introduction to graph theory. Tata McGraw-Hill Education, 2006.
[6] G. Chartrand, L. Lesniak, and P. Zhang. Graphs & digraphs, volume 39. CRC press, 2010.
[7] G. Chartrand and O. R. Oellermann. Applied and algorithmic graph theory. Mcgraw-Hill College,
1993.
[8] E. W. Dijkstra et al. A note on two problems in connexion with graphs. Numerische mathematik,
1(1):269–271, 1959.
[9] G. A. Dirac. Some theorems on abstract graphs. Proceedings of the London Mathematical Society,
3(1):69–81, 1952.
[10] L. Euler. Solutio problematis ad geometriam situs pertinentis. Commentarii academiae scientiarum
Petropolitanae, pages 128–140, 1741.
[11] H. Fleischner, L. Beineke, and R. Wilson. Eulerian graphs, selected topics in graph theory 2.
Academic Press, London, pages 2–53, 1983.
[12] A. Gibbons. Algorithmic graph theory. Cambridge university press, 1985.
[13] R. J. Gould. Updating the hamiltonian problem—a survey. Journal of Graph Theory, 15(2):121–
157, 1991.
[14] R. L. Graham and P. Hell. On the history of the minimum spanning tree problem. Annals of the
History of Computing, 7(1):43–57, 1985.
[15] S. L. Hakimi. On realizability of a set of integers as degrees of the vertices of a linear graph. i.
Journal of the Society for Industrial and Applied Mathematics, 10(3):496–506, 1962.
[16] V. Havel. A remark on the existence of finite graphs. Casopis Pest. Mat., 80:477–480, 1955.
[17] P. J. Heawood. Map color theorems. Quant. J. Math., 24:332–338, 1890.
[18] C. Hierholzer and C. Wiener. Über die möglichkeit, einen linienzug ohne wiederholung und ohne
unterbrechung zu umfahren. Mathematische Annalen, 6(1):30–32, 1873.
[19] A. Kempe. How to colour a map with four colours, 1880.
[20] A. B. Kempe. On the geographical problem of the four colours. American journal of mathematics,
2(3):193–200, 1879.
[21] J. B. Kruskal. On the shortest spanning subtree of a graph and the traveling salesman problem.
Proceedings of the American Mathematical society, 7(1):48–50, 1956.
86
REFERENCES Page 87
[22] C. Kuratowski. Sur le probleme des courbes gauches en topologie. Fundamenta mathematicae,
15(1):271–283, 1930.
[23] L. Lesniak and O. R. Oellermann. An eulerian exposition. Journal of Graph Theory, 10(3):277–297,
1986.
[24] L. Lesniak-Foster. Some recent results in hamiltonian graphs. Journal of Graph Theory, 1(1):27–36,
1977.
[25] E. Lucas. Recreations mathematiques: 2e ed. A. Blanchard, 1960.
[26] D. B. West et al. Introduction to graph theory, volume 2. Prentice hall Upper Saddle River, NJ,
1996.
[27] A. T. White. The proof of the heawood conjecture. Selected Topics in Graph Theory, LW Beineke
and RJ Wilson, Eds., Academic Press, London, pages 51–81, 1978.
[28] R. J. Wilson and J. J. Watkins. Graphs: an introductory approach: a first course in discrete
mathematics. John Wiley & Sons Inc, 1990.