COMPUTING Euler Tours
Neeldhara Misra
DSA1 Week 5
Recall
A walk is a sequence of edges
\(e_1, \ldots, e_{n-1}\)
such that there exists a sequence of vertices
\(v_1, \ldots, v_n\)
for which \(e_i = (v_i, v_{i+1})\)
for all \(1 \leqslant i \leqslant n-1\).
An (closed/open) Euler Tour of a graph \(G\)
is a (closed/open) walk
that contains every edge exactly once
(i.e, no repeats and no omissions).
If a graph \(G\) has:
(a) more than two vertices of odd degree, or
(b) exactly one vertex of odd degree, then
it does not have an Euler Tour of any kind
(closed or open).
What we discovered
If a graph \(G\) has:
(a) exactly two vertices of odd degree, or
(b) no vertex of odd degree, then
does it have an Euler Tour of some kind
(closed or open)?
Food for thought
Closed Euler Tours
Getting back to where we started.
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has any vertex of odd degree,
it does not have a closed Euler Tour.
What we know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
Will you get stuck at this point?
NO
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
Will you get stuck at this point?
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
Can we conclude that we have an Euler Tour?
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
Can we conclude that we have an Euler Tour?
NO
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
Now can we conclude that we have an Euler Tour?
If a graph \(G\) has no vertex of odd degree,
it does have a closed Euler Tour.
What we don't know
Now can we conclude that we have an Euler Tour?
NO
If a graph \(G\) has no vertex of odd degree,
AND and all of its vertices with nonzero degree belong to a single connected component,
then it does have a closed Euler Tour.
What we now know
find_tour(G,v,marked):
set curr := v
set S := empty
while there is an outgoing edge e = (curr,u) which is not in S or marked:
append e to S
res_deg[curr] = res_deg[curr]-1
set curr := u
return S
init marked = empty
init fragments = empty
while there is a vertex v such that
res_deg(v) > 0:
F = find_tour(G,v,marked)
Add F to fragments
patchup():
Let S[i] for i in 1, 2, ..., f
denote the set of all fragments
while f > 1:
look for a fragment S[i] that intersects S[0]
if S[i] does not exist:
return false
else:
expand S[0] along S[i]
remove S[i] from the set of all fragments
2023 DSA1 | Week 5
By Neeldhara Misra
2023 DSA1 | Week 5
- 763