np-completeness: reductions csc 4520/6520 fall 2013 slides adapted from david evans (virgina) and...
Post on 15-Dec-2015
220 Views
Preview:
TRANSCRIPT
NP-Completeness: Reductions
CSc 4520/6520Fall 2013
Slides adapted from David Evans (Virgina) and Costas Busch (RPI)
Definition of NP-Complete
Q is an NP-Complete problem if:
1) Q is in NP 2) every other NP problem polynomial
time is reducible to Q
Getting StartedHow do you show that EVERY NP problem
reduces to Q?One way would be to already have an NP-
Complete problem and just reduce from that
P1
P2
P3
P4
Mystery NP-Complete Problem
Q
3-SAT3-SAT = { f | f is in Conjunctive Normal
Form, each clause has exactly 3 literals and f is satisfiable }
3-SAT is NP-Complete
(2-SAT is in P)
NP-CompleteTo prove a problem is NP-Complete show
a polynomial time reduction from 3-SATOther NP-Complete Problems:
PARTITIONSUBSET-SUMCLIQUEHAMILTONIAN PATH (TSP)GRAPH COLORINGMINESWEEPER (and many more)
NP-Completeness Proof MethodTo show that Q is NP-Complete:1) Show that Q is in NP2) Pick an instance, R, of your favorite NP-
Complete problem (ex: Φ in 3-SAT)3) Show a polynomial algorithm to
transform R into an instance of Q
Example: CliqueCLIQUE = { <G,k> | G is a graph with a
clique of size k }A clique is a subset of vertices that are all
connectedWhy is CLIQUE in NP?
Reduce 3-SAT to CliquePick an instance of 3-SAT, Φ, with k
clausesMake a vertex for each literalConnect each vertex to the literals in
other clauses that are not the negationAny k-clique in this graph corresponds to
a satisfying assignment
Example: Independent SetINDEPENDENT SET = { <G,k> | where G
has an independent set of size k }An independent set is a set of vertices
that have no edgesHow can we reduce this to clique?
Independent Set to CLIQUEThis is the dual problem!
Vertex Cover
S
Vertex cover of a graph is a subset of nodes such that every edge in the graph touches one node in S
S = red nodes
Example:
|S|=4Example:
Size of vertex-cover is the number of nodes in the cover
graph contains a vertex cover of size }
VERTEX-COVER = { : kG,G
k
Corresponding language:
Example:G
COVER-VERTEX4, G
Theorem:
1. VERTEX-COVER is in NP
2. We will reduce in polynomial time 3CNF-SAT to VERTEX-COVER
Can be easily proven
VERTEX-COVER is NP-complete
Proof:
(NP-complete)
Let be a 3CNF formulawith variables and clauses
m
l
Example:
)()()( 431421321 xxxxxxxxx
4m
3l
Clause 1 Clause 2 Clause 3
Formula can be converted to a graph such that:
G
is satisfied
if and only if
GContains a vertex coverof size lmk 2
)()()( 431421321 xxxxxxxxx
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
Clause 1 Clause 2 Clause 3
Clause 1 Clause 2 Clause 3
Variable Gadgets
Clause Gadgets
m2 nodes
l3 nodes
)()()( 431421321 xxxxxxxxx
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
Clause 1 Clause 2 Clause 3
Clause 1 Clause 2 Clause 3
If is satisfied, then contains a vertex cover of size
G
lmk 2
First direction in proof:
)()()( 431421321 xxxxxxxxx
Satisfying assignment1 0 0 1 4321 xxxx
Example:
We will show that contains a vertex cover of size
103242 lmk
G
)()()( 431421321 xxxxxxxxx
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
1 0 0 1 4321 xxxx
Put every satisfying literal in the cover
)()()( 431421321 xxxxxxxxx
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
1 0 0 1 4321 xxxx
Select one satisfying literal in each clause gadgetand include the remaining literals in the cover
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
This is a vertex cover since every edge isadjacent to a chosen node
Explanation for general case:
1x1x 2x
2x 3x3x 4x
4x
Edges in variable gadgets are incident to at least one node in cover
1x
2x 3x
1x
2x 4x
1x
3x 4x
Edges in clause gadgets are incident to at least one node in cover,since two nodes are chosen in a clause gadget
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
Every edge connecting variable gadgetsand clause gadgets is one of three types:
Type 1 Type 2 Type 3
All adjacent to nodes in cover
If graph contains a vertex-coverof size then formula is satisfiable
G
lmk 2
Second direction of proof:
Example:
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
exactly one literal in each variable gadget is chosen
exactly two nodes in each clause gadget is chosen
To include “internal’’ edges to gadgets,and satisfy lmk 2
mchosen out of m2
l2 l3chosen out of
For the variable assignment choose the literals in the cover from variable gadgets
1x1x 2x
2x 3x3x 4x
4x
1 0 0 1 4321 xxxx
)()()( 431421321 xxxxxxxxx
1x1x 2x
2x 3x3x 4x
4x
1x
2x 3x
1x
2x 4x
1x
3x 4x
1 0 0 1 4321 xxxx
)()()( 431421321 xxxxxxxxx
since the respective literals satisfy the clauses
is satisfied with
Dominating SetProblem:
Dominating-set = {<G, K> | A dominating set of size K for G exists}
Goal:Show that Dominating-set is NP-Complete
Dominating Set (Definition)Problem:
Dominating-set = {<G, K> | A dominating set of size (at most) K for G exists}
Let G=(V,E) be an undirected graphA dominating set D is a set of vertices
that covers all verticesi.e., every vertex of G is either in D or is
adjacent to at least one vertex from D
Dominating Set (Example)Size-2 example : {Yellow vertices}
e
Dominating Set (Proof Sketch)Steps:
1) Show that Dominating-set ∈ NP. 2) Show that Dominating-set is not easier
than a NPC problemWe choose this NPC problem to be Vertex
coverReduction from Vertex-cover to
Dominating-set
3) Show the correspondence of “yes” instances between the reduction
Dominating Set - (1) NPIt is trivial to see that Dominating-set ∈ NPGiven a vertex set D of size K, we check
whether (V-D) are adjacent to Di.e., for each vertex, v, in (V-D), whether v is
adjacent to some vertex u in D
Dominating Set - (2) ReductionReduction - Graph transformation
Construct a new graph G' by adding new vertices and edges to the graph G as follows:
G G’
<G,k> ∈ L <G’, k> ∈ L’
T
Vertex-cover Dominating-set
Dominating Set - (2) ReductionReduction - Graph transformation (Con’t)
For each edge (v, w) of G, add a vertex vw and the edges (v, vw) and (w, vw) to G'
Furthermore, remove all vertices with no incident edges; such vertices would always have to go in a dominating set but are not needed in a vertex cover of G
G G’
<G,k> ∈ L <G’, k> ∈ L’
T
Vertex-cover Dominating-set
Vertex coverA vertex cover, C, is a set of vertices that
covers all edgesi.e., each edge is at least adjacent to some
node in C
{2, 4}, {3, 4}, {1, 2, 3} are vertex covers
1 2
3 4
Dominating Set – Graph Transformation Example
v w
z u
G
wv
z u
vz wu
vw
zu
vu
G'
Dominating Set - (3) Correspondence
A dominating set of size K in G’ A vertex cover of size K in G
Let D be a dominating set of size K in G’Case 1): D contains only vertices from G
Then, all new vertices have an edge to a vertex in D D covers all edges D is a valid vertex cover of G
Dominating Set - (3) Correspondence
A dominating set of size K in G’ A vertex cover of size K in G
Let D be a dominating set of size K in G’Case 2): D contains some new vertices (vertex in the
form of uv) (We show how to construct a vertex cover using only old
vertices, otherwise we cannot obtain a vertex cover for G) For each new vertex uv, replace it by u (or v) If u ∈ D, this node is not needed Then the edge u-v in G will be covered After new edges are removed, it is a valid vertex cover of G
(of size at most K)
Dominating Set - (3) Correspondence
A dominating set of size K in G’ A vertex cover of size K in G
Let C be a vertex cover of size K in G For an old vertex, v ∈ G’ :
By the definition of VC, all edges incident to v are coveredv is also covered
For a new vertex, uv ∈ G’ :Edge u-v must be covered, either u or v ∈ CThis node will cover uv in G’
Thus, C is a valid dominating for G’ (of size at most K)
Dominating Set - (3) Correspondence
v w
z u
wv
z u
vz wu
vw
zu
vu
Vertex-cover in G Dominating-set in G'
top related