Lec32 CS345
Lec32 CS345
CS345
Lecture 32
• NP Completeness – III
• Coping with NP-completeness
1
NP Complete problems
Is P = NP ?
P NP
NP-complete
NP
𝑨
𝑿
EXAMPLE
4
Dominating Set
Definition: Given an undirected graph ,
= {| or () }
In other words, is the set consisting of and all neighbors of in .
a subset is said to be an dominating set if
For each , IsIsititthe
thesmallest
smallest
dominating
dominatingset
set??
𝒃 NO.
YES
𝒂 𝒙
𝒛 𝒚 𝒕
Optimization version: compute dominating set of smallest size.
Decision version: Does there exist a dominating set of size ?
5
Dominating Set
Definition: Given an undirected graph ,
= {| or () }
In other words, is the set consisting of and all neighbors of in .
a subset is said to be a dominating set if
For each ,
Decision version:
Does there exist a dominating set of size ?
Efficient Verifier:
Input: (, , ),
Behavior:
It checks
1. || = ?
2. for each , whether ?
This algorithm takes O() time. Dominating Set NP 6
VC DS
𝒃 𝒃
𝒂 𝒙 𝒂 𝒙
𝒛 𝒚 𝒕 𝒛 𝒚 𝒕
7
VC DS
So without loss of generality assume does not have any isolated vertex.
8
VC DS
(, )
𝒇 (, )
9
VC DS
𝒂 𝒙 𝒂 𝒙
𝒛 𝒚 𝒕 𝒛 𝒕
𝒚
Theorem :
has a vertex cover of size if and only if has a dominating set of size .
10
VC DS
Theorem ():
If has a vertex cover of size
𝒗 𝒚 then has a dominating set of size .
𝒗 Proof:
Let be a vertex cover of of size .
𝒘 𝒚
Consider any vertex .
Case 1:
is dominated (use Observation 1)
Case 2:
(,) and the edge is covered by ,
so either or .
is dominated in this case as well
11
VC DS
Replace by .
If is already in , Theorem ():
then just remove . If has a dominating set of size ,
then has a vertex cover of size .
𝒗 Proof:
Let be a dominating set of .
𝒘 𝒚
We can assume that .
𝒗 Now consider any edge (,) .
𝒘 𝒚 Since is dominated in .
or .
We are done.
Lemma:
If has a dominating set of size ,
then also has a dominating set
of size . 12
MORE NP-COMPLETE PROBLEMS
13
Subgraph Isomorphism
𝟏 𝟐
𝒂 𝒖
𝒃 𝒗 𝟔
𝟑
𝒄 𝒘
𝟓 𝟒
Definition: Graph is said to be isomorphic to
if there is a bijection : such that for any two vertices
if and only if
Problem: Given two graphs and ,
¿
does there exist a subgraph of which is isomorphic to ?
15
HOW TO HANDLE
NP-COMPLETE PROBLEMS
Approximation Algorithms
16
Approximation algorithms
17
VERTEX COVER PROBLEM
18
The algorithm
;
While <> empty do
{ Let () be any edge present in ;
;
Remove every edge incident on ;
?
Remove every edge incident on ;
}
Return
19
SET COVER PROBLEM
20
Set Cover Problem
– a set = {, ,…,}
– , ,…, , with
Optimization version: Compute least number of sets that can cover .
Decision version: Does there exist subsets that can cover all elements ?
𝒆𝟐 𝒆𝟕
𝒆𝟓
𝒆𝟏
𝒆𝟑 𝒆𝟖
𝒆𝟒 𝒆𝟔
𝒆𝟗
21
Set Cover Problem
– a set = {, ,…,}
– , ,…, , with
Optimization version: Compute least number of sets that can cover .
Decision version: Does there exist subsets that can cover all elements ?
𝒆𝟐 𝒆𝟕
𝒆𝟓
𝒆𝟏
𝒆𝟑 𝒆𝟖
𝒆𝟒 𝒆𝟔
𝒆𝟗
22
Set Cover Problem
– a set = {, ,…,}
– , ,…, , with
Optimization version: Compute least number of sets that can cover .
Decision version: Does there exist subsets that can cover all elements ?
𝒆𝟐 𝒆𝟕
𝒆𝟓
𝒆𝟏
𝒆𝟑 𝒆𝟖
𝒆𝟒 𝒆𝟔
𝒆𝟗
23
Set Cover Problem
– a set = {, ,…,}
– , ,…, , with
Optimization version: Compute least number of sets that can cover .
Decision version: NP-complete Homework
Think simple.
Follow your intuition
24