HAMITONIAN CIRCUITS (Using Backtracking Method)
HAMITONIAN CIRCUITS (Using Backtracking Method)
05/15/12
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
05/15/12 2
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
05/15/12
Definition
Backtracking constructs its state-space tree in the depthfirst 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
05/15/12 4
Backtracking algorithm
Algorithm backtracking(X[1..i])
i=0; X[10] \ it reprints the empty tuple //Given a template of a generic backtracking algorithm //Input : X[1i] specifies first I promising components of a solution //Output: All the tuples representing the problems solutions
05/15/12
Continue
If X[1i] 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[1i + 1] )
05/15/12
a c d
b f e
05/15/12
CONTINUE
a b f c e d e c e d Dead end f Dead end
05/15/12
f Dead end
d a Found
8
05/15/12
10
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
1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16
05/15/12
12
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. 05/15/12 13
REFERENCES
Kenneth H Rosen, 6th edition Anany levitin Elements of descrete mathematics, 2nd edition.
05/15/12
14
THANK YOU
05/15/12
15