1 Directed Graphs and DeBruijn Sequences

1
Directed Graphs and DeBruijn Sequences
An orientation of a directed graph(digraph) is a choice of directions for
each of the edges. The in-degree at a vertex v, denoted deg − (v), equals the
number of arcs directed into v. The out-degree, denoted deg + (v), equals
the number of arcs directed out of v. Note that loops count as both indirected and out-directed arcs at a vertex. If there is an arc from u to v we
write u → v.
v
Figure 1: In-degree deg − (v) = 3 and out-degree deg + (v) = 4
A directed path is a path whose arcs are directed in the same direction
as the path. A directed Euler circuit is a closed directed path which
traverses each arc of the graph. In the digraph below there is a directed
Euler circuit.
a
d
b
c
e
f
Figure 2: Directed Eulerian Graph
1.1 Theorem ( Eulers theorem for digraphs )
Let G be a digraph. Then G has a directed Euler circuit iff the underlying
1
graph is connected and the in-degree equals the out-degree at each vertex.
Proof. By induction on the number of edges of G. If G is a directed cycle,
then the result is clear. Assume that the theorem holds for all connected
directed graphs with fewer edges than G whose in-degrees equal its outdegrees at every vertex. We first observe that in G there is at least one
directed cycle; starting at a vertex, depart on an out-directed edge and at
each subsequent vertex visited, keep departing on an out-directed edge until
you first reach a previously visited vertex. Then one obtains a directed cycle.
Suppose first that C is a directed cycle. If G = C, then it is clear that G has
a directed Euler circuit. Suppose therefore that G 6= C. Let G0 be the graph
obtained from G by removing the edges of C. Then for each vertex in G0 , the
in-degree equals the out-degree. If G0 only has one non-trivial component
(i.e. a component which is not an isolated vertex), say K, then we can find a
directed Euler circuit for G as follows. By the inductive assumption, K has
a directed Euler circuit. We observed that since G is connected, the cycle C
must share some vertices with K. Suppose v is one such vertex. We start a
directed Euler circuit of K at the vertex v. Once we finish this circuit at v,
we continue along C, finishing back at v again. This will be a directed Euler
circuit of G. Now suppose there is more than one non-trivial component of
G0 and let K1 , . . . , Kt be these components. Since G is connected, C must
intersect each of these components. For i = 1, . . . , t, let vi be a vertex belong
to both C and Ki (where v1 , . . . , vt are distinct). Again, we note that each
Ki has a directed Euler circuit. By reindexing if necessary, we may assume
that v1 , . . . , vt occur in this order as we traverse the directed cycle C. Now
we may find a directed Euler circuit of G as follows: starting at v1 , traverse
a directed Euler circuit of K1 . When we arrive back at v1 , continue along
C until we reach the vertex v2 . Now traverse a directed Euler circuit of
K2 starting at v2 . When we arrive back at v2 , we continue along C to v3 .
The directed circuit continues in this fashion visiting v1 , v2 , v3 , . . . until we
arrive back at v1 again. Thus G has a directed Euler circuit. The proof now
follows by induction.
1.1
An Application: the rotating drum problem
Imagine a drum with 16 memory locations arrange in a circle, each location
containing either a 1 or a 0. A sensor on particular window reads strings
with 4 consecutive bits on the drum. The problem is to find a circular
arrangement of the bits so that as the drum rotates, all the 4-bit words read
2
by the sensor are different (there are 16 such words).
General Problem: Is there a cyclic arrangement of 2n binary digits on a
drum so that the consecutive n-bit strings are all different?
Such a circular arrangement of bits as described in the problem is called
a Debruijn sequence.
We shall define a digraph G4 as follows: the vertices will be all the 3-bit
binary words. We define arcs such that for each vertex x1 x2 x3 , we draw
an arc from x1 x2 x3 to x2 x3 0, and from x1 x2 x3 to x2 x3 1. For example,
010 → 101, and 000 → 000 (a loop). Give the arc x1 x2 x3 → x2 x3 x4 the
label x1 x2 x3 x4 We this, the graph G4 looks like:
0011
101
111
11
10
010
11
01
010
1
10
00
0000
000
011
10
11
1001
00
01
001
00
01
0
11
1
00
10
0110
0
101
100
1100
110
Figure 3: The graph G4
G4 is called a DeBruijn graph. We observe that the in-degree equals
the out-degree which equals 2 at each vertex. Thus the digraph G4 has a
directed Euler circuit. Note that each Euler circuit of G4 corresponds in a
one-to-one fashion with a 16-bit DeBruijn sequence. In general, we define a
Debruijn graph Gn where the vertices are the binary words of length n − 1,
3
1111
and at each vertex x1 x2 · · · xn−1 there are two out-going arcs
x1 x2 · · · xn−1 → x2 x3 · · · xn−1 0, x1 x2 · · · xn−1 → x2 x3 · · · xn−1 1.
1.2 Theorem
The digraph Gn has a directed Euler circuit and each Euler circuit in Gn
corresponds in a one-to-one fashion with DeBruijn sequences of length 2n .
4