Discrete Mathematics
U. Waterloo ECE 103, Spring 2010
Ashwin Nayak
June 19, 2010
Some applications of graph theory
In these notes, we visit some important applications of elementary Graph Theory.
Gray Codes
An
n
-bit Gray code, also called the
refected binary code
, is an ordering of the
2
n
strings of length
n
over
{
0
,
1
}
such that every pair of successive strings differ in exactly one position. For example, an
2
-bit Gray code
is
00
,
01
,
11
,
10
, and a
3
-bit Gray code is
000
,
001
,
101
,
111
,
011
,
010
,
110
,
100
.
If we use successive strings in a Gray code to represent the integers from
0
up to
2
n
−
1
, instead of the usual
binary representation, we see that incrementing a number by one involves ±ipping only one bit. In the
usual binary representation, incrementing by 1 could lead to a sequence of bits that are carried over, which
may change several consecutive bits at once. For example,
7 + 1 = 8
in the usual binary representation
is
111
2
+ 1
2
= 1000
2
, and we see that incrementing
111
by
1
causes four bits to be ±ipped. This simple
property makes Gray codes very useful in practice.
Although they had appeared in mathematical puzzles earlier, Gray codes were proposed in 1947 by Frank
Gray, a physicist and researcher at Bell Labs, to prevent spurious output from electromechanical switches.
(As you may have guessed, the codes are named after him.) Today, Gray codes are widely used to facilitate
error correction in digital communications such as digital terrestrial television and some cable TV systems.
We have seen Gray codes with 2 and 3 bits. Do they exist for all
n
? Below, we see that this question is
closely related to a basic property of the
n
-dimensional hypercube
H
n
.
Recall that the vertices of
H
n
are precisely the set of all
n
-bit strings, and two vertices
x,y
form an edge iff
they differ in exactly in one position. So, the question of existence of an
n
-bit Gray code may be reformu-
lated as: Is there a path in
H
n
that includes all the
2
n
vertices? The answer is, as you may have guessed,
yes! In fact, the hypercube satis²es a stronger property, that there is a
cycle
that contains all
2
n
of its vertices
(when
n
≥
2
). Disregarding any one of the edges in such a cycle gives us the path we seek. Such a cycle is
shown in bold for
H
2
and
H
3
below;
H
1
cannot have such a cycle, but has the kind of path we seek.
Figure 1: Hamilton paths and cycles in
H
1
,H
2
3
, depicted in bold.
DeFnition 1
A cycle in a graph
G
that contains all the vertices in it is called a
Hamilton
cycle (sometimes a
Hamiltonian
cycle).
In the last home work, we saw that the grid graph
G
n
has a Hamilton cycle for even
n
. We now prove that
the
n
-hypercube also does, for all
n
≥
2
. In proving this, we make use of the fact that we can construct
the
(
n
+ 1)
-hypercube by connecting two copies of the
n
-hypercube with a suitable set of edges. So we can
1