NP Complete Reductions
NP Complete Reductions
NP Complete Reductions
1
Theorem: (proven in previous class)
Then: B is NP-complete
2
Using the previous theorem,
we will prove that 2 problems
are NP-complete:
Vertex-Cover
Hamiltonian-Path
3
Vertex Cover
Vertex cover of a graph
is a subset of nodes S such that every edge
in the graph touches one node in S
Example:
S = red nodes
4
Size of vertex-cover
is the number of nodes in the cover
Example: |S|=4
5
Corresponding language:
VERTEX-COVER = { G , k :
graph G contains a vertex cover
of size k }
Example:
G
Proof:
1. VERTEX-COVER is in NP
We have proven this before
7
Let be a 3CNF formula
with m variables
and l clauses
Example:
( x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )
Clause 1 Clause 2 Clause 3
m4
l 3
8
Formula can be converted
to a graph G such that:
is satisfied
if and only if
9
( x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) (x 1 x 3 x 4 )
Clause 1 Clause 2 Clause 3
Variable Gadgets 2m nodes
x1 x1 x2 x2 x3 x3 x4 x4
x2 x3 x2 x4 x3 x4
Clause 1 Clause 2 Clause 3
10
( x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) (x 1 x 3 x 4 )
Clause 1 Clause 2 Clause 3
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4
Clause 1 Clause 2 Clause 3
11
First direction in proof:
If is satisfied,
then G contains a graph of size k m 2l
12
Example:
(x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) ( x 1 x 3 x 4 )
Satisfying assignment
x1 1 x2 0 x3 0 x4 1
13
( x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) (x 1 x 3 x 4 )
x1 1 x2 0 x3 0 x4 1
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4
Select one satisfying literal in each clause gadget
and include the remaining literals in the cover 15
This is a vertex cover since every edge is
adjacent to a chosen node
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4
16
Explanation for general case:
x1 x1 x2 x2 x3 x3 x4 x4
17
Edges in clause gadgets
are incident to at least one node in cover,
since two nodes are chosen in a clause gadget
x1 x1 x1
x2 x3 x2 x4 x3 x4
18
Every edge connecting variable gadgets
and clause gadgets is one of three types:
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4
20
Example:
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4
21
To include “internal’’ edges to gadgets,
and satisfy k m 2l
x2 x3 x2 x4 x3 x4
2l chosen out of 3l
22
For the variable assignment choose the
literals in the cover from variable gadgets
x1 x1 x2 x2 x3 x3 x4 x4
x1 1 x2 0 x3 0 x4 1
(x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) ( x 1 x 3 x 4 )
23
(x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) ( x 1 x 3 x 4 )
is satisfied with
x1 1 x2 0 x3 0 x4 1
x1 x1 x2 x2 x3 x3 x4 x4
x1 x1 x1
x2 x3 x2 x4 x3 x4