hamitonian circuits (using backtracking method)

15
HAMITONIAN CIRCUITS (using backtracking method) 06/06/22 1

Upload: manaskumar23

Post on 23-Oct-2014

1.713 views

Category:

Documents


14 download

TRANSCRIPT

Page 1: HAMITONIAN CIRCUITS  (Using Backtracking Method)

HAMITONIAN CIRCUITS (using backtracking method)

04/07/23 1

Page 2: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Agenda Definition of Hamiltonian

Definition of backtracking method

Backtracking algorithm

Example (using backtracking method)

Relationship between Hamiltonian and Tsp

Euler an circuit versus Hamiltonian circuit

Conclusion

References 04/07/23 2

Page 3: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Definition A hamiltonian circuit in a connected graph defined as a

closed walk that traverse every vertex of G exactly once

except the starting vertex at which the walk also terminate

A graph possessing a hamiltonian circuit is said to be a

hamiltonian graph. The hamiltonian circuit is names after sir

William Rowan Hamilton

04/07/23 3

Page 4: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Definition

Backtracking constructs its state-space tree in the depth–

first search fashion in the majority of its applications

If the sequence of choices represented by a current node of

the state-space tree can be developed further without

violating the problems constraints

It is done by considering the first remaining legitimate

option for the next component of the partially built solution

and replace it by the next alternative

04/07/23 4

Page 5: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Backtracking algorithm

Algorithm backtracking(X[1…..i])

i=0; X[1…0] \ it reprints the empty tuple

//Given a template of a generic backtracking algorithm

//Input : X[1…i] specifies first I promising components of a

solution

//Output: All the tuples representing the problems solutions

04/07/23 5

Page 6: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Continue…If X[1…i] is a solution write X[1…..i]

Else

For each element x € S i+1 consistent with X[1…..i] and the

constraints

Do

X[i…..1] x

Backtrack (X[1…i + 1] )

04/07/23 6

Page 7: HAMITONIAN CIRCUITS  (Using Backtracking Method)

EXAMPLE FOR HAMILTON CIRCUIT (USING BACKTRACKING METHOD)

04/07/23 7

a b

c

d e

f

Page 8: HAMITONIAN CIRCUITS  (Using Backtracking Method)

CONTINUE…

04/07/23 8

a

b

c

d

e

f

e

d f

f

e

c

d

aDead end

Dead end Dead end

Found

Page 9: HAMITONIAN CIRCUITS  (Using Backtracking Method)

RELATION BETWEEN HAMILTON AND TSP

An optimal Hamilton circuit of a graph is one with the

smallest possible weight. There can be more than one.

The problem of finding an optimal Hamilton circuit in a

complete weighted graph is often called TSP(Traveling salesman

problem).

Commonly referred to as a TSP it simulates a salesman who

must visit each node preferably once go home at the end of the

day and have traveled the least distance needed. Any path the

salesman takes is a Hamiltonian circuit.04/07/23 9

Page 10: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Eulerian circuit versus Hamiltonian circuit

An eulerian circuit passes along each edge once and only once both are useful in application the Hamiltonian circuit when it is required to visit each vertex and the eulerian circuits when it is required to travel along all the connecting edges.

04/07/23 10

Euler an circuit not a Hamiltonian Hamiltonian circuit but

not a euler an

Page 11: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Eulerian circuit versus Hamiltonian circuit

Condition for there to be Euler an circuits are well know but in

general it is a difficult problem to decide when a given graph has

a Hamiltonian circuit. Finding condition for the existence of

Hamiltonian circuit is an unsolved problem.

The degree of the vertex is the number of edges joining onto that

vertex, and vertices are said to be odd or even.

Euler circuit exist only in networks where there are no odd

vertices, that is where all the vertices have an even number of

edges ending there.

04/07/23 11

Page 12: HAMITONIAN CIRCUITS  (Using Backtracking Method)

Knight queue

Is a chess piece that can be move either to spaces horizontal one space vertical or one space horigentally and two space vertically.

Knight on square (x,y) can move to any of the eight squares(x

04/07/23 12

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

Page 13: HAMITONIAN CIRCUITS  (Using Backtracking Method)

• Knight tour is a sequence of legal moves by a knight starting at some square and visiting each square exactly once.

• A knight tour is a i.e reentrant if there is a legal move that take the knight from the last square of the tour back to where the tour begin.

• We draw the chess board and move of knight as a graph• i.e all cells numbers 1 to 16 are vertices say vi & vj are

adjecent if knight could reach jth cell from the ith cell.• If we able find a hemiltonion circuit in the draws graph

then the problem is addressed.04/07/23 13

Page 14: HAMITONIAN CIRCUITS  (Using Backtracking Method)

REFERENCES

Kenneth H Rosen, 6th edition

Anany levitin

Elements of descrete mathematics, 2nd edition.

04/07/23 14

Page 15: HAMITONIAN CIRCUITS  (Using Backtracking Method)

THANK YOU…

04/07/23 15