NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE...

13
NP-complete Problems SAT 3SAT Independent Set Hamiltonian C ertex Cover CLIQUE Traveling-Salesman Probl Subset-Sum t 1000 NP-complete problems have been discovered since. …… Richard Karp 1972 Stephen Cook 1971 ……

Transcript of NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE...

Page 1: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

NP-complete Problems

SAT

3SAT

Independent Set Hamiltonian Cycle

Vertex Cover CLIQUE Traveling-Salesman Problem(TSP)

Subset-Sum

About 1000 NP-complete problems have been discovered since.

……

Richard Karp 1972

Stephen Cook 1971

……

Page 2: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

Independent Set

A V(G) is an independent set if no two vertices in A share an edge.

u, v A, (u, v) E(G)

Ex. b

d

gfc

a

e

a

g

e

d

A = { a, d, e, g } is an independent set.

Let G be an undirected graph.

B = { a, c, f } is not

Page 3: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

The Independent-Set Problem

Input: Graph G, integer K 1.

IND-SET

Q: Does G have an independent set of size K ?

Theorem IND-SET is NP-complete.

Proof IND-SET NP. Below is a non-deterministic algorithm:

a) Pick K vertices from V(G) to form a subset A V.

certificateb) Check if u, v A, (u, v) E(G). If so answer Yes; otherwise, answer No.

non-deterministic O(K) time

deterministic O(K ) time2

Page 4: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

3SAT ≤ IND SET P

Proof (cont’d)

Construct (G , K) such that 3SAT (G , K) IND-SET.

This will follow from Lemma 1.

Therefore IND-SET is NP-complete.

We show that 3SAT is polynomial-time reducible to IND-SET.

Page 5: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

Constructing G

Ex. = ( x x x ) ( x x x ) ( x x x ) 1 2 3 1 3 4 2 3 4

x

xx x xxx

x x1

2 3 3

1

4 4

2

3

One vertex for each literal.

Literals in the same clause form a triangle.

Opposite literals share edges.

Page 6: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

Satisfiability vs. Independent Set

Lemma 1 satisfiable G has an independent set of size K (= #clauses in ).

Proof ( ) Suppose is satisfiable.

Then at least one literal from every clause is true. Pick exactlyone such literal from each clause and pick its correspondingvertex.

K vertices are picked For two of these vertices to share an edge, the corresponding literals would be

Thus the K vertices form an independent set. So none of the K vertices are adjacent.

either in the same clause

or opposite literals. Impossible given the way these vertices are picked

Impossible given that is satisfiable.

Page 7: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

Cont’d

( ) Suppose G has an independent set of size K.

Then the vertices in the set

must be in different triangles.

do not include a pair of opposite literals.

Now we assign T to the corresponding literals in ,

which will be true under the induced truth value assignment to the variables.

Page 8: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

Vertex Cover Let G be an undirected graph.

C V(G) is a vertex cover if for every edge (u, v) E(G)

either u C or v C

a

c

d

b

e

d

a

{ a, d } is a vertex cover.

G = K n |C| |V| – 1complete graphwith n vertices

Page 9: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

The Vertex Cover Problem

Input: Graph G = (V, E), positive integer K | V |. Q: Does G have a vertex cover of size K ?

Lemma C is a vertex cover V – C is an independent set.

a

c

d

b

e

a

c

d

b

e

{a, d}: vertex cover

{b, c, e}: independent set

Proof () Let C be a vertex cover.

Suppose V – C is not an independent set.

Then there exists two vertices u, v V – C such that (u, v) E.

So edge (u, v) has both vertices not in Cand C is not a vertex cover.

( ) Similarly.

Vertex Cover (VC)

Page 10: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

VC is NP-complete

Corollary IND-SET VCP

It is easy to show that VC NP.

Theorem VC NPC.

Page 11: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

CLIQUE

(u, v) is an edge for every u, v Q.

A clique Q is a subset of vertices such that

b

ad

e

c

f g

cliques: { a, b, c, d }

{ e, f, g }

{ d, e }

{ g }, …

The subgraph induced by Q is a complete graph.

Page 12: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

Complement of a Graph

The complement G of a graph G = (V, E) has

the same vertex set V

edge set E such that

(u, v) E (u, v) E

b

ad

e

c

f g

b

ad

e

c

f g

Complement:Original graph:

Page 13: NP-complete Problems SAT 3SAT Independent Set Hamiltonian Cycle Vertex Cover CLIQUE Traveling-Salesman Problem(TSP) Subset-Sum About 1000 NP-complete problems.

The CLIQUE Problem

Lemma Q is a clique in G Q is an independent set in the complement G .

Input: Graph G = (V, E), positive integer K | V |.

Q: Does G have a clique of size K ?

IND-SET CLIQUEP

Theorem CLIQUE NPC.