Upload
lekshmi-nair
View
228
Download
0
Embed Size (px)
Citation preview
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 1/47
EULER GRAPHS,HAMILTONIONGRAPHS & TRAVELLING SALESMAN
PROBLEM
Lekshmi Krishna M.R
100609|Mtech-Technology Management
Department of Futures Studies
University of Kerala
Department of Futures Studies 1
1
2 3
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 2/47
Contents
Department of Futures Studies
2
I ntroduction
Euler Graphs
Theorems, Proof & Algorithms
Hamiltonian Graphs
Traveling Sales Man problems
Conclusion
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 3/47
I ntroduction
Department of Futures Studies
3
Configurations of nodes & connections occur in greatdiversity of applications
Such configurations are modeled by combinatorialstructures called Graphs
Consist of edges ,vertices & incidence relationbetween them
E.g. : Electrical circuits, road ways, organic moleculesetc
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 4/47
Euler Graphs
Department of Futures Studies
4
An Eulerian trail in a graph is a trail that contains
every edge of that graph
An Eulerian tour is a closed Eulerian trail
A graph that has an Euler tour (Circuit) is called an
Eulerian graph
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 5/47
Euler's Theorem 1
Department of Futures Studies
5
A
graph G contains an Eulerian circuit if and only ifthe degree of each vertex is even.
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 6/47
Proof
Department of Futures Studies
6
Suppose G contains an Eulerian circuit C. Then, for
any choice of vertex v, C contains all the edges that
are adjacent to v. Furthermore, as we traverse
along C, we must enter and leave v the samenumber of times, and it follows that deg(v) must be
even.
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 7/47
Example
Department of Futures Studies
7
1
2 3
Here all nodes are of degree 2(even degree) 1-2-3-1 Forms Euler graph
4
1
2 5
3
Node 3 is of odddegree(3)
No Eulerian path
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 8/47
Proof of Sufficiency
Department of Futures Studies
8
We prove by induction on the number of edges. Forgraphs with all vertices of even degree, the smallestpossible number of edges is 3 (i.e. a triangle) in thecase of simple graphs. In both cases, the graph
trivially contains an Eulerian circuit.
The Induction hypothesis then says:
Let H be a connected graph with k edges. If everyvertex of H has even degree, H contains an Euleriancircuit
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 9/47
V ariations of Eulerian Paths
Department of Futures Studies
9
1) Handshaking Lemma - Every graph has even
number of odd degree vertices.
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 10/47
Proof
Consider the sum of the degree of all the vertices,
S=�uv deg (u)
In this sum, every edge (a,b) in the graph gets counted twice: Once for a &
once for b.
Therefore S = 2m is an even number.
Now let Vodd (Veven) denote the subset of V that consists only of odd(even
respectively) degree vertices.
Since S =� uv deg (u) =� uv even deg (v) + � uv odd deg (w);
the number � wv odd deg (w) must be evenThus we can say that |Vodd| must be even
Department of Futures Studies
10
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 11/47
Department of Futures Studies
11
2
) Theorem2
.A
graph contains an Eulerian path ifand only if there are 0 or 2 odd degree vertices
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 12/47
Proof
Department of Futures Studies
12
Suppose a graph G contains an Eulerian path P.
Then, for every vertex v, P must enter and leave v
the same number of times, except when it is either
the starting vertex or the final vertex of P. Whenthe starting and final vertices are distinct, there are
precisely 2 odd degree vertices. When these two
vertices coincide, there is no odd degree vertex.
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 13/47
V ariation : 2 (Directed graphs)
Department of Futures Studies
13
Let D = (V;A) be a directed graph. Then D containsan Eulerian circuit if and only if, for every vertex u 2 V , indeg(u) = outdeg(v).
Furthermore, D contains an Eulerian path if and onlyif, there exists two vertices s and t such
that:
outdeg(s) = indeg(s) + 1
indeg(t) = outdeg(t) + 1
indeg(v) = outdeg(v)
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 14/47
Example:
Department of Futures Studies
14
B
C
T
S
F
E
According to the theoremoutdeg(s) = indeg(s) + 1indeg(t) = outdeg(t) + 1
indeg(v) = outdeg(v)
S-B-F-E-T-C-B-T-SEuler ian circuit
B
C
T
S
F
E
Indeg(s) = 0
Outdeg(s)= 1Indeg(t)=2Outdeg (t)=1Indeg(v) = 7
Outdeg (v)= 7 S-B-F-E-T-C-B-TEuler ian Path
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 15/47
Some facts«.
Department of Futures Studies
15
Euler's Theorems are examples of Existence theorems
Existence theorems tell whether or not something exists (e.g. Eulercircuit)
But doesn't tell us how to create it!
We want a constructive method for finding Euler paths and circuits
Methods (well-defined procedures, recipes) for construction arecalled algorithms
An algorithm for constructing an Euler circuit: Fleury's algorithm
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 16/47
F leury's algorithm
Department of Futures Studies
16
1. Check if the graph is connected, and every
vertex is of even degree. Reject otherwise.
2. Pick any vertex v(start) to start.
3. While the graph contains at least one edge:
(a) Pick an edge that is not a bridge.
(b) Traverse that edge, and remove it
from G.
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 17/47
Example:
Department of Futures Studies
17
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 18/47
F ormulation of Euler circuit using F leury·s
Algorithm
Department of Futures Studies
18
Marked Graph Reduced graph
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 19/47
Cont«.
Department of Futures Studies
19
The rest of the trip is obvious, and the complete Euler circuit is:(F,C, D,A,C, E,A, B, D, F)
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 20/47
Hamiltonian Graph
Department of Futures Studies
20
A Hamiltonian path is a path in an undirected graph
that visits each vertex exactly once.
A Hamiltonian cycle (or Hamiltonian circuit) is a
cycle in an undirected graph which visits each vertex
exactly once and also returns to the starting vertex.
A graph that contains a Hamiltonian circuit is called a
Hamiltonian graph.
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 21/47
Example:
Department of Futures Studies
21
1
32
4
1
32
1-2-3
Hamiltonian graph
1-2-3-4-3-1
Not Hamiltonian
4
1
32
1-2-4-3
1-4-2-3 Many Hamiltonian
paths
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 22/47
Department of Futures Studies
22
1
32
54
Every vertex is connected to all other
vertex-Complete graph - Hamiltonian
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 23/47
O ptimal Graph Traversals
Department of Futures Studies
23
Eulerian Trails & Tours
Each edge be traversed at least once
Postman problems
Hamiltonian paths and Cycles
Each vertex be traversed at least once
Traveling Salesman problems
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 24/47
Hamiltonian Type Problems
Department of Futures Studies
24
Involve vertex based conditions
No simple characterization is known
Problems are notoriously time consuming
(NP hard)
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 25/47
Traveling Salesman Problem (TSP)
Department of Futures Studies
25
Defined by W. R. Hamilton and Thomas Kirkman -
1800·s
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 26/47
As Graph Problem
Traveling salesman must travel to every city along the cheapest route
But he cannot visit a city more than once and he must come back where hestarted
� Modeled as undirected weighted graph
� Cities Vertices� Path- Edges� Path distance/cost = Edge length
26
Department of Futures Studies
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 27/47
F ive City Travel Problem
Department of Futures Studies
27
Salesman wanted to travel 5 cities
Want to reach back to the starting city
Assumption : Possible to travel from one city to allthe other cities
Forms complete graph
Cost of travel from one city to another is denoted by¶C·
Problem :To minimize the cost of travel ????
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 28/47
Department of Futures Studies
28
51
4
3
2
Find the feasible solutions ?
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 29/47
Department of Futures Studies
29
1-3-5-4-2-1 5-1-4-3-2-5
5-4-2-1-3-5 3-2-5-1-4-3
51
4
3
2
51
4
3
2
� n nodes
� (n -1)! feasible
solutions
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 30/47
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 31/47
Graphical Representation
Department of Futures Studies
31
3
51
42
10
10 8
6
7
85
96
9
� n nodes
� (n ± 1)! feasible solution
� Complete graph
� Hamiltonian
� Need to find the optimal solution
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 32/47
Sub Tours
Department of Futures Studies
32
3
2
1 5
4
TSP
No Sub Tours
NeedCompleteTours
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 33/47
F ormulation of TSP
Department of Futures Studies
33
X ij = 1 | If the person goes from i to j|
Objective ± To minimize total cost/distance of
travel
Objective function : Min �� Cij Xij
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 34/47
F ormulation of TSP (Constrains)
Department of Futures Studies
34
= 1 ¥ i
= 1 ¥ j
From every city i person need to go j,and is going only one out of theremaining nodes
If salesman in the city j then hecomes to j from a unique city i
Xij = 0,1 Either go from i to j or don't go
from i to j
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 35/47
Sub Tour Elimination Constrains
Department of Futures Studies
35
Sub tours of length 1
X jj = 1
X15 = 1X51 = 1
n city TSP ± can have n ± 1 length sub toursNeed to eliminate these sub tours
Xij +X ji � 1
If X15 is in solution then X51 is not in solution
2
1 5
4
3
Sub tour of Length 1
Sub tour of Length 2
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 36/47
Department of Futures Studies
36
Eliminate sub tour of length 1
Xjj = 0 - Diagonal assignments Sub tours of length 1 ;hencewe can say that Cjj = infinity
Eliminate sub tour of length 2 Xij+Xji 1 nC2
Eliminate sub tour of length 3
Xij + Xjk + Xki 2 nC3
To eliminate sub tours of length k we need to do up to kterms k-1
nC2
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 37/47
Department of Futures Studies
37
Have large number of constrains
Exponentially increasing constrains
How to eliminate this????
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 38/47
Department of Futures Studies
38
Need to eliminate sub tours of length 1,2,3 & 4
If there is a sub tour of length 3,then automatically itshould be included in sub tours of 2 & 1 hence by
eliminating 1 & 2 Sub tour of length 3 also geteliminated Likewise sub tour of length 4 too
Hence for 5 city problem we need to eliminate subtours of length 1 & 2
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 39/47
5 CITY = Eliminate length of 1 & 2
7 CITY =Eliminate length of 1,2 & 3
Length of 1 is always eliminated by using theconstrain Cjj = infinity
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 40/47
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 41/47
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 42/47
Department of Futures Studies
42
Consider the sub tours 1-2-3-1 & 4-5-4
3
2
1 5
4
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 43/47
Department of Futures Studies
43
Ui - U j + n Xij � n-1 i = 1,2««..n-1 j = 2,3««...n-1
U1- U2 -5X12 � 4
U2- U3 +5X23 � 4 1-2-3-1U1-U3 + 10 � 8
U4 ± U5 + 5 � 4 4-5-4U5 ± U4 + 5 � 4
10 � 8
Need to find solution which satisfiesthis conditions
3
2
1 5
4
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 44/47
Solution
Department of Futures Studies
44
Branch & Bound Algorithm
Heuristic Algorithm
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 45/47
Applications of TSP
Department of Futures Studies
45
Logistics
Planning
DNA sequencing
Manufacture of Microchips
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 46/47
Department of Futures Studies
46
Thank you!!!!
8/4/2019 Eulerian Graphs
http://slidepdf.com/reader/full/eulerian-graphs 47/47
Reference
Department of Futures Studies
47
Graph Theory & Its Applications : Jonathan Gross & Jay Yellan
Basic Graph Theory : K.R Parthasarathy
Discrete structures & Graph theory :G.S.S Bhishma Rao
http://www.austincc.edu/powens/+Topics/HTML/05-6/05-6.html
http://train-srv.manipalu.com/wpress/?p=138948