Professional Documents
Culture Documents
Graph Colouring and Hamiltonion Cycle
Graph Colouring and Hamiltonion Cycle
For this case it is (0, 1, 2, 4, 3, 0). This graph has some other Hamiltonian paths.
If one graph has no Hamiltonian path, the algorithm should return false.
Apply state space tree
method.set x values to
0.
Here we apply
backtracking with Depth
first search.
We make the first
starting vertex 1.
After placing 1 draw the state
space tree.
Next from one we need to try all
other possibilities. Hamiltonian
algorithm starting from 2 position
onwards. It will try to put 1 in 2
position.so already one there, if
there any vertex repeating again it
will avoid.
Then try with 2, two is already not
present, now check any edge from
1 to 2, yes. So this is valid and
draw the state space tree.
Now it go to next position.it is
already 0 now it make it as one
and check, you can see that 1 is
already there,