1.4 Trails, Circuits, Paths, and Cycles
1.4.2 Eulerian Trails and Circuits
A
F
C B
D E
FIGURE 1.52.
FIGURE 1.53.
FIGURE 1.54. Are any of these Eulerian?
Theorem 1.20. For a connected graphG, the following statements are equiva- lent.
1. Gis Eulerian.
2. Every vertex ofGhas even degree.
3. The edges ofGcan be partitioned into (edge-disjoint) cycles.
Proof. To prove the logical equivalence of these statements, we prove that the first statement implies the second, the second implies the third, and the third implies the first.
For the first implication, suppose thatGcontains an Eulerian circuitC. Letv be an arbitrary vertex ofG. Every time the circuit entersv on an edge, it must leave on a different edge. SinceCnever repeats an edge, there must be an even number of edges incident withvand hence the degree ofvis even.
For the second implication, suppose that every vertex ofGhas even degree.
We use induction on the number of cycles inG. SinceGis connected and has no vertices of degree 1,Gis not a tree, and thereforeGmust have at least one cycle. IfG has exactly one cycle, the Gmust be a cycle graph Cn for some n, and so the desired partition contains just the one cycle itself. Suppose now (using strong induction) that the implication is valid for graphs containing at most k cycles, and suppose Ghas k+ 1 cycles. LetC be one of the cycles ofG, and letG be the graph obtained fromGby deleting the edges ofC. With this deletion, each vertex ofCloses exactly two edges, and hence the vertices ofG all have even degree. Further, the graphG (which is possibly disconnected) has connected components that have no more thankcycles each. Each component, then, satisfies the induction hypothesis and has edges that can be partitioned into cycles. These cycles, together with the cycleC, partition the edges ofG into cycles. The induction is complete, and the implication is established.
For the third implication, suppose that the edges ofGcan be partitioned into cycles. Call these cyclesS1,S2, . . . ,Sk. LetC be the largest circuit inGsuch that the set of edges ofCis exactly
E(Sj1)∪E(Sj2)∪ · · · ∪E(Sjm)
for some collection of the cyclesSj1,Sj2, . . . ,Sjm. (We note here that this implies that for each cycleSi(1 ≤i≤k), either all of the edges ofSiare onCor none
of them are.) Now, supposeeis an edge ofGthat is (a) not an edge ofC, and (b) incident with a vertex, sayv, that is onC. Sinceeis not an edge ofC, it must be thateis an edge of cycleSi, for somei, where no edge ofSiis onC. The vertex vmust also be onSi. LetCbe the circuit inGobtained by patchingSiintoCat the vertexv(since no edge ofSiis a member ofC, there is no repetition of edges caused by this patching). Since the edges ofCconsist of the edges ofCtogether with the edges ofSi, we have contradicted the maximality ofC. This means that no such edgeecan exist and therefore thatCis an Eulerian circuit ofG. The final implication is established.
So, Eulerian circuits exist in connected graphs precisely when the degrees of these graphs are all even. What about Eulerian trails? Certainly if an Eulerian circuit exists, then so does an Eulerian trail (the circuit is just a closed trail). But are there graphs which are not Eulerian but which do contain an Eulerian trail?
The following corollary gives the complete answer. Its proof is left for you as an exercise.
Corollary 1.21. The connected graphGcontains an Eulerian trail if and only if there are at most two vertices of odd degree.
Now that we know precisely when Eulerian circuits and trails exist, how easy is it to find them? The algorithm given below, named for nineteenth century math- ematician Carl Hierholzer [159], gives a simple way of identifying such routes.
While not identical, you may notice a similarity between this algorithm and the method used to prove the third implication in the proof of Theorem 1.20.
Before reading on, take a look back at the quotation given at the beginning of this section. It describes the primary reason for the success of Hierholzer’s algorithm.
Hierholzer’s Algorithm for Identifying Eulerian Circuits Given: An Eulerian graphG.
i. Identify a circuit inGand call itR1. Mark the edges ofR1. Leti= 1.
ii. IfRicontains all edges ofG, then stop (sinceRiis an Eulerian circuit).
iii. IfRidoes not contain all edges ofG, then letvibe a vertex onRithat is incident with an unmarked edge,ei.
iv. Build a circuit,Qi, starting at vertexviand using edgeei. Mark the edges ofQi.
v. Create a new circuit,Ri+1, by patching the circuitQiintoRiatvi. vi. Incrementiby 1, and go to step ii.
An example of this process is shown in Figure 1.55. You should note that the
a b
c d
f g
e h
i j
R4: e, g, h, f, e, i, h, d, b, a, c, e, d, c, h, j, e
R1: e, g, h, j, e
a b
c d
f g
e h
i j
Q1: h, d, c, h
a b
c d
f g
e h
i j
R2: e, g, h, d, c, h, j, e Q2: d, b, a, c, e, d
a b
c d
f g
e h
i j
R3: e, g, h, d, b, a, c, e, d, c, h, j, e Q3: h, f, e, i, h FIGURE 1.55. The stages of Hierholzer’s algorithm.
process will succeed no matter what the initial circuit,R1, is chosen to be. Another algorithm for finding Eulerian circuits is given in Exercise 3.
The even degree characterization of Eulerian graphs is really quite nice. All one needs to do to determine if a graph is Eulerian is simply look at the degrees of the vertices. Once we know a graph is Eulerian, Hierholzer’s algorithm will give us an Eulerian circuit. Maybe Charlie Cowell, our anvil salesman, used these ideas to plan his door to door routes!
Exercises
1. For each of the following, draw an Eulerian graph that satisfies the condi- tions, or prove that no such graph exists.
(a) An even number of vertices, an even number of edges.
(b) An even number of vertices, an odd number of edges.
(c) An odd number of vertices, an even number of edges.
(d) An odd number of vertices, an odd number of edges.
2. Use Hierholzer’s algorithm to find an Eulerian circuit in the graph of Fig- ure 1.56. UseR1:a, b, c, g, f, j, i, e, aas your initial circuit.
a
o p
n
l h
j k
g f
m i e
c d b
FIGURE 1.56.
3. What follows is another algorithm (from [195]) for finding Eulerian cir- cuits. The method used here is to build the circuit, one edge at a time, mak- ing sure to make good choices along the way.
Fleury’s Algorithm for Identifying Eulerian Circuits Given: An Eulerian graphG, with all of its edges unmarked.
i. Choose a vertexv, and call it the “lead vertex.”
ii. If all edges ofGhave been marked, then stop. Otherwise continue to step iii.
iii. Among all edges incident with the lead vertex, choose, if possible, one that is not a bridge of the subgraph formed by the unmarked edges. If this is not possible, choose any edge incident with the lead. Mark this edge and let its other end vertex be the new lead vertex.
iv. Go to step ii.
Use Fleury’s algorithm to find an Eulerian circuit for the graph in Fig- ure 1.57. Letabe your initial vertex.
4. Prove Corollary 1.21.
5. Prove that if every edge of a graphGlies on an odd number of cycles, then Gis Eulerian.
6. LetGbe a connected graph which is regular of degreer. Prove that the line graph ofG,L(G), is Eulerian.
a
f d
b
e g c
FIGURE 1.57.
7. LetG=Kn1,n2.
(a) Find conditions onn1andn2that characterize whenGwill have an Eulerian trail.
(b) Find conditions that characterize whenGwill be Eulerian.
8. LetG=Kn1,...,nk, wherek≥3.
(a) Find conditions onn1, . . . , nk that characterize whenGwill have an Eulerian trail.
(b) Find conditions that characterize whenGwill be Eulerian.