# More NP-complete Problems

1

Theorem: (proven in previous class) If: Language A is NP-complete Language B is in NP A is polynomial time reducible to B 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:
**

Gd

G d VERTEX - COVER ,4

6

Theorem: VERTEX-COVER is NP-complete

Proof: 1. VERTEX-COVER is in NP We have proven this before 2. We will reduce in polynomial time 3CNF-S T to VERTEX-COVER

(NP-complete)

7

**Let N be a 3CNF formula with m variables and l clauses Example:
**

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

Clause 1 Clause 2 Clause 3

m!4

l !3

8

Formula N can be converted to a graph G such that:

N is satisfied

if and only if

G Contains a vertex cover of size k ! l

9

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

Clause 1 Clause Clause

Variable Gadgets

1

1

nodes

Clause Gadgets

1

1

l nodes

1

Clause 1

Clause

Clause

10

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

Clause 1 Clause Clause

1

1

1

1

1

Clause 1

Clause

Clause

11

First direction in proof: If N is satisfied, then G contains a graph of size k ! m 2l

12

Example:

N !(

1

)(

1

)(

1

)

Satisfying assignment

x1 ! 1 x2 ! 0 x3 ! 0 x4 ! 1

**We will show that G contains a vertex cover of size
**

k ! m 2l ! 4 2 3 ! 10

13

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

1

!1

!0

!0

!1

1

1

1

1

1

**Put every satisfying literal in the cover
**

14

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

1

!1

!0

!0

!1

1

1

1

1

1

Select one satisfying literal in each clause gadget and include the remaining literals in the cover 15

This is a verte cover since every edge is adjacent to a chosen node

1

1

1

1

1

16

Explanation for general case:

x1

x1

x

x

x

x

x

x

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

17

Edges in clause gadgets are incident to at least one node in cover, since two nodes are chosen in a clause gadget

1

1

1

4

4

18

**Every edge connecting variable gadgets and clause gadgets is one of three types:
**

£ ¢ ¢

1

1

Type 1

Type ll adjacent to nodes in cover

¤

¥

¡

¡

1

1

1

¥

¤

¢

Type

19

Second direction of proof: If graph G contains a vertex-cover of size k ! l then formula N is satisfiable

20

Example:

x1

x1

x

x

x

x

x

x

x1

x1

x1 x

x

x

x

x

x

21

**To include ´internal·· edges to gadgets, and satisfy k ! l
**

e actly one literal in each variable gadget is chosen

1

1

m chosen out of 2m

**e actly two nodes in each clause gadget is chosen
**

1

1

1

**2l chosen out of 3l
**

22

**For the variable assignment choose the literals in the cover from variable gadgets
**

x2

x2

1

1

x3

x3

x4

x4

x1 ! 1

x2 !

x3 !

x4 ! 1

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

23

N ! (x 1 x 2 x 3 ) (x 1 x 2 x 4 ) ( x 1 x 3 x 4 )

is satisfied with

x1 ! 1

x1

x1

x2 ! 0

x2

x2

x3 ! 0

x3

x3

x4 ! 1

x4

x4

x1

x1

x1 x4

x2

x3

x2

x3

x4

**since the respective literals satisfy the clauses
**

24