knure, software department, ph. 7021-446, e-mail: [email protected] n.v. bilous faculty of...
TRANSCRIPT
KNURE, Software department,Ph. 7021-446, e-mail: [email protected]
NN..VV. . BilousBilous
Faculty of computer sciencesSoftware department, KNURE
An Euler and An Euler and HamiltonHamilton paths paths and circuitsand circuits
Discrete mathematicsDiscrete mathematics..
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 2
The task of Königsberg bridge problemThe task of Königsberg bridge problem
The Seven Bridges of Königsberg. Whether it is possible to start at some location in the town, travel across all the bridges without crossing any bridge twice, and return to the starting point.
The Seven Bridges of Königsberg
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 3
The task of Königsberg bridge problemThe task of Königsberg bridge problem
Euler studied this problem using the multigraph obtained when the four regions are represented by vertices and the bridges by edges.
The question becomes: Is there a simple circuit in this multigraph that contains every edge.
Multigraph Model of the Town of Königsberg
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 4
An Euler circuit. An Euler pathAn Euler circuit. An Euler path
An Euler circuit in a graph G is a simple circuit containing every edge of G.
An Euler path in G is a simple path containing every edge of G .
Example
Have the undirected graph G an Euler circuit, an Euler path.
The graph G has an Euler circuit:
V1, V2, V3, V4, V6, V5, V4, V2, V6, V1
The graph G does not have an Euler path.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 5
An Euler circuit. An Euler pathAn Euler circuit. An Euler path
Example
Which of the directed graphs have an Euler circuit? Of those
that do not, which have an Euler path?
The graph H2 has an Euler circuit a, g, c, b, g, e, d, f,
a. Neither H1 nor H3 has an Euler circuit.
H3 has an Euler path
c, a, b, e, d, b,
but H1 does not.
d
f a
g
H1
ba
d c
H2
be
c
c
b
d
H3
a
The Directed Graphs H1, H2, and H3
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 6
Necessary and sufficient conditions for Euler CircuitNecessary and sufficient conditions for Euler Circuit
Euler Theorem. A connected multigraph has an Euler circuit if and only if each of its vertices has even degree.
The graph, containing an Euler circuit is called an Euler graph.
ExampleThe graph G is connected.
deg(V1)=2 deg(V4)=4
deg(V2)=4 deg(V5)=2
deg(V3)=2 deg(V6)=4All vertices have even degrees, then G is Euler graph.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 7
Constructing Euler CircuitsConstructing Euler Circuits
Algorithm Constructing Euler Circuits.procedure Euler (G: connected multigraph with all vertices of even degree)
circuit: = a circuit in G beginning at an arbitrarily chosenvertex with edges successively added to form a path that returns to this vertex
H: = G with the edges of this circuit removedwhile H has edges begin subcircuit: = a circuit in H beginning at a vertex in H that also is
an endpoint of an edge of circuitH: = H with edges of subcircuit and all isolated vertices removedcircuit: = circuit with subcircuit inserted at the appropriate
vertexend {circuit is an Euler circuit}
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 8
Necessary and sufficient conditions for Euler PathsNecessary and sufficient conditions for Euler Paths
A connected multigraph has an Euler path but not an Euler circuit if and only if it has exactly two vertices of odd degree.
ExampleWhich graphs have an Euler path?
G1 contains exactly two vertices of odd degree b and d. Hence it has an Euler path that must have b and d as its endpoints.
d
b
a c
a
f
b
e
c
d
gG1 G2
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 9
Necessary and sufficient conditions for Euler PathsNecessary and sufficient conditions for Euler Paths
Continuation of an example
One such Euler path is d, a, b, c, d, b. Similarly, G2
has no Euler path since it has six vertices of odd degree.
d
b
a c
a
f
b
e
c
d
g
G1 G2
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 10
The The puzzlepuzzle of of Mohammed's scimitarsMohammed's scimitars
Mohammed's scimitars can be drawn with using Euler circuits and paths. In this way where the drawing begins and ends at the same point.
a
kg
h
jif
c
b
e
d
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 11
AA Hamilton path Hamilton path. A. A Hamilton circuit Hamilton circuit
A path x0, x1,…, xn-1, xn in the graph G = (V, E) is called a
Hamilton path if V = {x0, x1,…, xn-1,. xn} and
xi≠ xj for 0 ≤ i <j ≤ n.
A circuit x0 , x1 ,…, xn-1, xn, x0 (with n > 1) in a graph G = (V, E)
is called a Hamilton circuit if x0, x1,…, xn-1, xn, x0, is a Hamilton path.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 12
Hamilton’s puzzleHamilton’s puzzle
Hamilton's puzzle consisted of a wooden dodecahedron (a polyhedron with 12 regular pentagons as faces).
Is there a circuit in the graph that passes through each vertex exactly once?
Hamilton's "Round the World" Puzzle.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 13
A Hamilton graphA Hamilton graph
Graph in which exists Hamilton circuit is called a Hamilton graph
Example
Which of the simple graphs have a Hamilton circuit or, if not, a Hamilton path?
a, b, c, d, e, a is a Hamilton circuit in G1.
e
a
d
a
d c
b
fc
b ga
e c
b
d
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 14
A Hamilton graphA Hamilton graph
Continuation of an example
There is no Hamilton circuit in G2, but G2 does
have a Hamilton path a, b, c, d.
G3 has neither a Hamilton circuit nor a Hamilton
path since any path containing all vertices must contain one of the edges {a, b}, {e, f}, and {c, d} more than once.
e
a
d
a
d c
ba
e c
b
d
fc
b g
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 15
Necessary conditions for existence of Necessary conditions for existence of Hamilton circuitsHamilton circuits
Necessary conditions for existence of Hamilton circuits:
1. The graph G should be connected.
2. For the graph G cuts and bridges are absent.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 16
Sufficient conditions for existence of Hamilton Sufficient conditions for existence of Hamilton circuits circuits
The theorem.
If graph G is a connected simple graph with more then 2 vertices, then graph G has a Hamilton circuit if the degree of each vertex is at least n/2.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 17
Sufficient conditions for existence of Hamilton Sufficient conditions for existence of Hamilton circuitscircuits
Ore theorem. If in the graph G with n vertices (n 3) the sum of
degrees of any two vertices u, v is not smaller than n (deg u + deg v n),
That the graph G is a Hamilton graph.
König theorem. In the complete directed graph G (which any pair
vertices incorporates even in one direction) always exists Hamilton path .
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 18
Roberts - Flores algorithm about HamiltonRoberts - Flores algorithm about Hamilton circuitscircuits presence on the graph presence on the graph
Build a matrix M. Each columns corresponds to each vertex of the graph. Each elements of column specify vertex that incidence to initial vertex (for undirected graph) or is the end of arc that go out from initial vertex (for the directed graph).
a b c d e f b c a c c a
M = e d f d b c
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 19
Roberts - Flores algorithm about HamiltonRoberts - Flores algorithm about Hamilton circuitscircuits presence on the graphpresence on the graph
Begin with vertex a, assume that
G´ ={а}.
Then add vertices, using a matrix M as follows:
1) From a column a: get out every possible
G´ = {а,b}.
2) From a column b: G´ = {а,b,с}.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 20
Roberts - Flores algorithm about HamiltonRoberts - Flores algorithm about Hamilton circuitscircuits presence on the graphpresence on the graph
3) From a column с, the first vertex a is not possible because it is already chosen earlier. Add the following vertex d.
In a result, G´ = {a, b, c, d, f}.
4) From a column f : all vertices a, b, c exist in G. In column f there are no possible variants come back on one step.
N.V.Belous 5.Euler and Hamilton Circuits and Paths. 21
Roberts - Flores algorithm about HamiltonRoberts - Flores algorithm about Hamilton circuitscircuits presence on the graphpresence on the graph
5) In columns d and c also there are no vertices after f and d, means, again come back.
G´ = {a,b}.
6) In column b add vertex е, then c,d,f.
G´1 = {a,b,e,c,d,f} – Hamilton path . The arc (f, a)
gives Hamilton circuit.
G´2 = {a,b,e,d,f,c}