Circuits
(Eulerian and Hamiltonian) Ioan Despi
despi@turing.une.edu.au
University of New England
July 25, 2013
Circuits (Eulerian and Hamiltonian) Ioan Despi - - PowerPoint PPT Presentation
Circuits (Eulerian and Hamiltonian) Ioan Despi despi@turing.une.edu.au University of New England July 25, 2013 Outline 1 Recall 2 Bridges of K onigsberg 3 The Traveling Salesperson Problem 4 Eulerian 5 Eulers Theorem 6 Hamiltonian 7
University of New England
July 25, 2013
1 Recall 2 Bridges of K¨
3 The Traveling Salesperson Problem 4 Eulerian 5 Euler’s Theorem 6 Hamiltonian 7 Fleury’s Algorithm
Ioan Despi – Discrete Mathematics 2 of 31
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices. Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself! Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself!
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself!
◮ A loop adds 2 to the degree of a vertex! Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself!
◮ A loop adds 2 to the degree of a vertex!
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself!
◮ A loop adds 2 to the degree of a vertex!
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself!
◮ A loop adds 2 to the degree of a vertex!
◮ Paths are specified by listing adjacent vertices from the beginning of the
Ioan Despi – Discrete Mathematics 3 of 31
◮ The edges of a graph express the relationships among the vertices.
◮ If a vertex has a loop, the vertex is adjacent to itself!
◮ A loop adds 2 to the degree of a vertex!
◮ Paths are specified by listing adjacent vertices from the beginning of the
Ioan Despi – Discrete Mathematics 3 of 31
Ioan Despi – Discrete Mathematics 4 of 31
Ioan Despi – Discrete Mathematics 4 of 31
◮ The resulting pieces of a disconnected graph are called components of the
Ioan Despi – Discrete Mathematics 4 of 31
◮ The resulting pieces of a disconnected graph are called components of the
Ioan Despi – Discrete Mathematics 4 of 31
Ioan Despi – Discrete Mathematics 5 of 31
1 Represent the problem as a graph. 2 Represent the problem using predicate calculus: devise a predicate and
3 Are the two representations equivalent? 4 Try to solve the problem (optional). Ioan Despi – Discrete Mathematics 6 of 31
Ioan Despi – Discrete Mathematics 7 of 31
Ioan Despi – Discrete Mathematics 7 of 31
Ioan Despi – Discrete Mathematics 8 of 31
Ioan Despi – Discrete Mathematics 9 of 31
Ioan Despi – Discrete Mathematics 9 of 31
Ioan Despi – Discrete Mathematics 9 of 31
Ioan Despi – Discrete Mathematics 9 of 31
Ioan Despi – Discrete Mathematics 10 of 31
Ioan Despi – Discrete Mathematics 11 of 31
Ioan Despi – Discrete Mathematics 11 of 31
Ioan Despi – Discrete Mathematics 11 of 31
Ioan Despi – Discrete Mathematics 11 of 31
Ioan Despi – Discrete Mathematics 11 of 31
Ioan Despi – Discrete Mathematics 11 of 31
30 30 25 40 50 35 B A C D
Ioan Despi – Discrete Mathematics 12 of 31
A AB AC AD ABC ABCD ABCDA ABD ABDC ABDCA ACB ACBD ACBDA ACD ACDB ACDBA ADB ADBC ADBCA ADC ADCB ADCBA 30 50 40 30 35 30 25 35 25 25 25 35 35 30 30 40 50 40 30 50 30 125 140 155 140 155 125
Ioan Despi – Discrete Mathematics 13 of 31
Ioan Despi – Discrete Mathematics 14 of 31
Ioan Despi – Discrete Mathematics 15 of 31
Ioan Despi – Discrete Mathematics 15 of 31
Ioan Despi – Discrete Mathematics 15 of 31
Ioan Despi – Discrete Mathematics 15 of 31
Ioan Despi – Discrete Mathematics 16 of 31
Ioan Despi – Discrete Mathematics 16 of 31
◮ An Eulerian circuit is a type of Eulerian path, but
a b c d e
a b d e
Ioan Despi – Discrete Mathematics 16 of 31
◮ An Eulerian circuit is a type of Eulerian path, but ◮ An Eulerian path is not necessarily an Eulerian circuit.
a b c d e
a b d e
Ioan Despi – Discrete Mathematics 16 of 31
◮ An Eulerian circuit is a type of Eulerian path, but ◮ An Eulerian path is not necessarily an Eulerian circuit.
a b c d e
a b d e
Ioan Despi – Discrete Mathematics 16 of 31
◮ An Eulerian circuit is a type of Eulerian path, but ◮ An Eulerian path is not necessarily an Eulerian circuit.
a b c d e
a b d e
Ioan Despi – Discrete Mathematics 16 of 31
1 G has an Eulerian circuit (i.e., is Eulerian) if and only if every vertex of G
Ioan Despi – Discrete Mathematics 17 of 31
1 G has an Eulerian circuit (i.e., is Eulerian) if and only if every vertex of G
2 G has an Eulerian path, but not an Eulerian circuit, if and only if G has
Ioan Despi – Discrete Mathematics 17 of 31
1 G has an Eulerian circuit (i.e., is Eulerian) if and only if every vertex of G
2 G has an Eulerian path, but not an Eulerian circuit, if and only if G has
◮ The Eulerian path in this case must start at any of the two ’odd-degree’
Ioan Despi – Discrete Mathematics 17 of 31
1 G has an Eulerian circuit (i.e., is Eulerian) if and only if every vertex of G
2 G has an Eulerian path, but not an Eulerian circuit, if and only if G has
◮ The Eulerian path in this case must start at any of the two ’odd-degree’
Ioan Despi – Discrete Mathematics 17 of 31
1 G has an Eulerian circuit (i.e., is Eulerian) if and only if every vertex of G
2 G has an Eulerian path, but not an Eulerian circuit, if and only if G has
◮ The Eulerian path in this case must start at any of the two ’odd-degree’
Ioan Despi – Discrete Mathematics 17 of 31
Ioan Despi – Discrete Mathematics 18 of 31
◮ If we traverse all edges, we build an Eulerian cycle, ◮ otherwise, consider a subgraph H obtained from the original graph by
⋆ Each vertex of H has even degree. In the above left picture (Figure 6),
⋆ The original graph and H must have one vertex in common. We start with
Ioan Despi – Discrete Mathematics 19 of 31
Ioan Despi – Discrete Mathematics 20 of 31
Ioan Despi – Discrete Mathematics 20 of 31
Ioan Despi – Discrete Mathematics 20 of 31
Ioan Despi – Discrete Mathematics 20 of 31
Ioan Despi – Discrete Mathematics 20 of 31
1 Due to the above Euler’s theorem, the seven bridge problem has no
2 In the graph from Figure 8: v1 − e1 − v2 − e2 − v2 − e3 − v3 − e4 − v1 is
3 The graph in Figure 9 has an Eulerian path but is not Eulerian.
v1 v2 v3 e1 e3 e4 e2
4 K3 is an Eulerian graph, but K4 is not Eulerian. Ioan Despi – Discrete Mathematics 21 of 31
Ioan Despi – Discrete Mathematics 22 of 31
Ioan Despi – Discrete Mathematics 22 of 31
Ioan Despi – Discrete Mathematics 22 of 31
Ioan Despi – Discrete Mathematics 22 of 31
Ioan Despi – Discrete Mathematics 22 of 31
Ioan Despi – Discrete Mathematics 22 of 31
◮ for an Euler path you may visit each vertex more than once and ◮ in a Hamilton path it is not necessary to travel every edge.
v1 v2 v3 e1 e3 e4 e2
Ioan Despi – Discrete Mathematics 23 of 31
Ioan Despi – Discrete Mathematics 24 of 31
Ioan Despi – Discrete Mathematics 25 of 31
Ioan Despi – Discrete Mathematics 25 of 31
Ioan Despi – Discrete Mathematics 25 of 31
Ioan Despi – Discrete Mathematics 26 of 31
Ioan Despi – Discrete Mathematics 26 of 31
Ioan Despi – Discrete Mathematics 26 of 31
Ioan Despi – Discrete Mathematics 27 of 31
Ioan Despi – Discrete Mathematics 27 of 31
Ioan Despi – Discrete Mathematics 28 of 31
1 Check if the graph is connected and it has either 0 or 2 odd vertices.
Ioan Despi – Discrete Mathematics 29 of 31
1 Check if the graph is connected and it has either 0 or 2 odd vertices.
2 If there are 0 odd vertices, pick any vertex to start.
Ioan Despi – Discrete Mathematics 29 of 31
1 Check if the graph is connected and it has either 0 or 2 odd vertices.
2 If there are 0 odd vertices, pick any vertex to start.
3 While the graph contains at least one edge: Ioan Despi – Discrete Mathematics 29 of 31
1 Check if the graph is connected and it has either 0 or 2 odd vertices.
2 If there are 0 odd vertices, pick any vertex to start.
3 While the graph contains at least one edge: 1 If you have a choice, always pick an edge that is not a bridge. Ioan Despi – Discrete Mathematics 29 of 31
1 Check if the graph is connected and it has either 0 or 2 odd vertices.
2 If there are 0 odd vertices, pick any vertex to start.
3 While the graph contains at least one edge: 1 If you have a choice, always pick an edge that is not a bridge. 2 Traverse that edge, and remove it from G. Ioan Despi – Discrete Mathematics 29 of 31
Ioan Despi – Discrete Mathematics 30 of 31
Ioan Despi – Discrete Mathematics 30 of 31
Ioan Despi – Discrete Mathematics 30 of 31
Ioan Despi – Discrete Mathematics 30 of 31
Ioan Despi – Discrete Mathematics 30 of 31
Ioan Despi – Discrete Mathematics 30 of 31
Ioan Despi – Discrete Mathematics 31 of 31
Ioan Despi – Discrete Mathematics 31 of 31
Ioan Despi – Discrete Mathematics 31 of 31
e6
e7
e8
e9
e5
e3
e2
e1
e4
Ioan Despi – Discrete Mathematics 31 of 31