Вы находитесь на странице: 1из 47

Department of Futures Studies

EULER GRAPHS,HAMILTONION GRAPHS & TRAVELLING SALESMAN PROBLEM


1

Lekshmi Krishna M.R 100609|Mtech-Technology Management Department of Futures Studies University of Kerala

Contents
2

Introduction Euler Graphs Theorems, Proof & Algorithms Hamiltonian Graphs Traveling Sales Man problems Conclusion
Department of Futures Studies

Introduction
3

Configurations of nodes & connections occur in great diversity of applications Such configurations are modeled by combinatorial structures called Graphs Consist of edges ,vertices & incidence relation between them E.g. : Electrical circuits, road ways, organic molecules etc
Department of Futures Studies

Euler Graphs
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

Department of Futures Studies

Euler's Theorem 1
5

A graph G contains an Eulerian circuit if and only if the degree of each vertex is even.

Department of Futures Studies

Proof
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 same number of times, and it follows that deg(v) must be even.

Department of Futures Studies

Example
7

1 1 2 5

3 3 4

Here all nodes are of degree 2(even degree) 1-2-3-1 Forms Euler graph

Node 3 is of odd degree(3) No Eulerian path


Department of Futures Studies

Proof of Sufficiency
8

We prove by induction on the number of edges. For graphs with all vertices of even degree, the smallest possible number of edges is 3 (i.e. a triangle) in the case 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 every vertex of H has even degree, H contains an Eulerian circuit
Department of Futures Studies

Variations of Eulerian Paths


9

1) Handshaking Lemma - Every graph has even number of odd degree vertices.

Department of Futures Studies

Proof
10

Consider the sum of the degree of all the vertices, S=u


v

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 = u v deg (u) = u v even deg (v) + u v odd deg (w); the number w v odd deg (w) must be even Thus we can say that |Vodd| must be even

Department of Futures Studies

11

2) Theorem 2. A graph contains an Eulerian path if and only if there are 0 or 2 odd degree vertices

Department of Futures Studies

Proof
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. When the starting and final vertices are distinct, there are precisely 2 odd degree vertices. When these two vertices coincide, there is no odd degree vertex.

Department of Futures Studies

Variation : 2 (Directed graphs)


13

Let D = (V;A) be a directed graph. Then D contains an Eulerian circuit if and only if, for every vertex u 2 V , indeg(u) = outdeg(v). Furthermore, D contains an Eulerian path if and only if, there exists two vertices s and t such that: outdeg(s) = indeg(s) + 1 indeg(t) = outdeg(t) + 1 indeg(v) = outdeg(v)
Department of Futures Studies

Example:
14

According to the theorem outdeg(s) = indeg(s) + 1 indeg(t) = outdeg(t) + 1 indeg(v) = outdeg(v)

B S T C

S-B-F-E-T-C-B-T-S Euler ian circuit


E

Indeg(s) = 0 Outdeg(s)= 1 Indeg(t)=2 Outdeg (t)=1 Indeg(v) = 7 Outdeg (v)= 7

B S T C

S-B-F-E-T-C-B-T Euler ian Path


Department of Futures Studies

Some facts.
15

Euler's Theorems are examples of Existence theorems Existence theorems tell whether or not something exists (e.g. Euler circuit) 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 are called algorithms An algorithm for constructing an Euler circuit: Fleury's algorithm
Department of Futures Studies

Fleury's algorithm
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.

Department of Futures Studies

Example:
17

Department of Futures Studies

Formulation of Euler circuit using Fleurys Algorithm


18

Marked Graph

Reduced graph

Department of Futures Studies

Cont.
19

The rest of the trip is obvious, and the complete Euler circuit is: (F, C, D, A, C, E, A, B, D, F)
Department of Futures Studies

Hamiltonian Graph
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.
Department of Futures Studies

Example:
21

1 1

2 1-2-3

Hamiltonian graph

4 1-2-3-4-3-1 Not Hamiltonian


Department of Futures Studies

4 1-2-4-3 1-4-2-3 Many Hamiltonian paths

22

1 Every vertex is connected to all other vertex-Complete graph - Hamiltonian

Department of Futures Studies

