You are on page 1of 6

Euler Tours A graph is Eulerian if it has an Euler tour.

A tour of G is a closed walk which includes every


c
edge at least once. a f

c f u v
a d
b e
u d v
b e Eulerian ?
Does it have an Euler trail ?
An Euler tour of G is a tour which includes every
edge exactly once. c f
a

u d v
An Euler trail of G is a trail which includes every b e
edge exactly once.
Schlag CMPE177 Fall 2004 1 Schlag CMPE177 Fall 2004 2

Thm
For a connected graph G the following are Eulerian ?
equivalent:
a a a
1. G is Eulerian.
b e e e
b g b g
2. All vertices of G have even degree.
d d d
3. The edges of G can be partitioned into cycles.
c f c f f
c
Thm 3.2 1 if and only if 2
Thm 3.3 1 if and only if 3 Does it have an Euler trail ?
Show 1Ł 2Ł 3Ł 1
Schlag CMPE177 Fall 2004 3 Schlag CMPE177 Fall 2004 4

1
Proof: 1Ł 2 Proof: 1Ł 2 (continued)
Assume G is Eulerian. d(v)= 2(# loops at v) + (# non-loop edges of v)
Let C be an Euler Tour of G. = 2(# loops at v) + (# non-loop edges entering v)
Let v be any vertex of G. + (# non-loop edges leaving v)
If d(v)=0, then v has even degree. = 2(# loops at v) + 2(# non-loop edges leaving v)
If d(v)>0, then v has one or more edges which all Since C enters and leaves v the same # of times.
appear exactly once in C. So d(v) is even.
Each occurrence of v in C is preceded and Proof: 2Ł 3 By induction on the # of cycles of G, k.
followed by an edge of v.
Base: k=0. If G has no cycles, it is a tree.
Loops can be used both to enter and leave v, but
non-loops are used either to enter or leave v, not A tree with at least 2 vertices, must have 2 vertices
both. of degree 1 by Corollary 2.3.
Schlag CMPE177 Fall 2004 5 Schlag CMPE177 Fall 2004 6

Proof: 2Ł 3 (continued) Proof: 2Ł 3 (continued)


Since G has only vertices of even degree, it must Let G1,G2 , 

,Gm be the connected components of G'.


have a single vertex with no edges.
So the 0 edges can be partitioned into 0 cycles. Each Gi is a connected graph with even degrees
having less than k cycles.
Step: k>0. Let C be a cycle in G.
Let G’ be the graph G-E(C) (remove the edges of C). By induction the edges of each Gi can be partitioned
The degree of any vertex in G’ is either the same into cycles.
as in G or 2 less. Let C1,C2, ,Ct be the cycles from all of the
So the degree of any vertex in G’ is still even. components of G'.

G’ has less than k cycles. Then C1,C2, 

,Ct ,C is a partition into cycles of E(G).


Schlag CMPE177 Fall 2004 7 Schlag CMPE177 Fall 2004 8

2
Proof: 3Ł 1 Proof: 3Ł 1 (continued)
Let C and C’ be closed trails of G which intersect Splice together C1 and C j to form a closed trail, C''.
at v, but have no common edges.
C = ve 1v 1e 2 v 2 v k e k + 1v

C2 , 

,C j −1,C j +1, 

,C m ,C ' ' is a partition of E(G) into


C ' = vf 1u 1f 2 u 2 ,u h f h + 1v


m-1 closed trails .


Then C ' ' = ve1v 1e2 ,v 2 v k ek +1vf1u1f2u2 uk fk +1v
Repeat m-2 times until there is only 1 closed trail
 

is a closed trail with all of the edges of C and C’. which contains all of E(G).
Let C1,C2, 

,Cm be the partition into cycles of E(G).


This is an Euler Tour, so G is Eulerian.
C1,C2, 

,Cm is also a partition of E(G) into closed trails .


Since G is connected C1 has a vertex in common
with some C j (j ≠ 1).
Schlag CMPE177 Fall 2004 9 Schlag CMPE177 Fall 2004 10

Corollary A connected graph G has an Euler Trail if


and only if it has either 2 or 0 vertices of odd degree.
Finding Euler Tours
Proof: Ł Let T be the Euler Trail, say from u to v. C←empty cycle at v0
Then G+e (where e=(u,v) is a new edge) is Eulerian while (G has unmarked edges)
(T+e is an Euler Tour) and so has only vertices of u←any vertex on C which has unmarked edges
C’←empty list of edges
even degree.
v←u
So either G has 0 vertices of odd degree (if u=v) do
or has exactly 2 vertices of odd degree (if u v) . e←unmarked edge of v
Let u and v be the 2 vertices of odd degree, or mark e
if there are none, let v=u. Append e to C’
v←other endpoint of e
Then G+e (where e=(u,v) is a new edge) has only
until(v=u)
vertices of even degree, so it has an Euler Tour, C. Splice C’ into C at u
Removing e from C gives a u-v Euler Trail of G. endwhile
Schlag CMPE177 Fall 2004 11 Schlag CMPE177 Fall 2004 12

3
Fleury’s Algorithm Example of Fleury’s Algorithm
(aka don’t burn your bridges)
v←v0; F←E
C←trivial path at v0
while (G has unmarked edges) c f
If v has an unmarked edge that is not a bridge of (V,F) a
then e←unmarked edge of v that is not a bridge of (V,F)
else e←any unmarked edge of v u d v
mark e
b e
Append e to C
F←F-e
v←other endpoint of e
endwhile

How do you tell if an edge of (V,F) is a bridge?


Schlag CMPE177 Fall 2004 13 Schlag CMPE177 Fall 2004 14

Why does Fleury’s Algorithm work? Euler Tours in Directed Graphs


At any time v will have at most one edge which is A directed tour of G is a closed directed walk
a bridge of (V,F), (will be used last). v f which includes every arc at least once.
e
Suppose not: e and f are bridges.
A directed Euler tour of D is a directed tour which
Assume v 0 is not in G1 . v1
includes every arc exactly once.
All vertices in G1 , currently G2
G1 A directed Euler trail of D is a directed trail which
have even degree. includes every arc exactly once.
But then the subgraph G1 , has
v1
exactly one vertex, v1, of odd degree. A directed graph is Eulerian if it has a directed
G1 Euler tour.

Schlag CMPE177 Fall 2004 15 Schlag CMPE177 Fall 2004 16

4
Thm 7.2 Eulerian ?
For a weakly connected directed graph D: c
b
a d
D is Eulerian if and only if for all v, id(v)=od(v). c e h
b
a f c
D has an open directed Euler Trail from u to v if d g b
e h a d
and only if,
f e h
1. od(u)=id(v)+1. g
f
g
2. id(v)=od(v)+1.
3. for all w u,v, id(w)=od(w). Does it have an Euler Trail ?

If D is Eulerian then it is strongly connected.


Schlag CMPE177 Fall 2004 17 Schlag CMPE177 Fall 2004 18

Finding Euler Tours in Directed Graphs Example b


c
a d
1. Build a DFS tree for the graph. e h
a
2. Start traversal at root of the tree. g
f

3. Traverse arcs in reverse direction using the tree e


b
arc to the parent last.
c d f
The traversal can never get stuck since a path to
the root will always exist as long as a vertex has
h
an arc left. g

Schlag CMPE177 Fall 2004 19 Schlag CMPE177 Fall 2004 20

5
Equivalent to:
Chinese Postman Problem
Add a set of edges of minimum weight to G to make
Given a weighted graph G, find a minimum cost tour. it Eulerian, where the cost of each new edge is the
distance between its endpoints in G.
f
6 f
5 2 6
a b 5 2
1 (e,f),(b,d) cost 3+3=6
1 3 1 a b
e 1
1 3 1 (e,b),(d,f) cost 2+5=7
7 d c e
2
7 d c
2
(e,d),(b,f) cost 4+3=7
Each edge must be traversed.
Schlag CMPE177 Fall 2004 21 Schlag CMPE177 Fall 2004 22

f
6 (e,f),(b,d) cost 3+3=6
5 2
3 a b
1
1 3 1
e 3
7 d c
2

f
6
5 2
a b Solution is an Euler Tour
1
1 3
of the modified graph.
e 1
7 d c
2

Schlag CMPE177 Fall 2004 23

You might also like