SCS03P076Hamiltonian Path Problem
SCS03P076Hamiltonian Path Problem
If it contains HP :
In this case graph may have HC or may not. For
that we need to remove edge and new vertices in
the graph.
Problem Statement
Input:
A graph
Yes(If graph has HP)
No(If graph doesnt have HP)
Output:
Yes(If the graph has HC)
No(If the graph doesnt have HC)
--GRAPH
Path 1
Path 2
If the Graph has HP it may have HC or not depends on the above procedure.
Take any two vertices and join them with two new vertices
10
Path 1
Got stuck from this path
And was not able to get
HP this way.
Path 2
11
12
13
14
Option 1
Option 2
Path 2
Path 1
15
Path 1
16
Path 2
Similarly here we have 3 options and similarly doing the above steps to find HP we
didnt reach HP.
17
Similarly we need to check for all the edges and if we are not able to find HP throu
Then we will conclude that the original graph doesnt have HC
18
Trying to find HP on
removing this edge now.
19
20
We tried for the above two edges, similarly trying for every edge we were not able to
Conclusion: After checking with all the edges, we find there doesnt exists HP there
Original graph doesnt contain HC in it.
21
Review Questions
22
CREDI
TS
Saurabh Chanderiya
07005004
Computer Science and
Engineering.
saurabhc@cse.iitb.ac.in
23