Transcript
Page 1: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

NP-Completeness: Reductions

CSc 4520/6520Fall 2013

Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Page 2: NP-Completeness: Reductions CSc 4520/6520 Fall 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

Page 3: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 4: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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)

Page 5: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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)

Page 6: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 7: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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?

Page 8: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 9: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)
Page 10: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)
Page 11: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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?

Page 12: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Independent Set to CLIQUEThis is the dual problem!

Page 13: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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:

Page 14: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

|S|=4Example:

Size of vertex-cover is the number of nodes in the cover

Page 15: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

graph contains a vertex cover of size }

VERTEX-COVER = { : kG,G

k

Corresponding language:

Example:G

COVER-VERTEX4, G

Page 16: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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)

Page 17: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Let be a 3CNF formulawith variables and clauses

m

l

Example:

)()()( 431421321 xxxxxxxxx

4m

3l

Clause 1 Clause 2 Clause 3

Page 18: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Formula can be converted to a graph such that:

G

is satisfied

if and only if

GContains a vertex coverof size lmk 2

Page 19: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

)()()( 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

Page 20: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

)()()( 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

Page 21: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

If is satisfied, then contains a vertex cover of size

G

lmk 2

First direction in proof:

Page 22: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

)()()( 431421321 xxxxxxxxx

Satisfying assignment1 0 0 1 4321 xxxx

Example:

We will show that contains a vertex cover of size

103242 lmk

G

Page 23: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

)()()( 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

Page 24: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

)()()( 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

Page 25: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 26: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Explanation for general case:

1x1x 2x

2x 3x3x 4x

4x

Edges in variable gadgets are incident to at least one node in cover

Page 27: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 28: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 29: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

If graph contains a vertex-coverof size then formula is satisfiable

G

lmk 2

Second direction of proof:

Page 30: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Example:

1x1x 2x

2x 3x3x 4x

4x

1x

2x 3x

1x

2x 4x

1x

3x 4x

Page 31: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 32: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 33: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 34: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Dominating SetProblem:

Dominating-set = {<G, K> | A dominating set of size K for G exists}

Goal:Show that Dominating-set is NP-Complete

Page 35: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 36: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Dominating Set (Example)Size-2 example : {Yellow vertices}

e

Page 37: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 38: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 39: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 40: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 41: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 42: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

Dominating Set – Graph Transformation Example

v w

z u

G

wv

z u

vz wu

vw

zu

vu

G'

Page 43: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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

Page 44: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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)

Page 45: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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)

Page 46: NP-Completeness: Reductions CSc 4520/6520 Fall 2013 Slides adapted from David Evans (Virgina) and Costas Busch (RPI)

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