Professional Documents
Culture Documents
Lecture #32
Sarmad Abbasi
Virtual University
Theory of Computation
1 / 23
Theory of Computation
2 / 23
Theory of Computation
3 / 23
NP-completeness
Theory of Computation
4 / 23
NP-completeness
Our goal now is to add one more problem to this picture. We want to
show that the hamiltonian path problem is also NP-Complete. The
picture will then look like this.
Theory of Computation
5 / 23
NP-completeness
Theory of Computation
6 / 23
NP-completeness
Theory of Computation
7 / 23
NP-completeness
Starts and s.
Ends at t
Theory of Computation
8 / 23
NP-completeness
Sarfarz Show figure 3. Does this graph have a hamiltonian path from s
to t.
Theory of Computation
9 / 23
NP-completeness
Theory of Computation
10 / 23
NP-completeness
Let us define
HAMPATH{< G, s, t >: G has a hamiltonian path from s to t}.
Thus the computational question is that given a graph G and two
vertices s and t. Does there exist a hamiltonian path from s to t.
Theory of Computation
11 / 23
NP-completeness
Theory of Computation
12 / 23
NP-completeness
Theorem
3SAT p HAMPATH
Consequently HAMPATH is NP-complete.
Theory of Computation
13 / 23
NP-completeness
is satisfiable.
Theory of Computation
14 / 23
NP-completeness
Let us take
= C1 C2 Cm
and x1 , . . . , xn be the variables in .
We describe how to construct G .
Theory of Computation
15 / 23
NP-completeness
Theory of Computation
16 / 23
NP-completeness
Show figure. This figure shows the diamond shape structure that has
to be created for each node xi .
Theory of Computation
17 / 23
NP-completeness
Theory of Computation
18 / 23
NP-completeness
Theory of Computation
19 / 23
NP-completeness
Now, let us discuss how to connect the vertices in the diamond to the
clauses. Here is the rule.
If xi appears in Cj then:
Connect the vertex in the diamond for xi that is labeled CjL with Cj .
Also, connect Cj with CjR . Formally, all the following edges
(CjL , Cj ) and (Cj , CjR ).
Show figure.
Theory of Computation
20 / 23
NP-completeness
Theory of Computation
21 / 23
NP-completeness
Theory of Computation
22 / 23
NP-completeness
Theory of Computation
23 / 23
NP-completeness
What can we say about this graph. Well, I will convince you that:
1
Theory of Computation
24 / 23
NP-completeness
Theory of Computation
25 / 23
NP-completeness
Theory of Computation
26 / 23
NP-completeness
Theory of Computation
27 / 23
NP-completeness
Note that if we are traversing the diamond for xi from Left to right then
we can pick up a clause Cj if xi appears in Cj . This is due to
construction. This is because we have an edge from CjL to Cj and back
to CjR . Show figure.
Theory of Computation
28 / 23
NP-completeness
Note that if we are traversing the diamond for xi from Right to Left then
we can pick up a clause Cj if xi appears in Cj . This is again by
construction. In this case we have an edge from CjR to Cj and back to
CjL .
Theory of Computation
29 / 23
NP-completeness
Theory of Computation
30 / 23
NP-completeness
Start from s.
Along the way pick up any Cj that has not been already picked up.
Theory of Computation
31 / 23
NP-completeness
Lemma
If is satisfiable then G has a hamiltonian path from s to t.
We have to prove the converse of this theorem next time
Theory of Computation
32 / 23