Euler Circuits and Paths

Euler Circuits and Paths
Exploration

Is it possible to draw this figure without
lifting your pencil from the paper and
without tracing any of the lines more than
once?
Leonard Euler


This problem is an 18th
century problem that
intrigued Swiss
mathematician Leonard
Euler (1707-1783).
This problem was
posed by the residents
of Königsberg, a city in
what was then Prussia
but is now Kaliningrad.
Königsberg Bridges


In the 1700s, seven bridges connected two islands
on the Pregel River to the rest of the city.
The people wondered whether it would be possible
to walk through the city by crossing each bridge
exactly once and return to the original starting
point.
Euler’s Solution
Using a graph like the picture where the
vertices represent the landmasses of the
city and the edges represent the bridges,
Euler was able to find that the desired
walk throughout the city was not possible.
 In doing so, he also discovered a solution
to problems of this general type.

Euler’s Solution (cont’d)




Try to transverse the graph without lifting your
pencil of tracing the lines more than once.
When can you draw figures without retracing any
of the edges and still end up at your starting
point?
When can you draw the figure without retracing
and end up at a point other than the one from
which you began?
When can you not draw the figure without
retracing?
Euler’s Solution (cont’d)
Euler found that the key to the solution
was related to the degrees of the vertices.
 Recall that the degree of a vertex is the
number of the edges that have the vertex
as an endpoint.
 Find the degree of each vertex of the
graphs on the next slide. Do you see
what Euler noticed?

Degree of the Vertex
Euler’s Solution

Euler found that in order to be able to
transverse each edge of a connected
graph exactly once and to end at the
starting vertex, the degree of each vertex
of the graph must be even. (As only in the
second graph)
Euler Circuits and Paths
In his honor, a path that uses each edge
of a graph exactly once and ends at the
starting vertex is called an Euler circuit.
 Euler also noticed that if a connected
graph had exactly two odd vertices, it
was possible to use each edge of the
graph exactly once but to end at a vertex
different from the starting vertex. Such a
path is called an Euler path.

Euler Circuits and Paths (cont’d)
Notice that the first graph is an example
of an Euler path.
 The last graph, however, has four odd
vertices and so it cannot be traced without
lifting the pencil.
 It is neither an Euler path nor an Euler
circuit.

Finding Euler Circuits
Finding an Euler circuit in a small graph
can usually be found relatively easily by
trial and error.
 However, as the number of vertices and
edges increases, a systematic way of
finding the circuit becomes necessary.
The following algorithm gives one way of
finding and Euler circuit for a connected
graph with all vertices of even degree.

Euler Circuit Algorithm
1.
2.
3.
4.
5.
Pick any vertex and label it S.
Construct a circuit, C, that begins and
ends at S.
If C is a circuit that includes all edges of
the graph, go to Step 8.
Choose a vertex, V, that is in C and has
an edge that is not in C.
Construct a circuit C’ that starts and
ends at V using edges not in C.
Euler Circuit Algorithm (cont’d)
6.
7.
8.
Combine C and C’ to form a new circuit.
Call this New circuit C.
Go to Step 3.
Stop. C is an Euler circuit for the graph.
Example

Use the Euler circuit algorithm to find an Euler circuit for
the graph below.
c
d
a
b
e
i
f
h
g
Using the Algorithm
◄ Apply
Step 1 of the algorithm. Choose
vertex b, and label it S.
◄ Let C be the circuit S, c, d, e, a, S.
◄ C does not contain all edges of the graph,
so go to Step 4 of the algorithm.
◄ Choose vertex d.
◄ Let C’ be the circuit d, g, f, e, g, h, e, I, h,
b, d.
Algorithm (cont’d)
◄ Combine
C and C’ by replacing vertex d in
the circuit C with the circuit C’. Let C now
be the circuit S, c, d, g, f, e, g, h, e, I, h,
s, d, e, a, S.
◄ Go to Step 3 of the algorithm.
◄ C now contains all edges of the graph, so
go to Step 8 of the algorithm and stop. C
is an Euler circuit for the graph.
Directionality in Graphs
Sometimes a graph application requires
that edges have directionality.
 An example of this can be seen in a city
that has one-way streets.
 A graph that has directed edges, edges
that can be traversed in only one
direction, is known as a digraph.
 The number of edges going into a vertex
is known as the indegree of the vertex
and the number of edges coming out of a
vertex is known as the outdegree.

An Example of a Digraph
The digraph on the next slide can be
described by the following set of vertices
and set of ordered edges:
Vertices={A, B, C, D}
Ordered Edges= {AB, BA, BC, CA, DB, AD}
 If you follow the indicated direction of
each edge, is it possible to draw this
digraph and end up at the vertex where
you started? That is, does the digraph
have a directed circuit?

Digraph
Check the indegree and outdegree of
each vertex.
 A connected diagraph has a Euler circuit
if the indegree and outdegree of each
vertex are equal.

B
A
C
D
Practice Problems
1.
State whether the graph has an Euler
circuit, an Euler path, or neither. Explain
why.
a.
c.
d.
`
b.
Practice Problems (cont’d)
2. Sally began using the Euler circuit algorithm
to find the Euler circuit for the graph below.
She started at vertex d and labeled it S. The
first circuit she found was S, e, f, a, b, c, S.
Using Sally’s start, continue the algorithm,
and find the Euler circuit for the graph.
a
b
e
g
c
f
d
S
Practice Problems (cont’d)
3. Use the Euler circuit algorithm to find an
Euler circuit for the following graph:
c
d
b
e
a
h
g
f
Practice Problems (cont’d)
4.
5.
The Euler circuit algorithm is to be used
for “connected graphs with all vertices of
even degree.” Why is it necessary to
state that the graph must be connected?
Give an example of a graph with all
vertices of even degree that does not
have an Euler circuit.
Will a complete graph with two vertices
have an Euler circuit? Three vertices?
Four vertices? Five vertices, or n
vertices?
Practice Problems (cont’d)
6. The present-day Königsberg has two more
bridges than it did in Euler’s time. One more
bridge was added to connect the two banks of
the river, A to B, in the figure below. Another
one was added to link the land to one of the
islands, B to D. Is it now possible to make the
famous walk and return to the starting point?
A
C
D
B
Practice Problems (cont’d)
7.
The streets of a city can be described by
a graph in which the vertices represent
the street corners and the edges
represent the streets. Suppose you are
the city street inspector and it is
desirable to minimize time and cost by
not inspecting the same street more than
once.
Practice Problems (cont’d)
Is it possible to begin at the garage (g)
and inspect each street only once? Will
you be back at the garage at the end of
the inspection? Find a route that inspects
all streets, repeats the number of edges
and returns to the garage.
Practice Problems (cont’d)
Diagram:
a
c
b
d
e
j
i
f
h
G
Practice Problems (cont’d)
8.
Construct the following digraphs:
a. V={A, B, C, D, E}
E={AB, CB, CE, DE, DA}
b. V={W, X, Y, Z}
E={WX, XZ, ZY, YW, XY, YX}
Practice Problems (cont’d)
9.
Determine whether the digraph has a
directed Euler circuit.
a.
b.
c.
Practice Problems (cont’d)
10.
Does the following digraph have a directed Euler
circuit? Why or why not? Does it have a
directed Euler path? If it does, which vertex
must be the starting vertex? When does a
digraph have an Euler path?
b
c
f
g
a
d
e