Top Banner
NP-complete examples CSC3130 Tutorial 11 Xiao Linfu [email protected] Department of Computer Science & Engineering Fall 2009
18

NP-complete examples CSC3130 Tutorial 11 Xiao Linfu [email protected] Department of Computer Science & Engineering Fall 2009.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

NP-complete examples

CSC3130 Tutorial 11

Xiao Linfu

[email protected]

Department of Computer Science & Engineering

Fall 2009

Page 2: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Outline

• Review of P, NP, NP-C

• 2 problems– Double-SAT– Dominating set

http://en.wikipedia.org/wiki/Dominating_set_problem

Page 3: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.
Page 4: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.
Page 5: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.
Page 6: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Relations

NP

P

NP-C

easy

hard

Is there any problem even harder than NP-C?

Yes! e.g. I-go

Page 7: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

How to show that a problem R is not easier than a problem Q?

Informally, if R can be solved efficiently, we can solve Q efficiently.

Formally, we say Q polynomially reduces to R if:

1. Given an instance q of problem Q

2. There is a polynomial time transformation to an instance f(q) of R

3. q is a “yes” instance if and only if f(q) is a “yes” instance

Then, if R is polynomial time solvable, then Q is polynomial time solvable.

If Q is not polynomial time solvable, then R is not polynomial time solvable.

Polynomial Time Reduction

Page 8: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Methodology

• To show L is in NP, you can either (i) show that solutions for L can be verified in polynomial-time, or (ii) describe a nondeterministic polynomial-time TM for L.

• To show L is NP-complete, you have to design a polynomial-time reduction from some problem we know to be NP-complete

Page 9: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

• The direction of the reduction is very important– Saying “A is easier than B” and “B is easier than

A” mean different things

• What we have? We know SAT, Vertex Cover problems are NP-Complete!

Page 10: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Double-SAT

• Definition: – Double-SAT = {<φ> | φ is a Boolean formula

with at least two satisfying assignments}

• Show that Double-SAT is NP-Complete.– (1) First, it is easy to see that Double-SAT ∈ NP.

• non-deterministically guess 2 assignments for φ and verify whether both satisfy φ.

– (2) Then we show Double-SAT is not easier than SAT.• Reduction from SAT to Double-SAT

Page 11: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Double-SAT

• Reduction:– On input φ(x1, . . . , xn):

– 1. Introduce a new variable y.– 2. Output formula φ’(x1, . . . , xn, y) = φ(x1, . . . , xn) ∧ ( y ∨

y ).

Page 12: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Dominating set

• Definition: input G=(V,E), K

• Let G=(V,E) be an undirected graph. A dominating set D is a set of vertices in G such that every vertex of G is either in D or is adjacent to at least one vertex from D. The problem is to determine whether there is a dominating set of size K for G.

Page 13: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Dominating set - example

• {yellow vertices} is an example of a dominating set of size 2.

e

Page 14: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Dominating set

• Show that Dominating set is NP-Complete.– (1) First, it is easy to see that Dominating set ∈

NP. • Given a vertex set D of size K, we check

whether (V-D) are adjacent to D.– (2) Then we show Dominating set is not easier

than Vertex cover.• Reduction from Vertex cover to Dominating

set

Page 15: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Dominating set

• Reduction– (1) Graph transformation - Construct a new graph G'

by adding new vertices and edges to the graph G as follows: 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.

Page 16: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Dominating set – graph transformation

v w

z u

wv

z u

vz wu

vw

zu

vu

G

G'

Page 17: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Dominating set

• Reduction– (1) Graph transformation– (2) a dominating set of size K in G’ a vertex cover of

size K in G

Page 18: NP-complete examples CSC3130 Tutorial 11 Xiao Linfu lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering Fall 2009.

Thank you!