Professional Documents
Culture Documents
Algorithms
The NP-Completeness Theory
Algorithms 1
The NP-Completeness Theory
Algorithms 2
The Class of Problems P
Algorithms 3
Input Size
Algorithms 4
The Class of Problems NP
Algorithms 5
P vs. NP
P NP
Algorithms 6
All Problems
P NP
All Problems
Algorithms 7
Decision Problems vs. Optimization Problems
Algorithms 8
Decision Problems vs. Optimization Problems
Algorithms 9
Graph Problems
Algorithms 10
Independent Sets
Algorithms 11
The Independent Set Problem
Algorithms 12
Cliques
Algorithms 13
The Clique Problem
Algorithms 14
Vertex Cover Sets
Algorithms 15
The Vertex Cover Problem
Algorithms 16
Dominating Sets
Algorithms 17
The Dominating Set Problem
Algorithms 18
Vertex Coloring
Algorithms 19
The Vertex Coloring Problem
Algorithms 20
Hamilton Paths
⋆ A simple path that visits all the vertices of the graph exactly
once: P = (v1, v2, . . . , vn) ⇒ V = {v1, . . . , vn}.
Algorithms 21
The Hamilton Path Problem
Algorithms 22
Problems as Languages
⋆ The set Co-NP is the set of all problems for which their
complement language can be verified with a polynomial
time algorithm.
Algorithms 23
NP vs. Co-NP: Possible Relations
NP=Co-NP
P=NP=Co-NP P
NP P Co-NP
NP P Co-NP
Algorithms 24
Reductions
Algorithms 25
Reducibility is Transitive
Algorithms 26
The Class of Problems NP-Hard
NPH
P NP
Algorithms 27
The Class of Problems NP-Complete
Corollary: If N P = N P C then P = N P .
Algorithms 28
P 6= N P ?
NPH
NPC
P NP
Algorithms 29
Boolean Formulas
Algorithms 30
Example
Algorithms 31
CNF Boolean Formulas
Algorithms 32
The SAT Problem
Algorithms 33
SAT is an NP-Complete Problem
Algorithms 34
Boolean Circuits
Algorithms 35
Example
x
y
Algorithms 36
The C-SAT Problem
Algorithms 37
C-SAT is an NP-Complete Problem
Algorithms 38
SAT vs. C-SAT
Algorithms 39
How to Prove that a Problem is NP-Complete?
Algorithms 40
The 3-SAT Problem
Algorithms 41
The 3-SAT Problem
Input:
⋆ Variables: x1, x2, . . . , xh.
⋆ A 3-CNF formula: Φ = C1 ∧ C2 ∧ · · · ∧ Ck .
⋆ Clause r: Cr = (ℓr1, ℓr2, ℓr3)
⋆ Literals: ℓri ∈ {x1, x¯1, x2, x¯2, . . . , xh, x¯h} for 1 ≤ r ≤ k
and 1 ≤ i ≤ 3.
Problem: Find a TRUE and FALSE assignment to the h
variables, if exists, such that Φ =TRUE?
Decision Problem: Is there a TRUE and FALSE assignment
to the variables such that Φ =TRUE?
Algorithms 42
A Reduction Tree
C-SAT
SAT
3-SAT
VC CLIQUE
DOM IND
3-COL HAM
Algorithms 43
Reduction from 3-SAT to CLIQUE
Algorithms 44
Example
_ _
x y z
_
x x
y y
z z
Φ = (x ∨ ȳ ∨ z̄) ∧ (x̄ ∨ y ∨ z) ∧ (x ∨ y ∨ z)
Algorithms 45
Reduction from 3-SAT to CLIQUE
Algorithms 46
Reduction from 3-SAT to CLIQUE
Algorithms 47
CLIQUE is NPC
Algorithms 48
Reduction from 3-SAT to Vertex Cover
Algorithms 49
Example
_ _ _ _
x x y y z z w w
Algorithms 50
Reduction from 3-SAT to Vertex Cover
Algorithms 51
Reduction from 3-SAT to Vertex Cover
Proof ⇒:
⋆ Let C be a vertex cover of size h + 2k in G(Φ).
⋆ C contains exactly one variable vertex and 2 triangle
vertices.
⋆ If xi ∈ C then assign TRUE to xi. If x̄i ∈ C then assign
FALSE to xi.
⋆ The 2 triangle vertices can cover only 2 of the edges
connecting the triangle to the variable vertices. The third
edge must be covered by a variable vertex.
⋆ This variable vertex will give the corresponding triangle
the true value.
Algorithms 52
Reduction from 3-SAT to Vertex Cover
Proof ⇐:
⋆ Let xi ∈ {TRUE,FALSE} be a TRUE assignment to Φ.
⋆ If xi =TRUE then add xi to the vertex cover C. If
xi =FALSE then add x̄i to the vertex cover C.
⋆ Each clause has a TRUE literal. The variable vertex
corresponding to this literal covers the edge connecting
this clause triangle to its variables. Add the other 2
vertices from the triangle to the vertex cover C.
⋆ These 2 vertices cover the triangle edges and the other 2
edges connecting the triangle to the variable vertices.
⋆ All together, C contains h + 2k vertices.
Algorithms 53
Vertex Cover is NPC
Algorithms 54
Independent Sets and Vertex Cover Sets
Algorithms 55
IND is an NP-Complete Problem
Algorithms 56
VC is an NP-Complete Problem
Algorithms 57
Cliques and Independent Sets
Algorithms 58
IND is an NP-Complete Problem
Algorithms 59
CLIQUE is an NP-Complete Problem
Algorithms 60
Vertex Cover Sets and Cliques
Algorithms 61
VC is an NP-Complete Problem
Algorithms 62
CLIQUE is an NP-Complete Problem
Algorithms 63
Reduction from Vertex Cover to Dominating Set
Algorithms 64
Example
Algorithms 65
Reduction from Vertex Cover to Dominating Set
Algorithms 66
Reduction from Vertex Cover to Dominating Set
Proof ⇒:
⋆ Let the vertex cover of G be the dominating set for G′.
⋆ Every vertex cover is a dominating set and therefore all
the G vertices in G′ are dominated.
⋆ Every edge in G is covered and therefore all the new
vertices are dominated.
Algorithms 67
Reduction from Vertex Cover to Dominating Set
Proof ⇐:
⋆ Let D be a dominating set in G′.
⋆ If u ∈ V ′ is in the dominating set for G′, then u ∈ V is
in the vertex set for G.
⋆ If e = (u, v) is in the dominating set for G′, then select
either u or v to be in the vertex set for G.
⋆ Since every vertex e ∈ V ′ is dominated, it follows that
every edge e ∈ E is covered.
Algorithms 68
Dominating Set is NPC
Algorithms 69