Optimal Graph Traversals


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

Department of Futures Studies

Hamiltonian Type Problems


24

Involve vertex based conditions No simple characterization is known Problems are notoriously time consuming (NP hard)

Department of Futures Studies

Traveling Salesman Problem (TSP)


25

Defined by W. R. Hamilton and Thomas Kirkman 1800s

Department of Futures Studies

As Graph Problem
26

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 he started

Modeled as undirected weighted graph Cities Vertices Path- Edges Path distance/cost = Edge length

Department of Futures Studies

Five City Travel Problem


27

Salesman wanted to travel 5 cities Want to reach back to the starting city Assumption : Possible to travel from one city to all the other cities Forms complete graph Cost of travel from one city to another is denoted by C Problem :To minimize the cost of travel ????
Department of Futures Studies

28

Find the feasible solutions ?

Department of Futures Studies

29

1-3-5-4-2-1 5-4-2-1-3-5
3

5-1-4-3-2-5 3-2-5-1-4-3
3

1
Department of Futures Studies

n nodes (n -1)! feasible solutions

Cost of Travel
30

Z =

10 8 9 7

10 8 9 7 10 5 6 10 8 9 5 8 6 6 9 6

Cost of travel from a node to itself = 0 But for solving this we put as -
Department of Futures Studies

Graphical Representation
31

3
10 n nodes 8 8 6 5 9 9 6 (n 1)! feasible solution

2
10

Complete graph Hamiltonian Need to find the optimal solution

5
Department of Futures Studies

Sub Tours
32

TSP No Sub Tours Need Complete Tours 3

5
Department of Futures Studies

Formulation of TSP
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

Department of Futures Studies

Formulation of TSP (Constrains)


34

=1 i

From every city i person need to go j,and is going only one out of the remaining nodes

=1 j

If salesman in the city j then he comes to j from a unique city i

Xij = 0,1

Either go from i to j or don't go from i to j


Department of Futures Studies

Sub Tour Elimination Constrains


35

Sub tours of length 1 Xjj = 1


3

X15 X51

=1 =1

n city TSP can have n 1 length sub tours Need to eliminate these sub tours Xij +Xji 1 If X15 is in solution then X51 is not in solution

1 Sub tour of Length 2

Sub tour of Length 1


Department of Futures Studies

36

Eliminate sub tour of length 1 Xjj = 0 - Diagonal assignments Sub tours of length 1 ;hence we can say that Cjj = infinity Eliminate sub tour of length 2 Xij+Xji 1 nC2
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 k terms k-1
Department of Futures Studies

37

Have large number of constrains Exponentially increasing constrains

How to eliminate this????

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 it should be included in sub tours of 2 & 1 hence by eliminating 1 & 2 Sub tour of length 3 also get eliminated Likewise sub tour of length 4 too Hence for 5 city problem we need to eliminate sub tours of length 1 & 2

Department of Futures Studies

5 CITY = Eliminate length of 1 & 2 7 CITY =Eliminate length of 1,2 & 3

Length of 1 is always eliminated by using the constrain Cjj = infinity

40

If n is odd, number of constrains is given by

If n is even , number of constrains is given by Still the number of constrains in TSP is large.....

Department of Futures Studies

Another method
41

Ui - Uj + n Xij n-1

i = 1,2..n-1 j = 2,3...n-1

Here we have n^2 constrains How does this works?

Department of Futures Studies

42

Consider the sub tours 1-2-3-1 & 4-5-4

Department of Futures Studies

43

Ui - Uj + n Xij n-1

i = 1,2..n-1 j = 2,3...n-1

U1- U2 -5X12 4 U2- U3 +5X23 4 U1-U3 + 10 8 U4 U5 + 5 4 U5 U4 + 5 4 10 8

1-2-3-1

4-5-4

Need to find solution which satisfies this conditions


Department of Futures Studies

Solution
44

Branch & Bound Algorithm Heuristic Algorithm

Department of Futures Studies

Applications of TSP
45

Logistics Planning DNA sequencing Manufacture of Microchips

Department of Futures Studies

46

Thank you!!!!
Department of Futures Studies

Reference
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

Department of Futures Studies

Вам также может понравиться