lecture23-NP-Complete2
lecture23-NP-Complete2
F (G,k) yes
Reduction IS
no
l Requirements:
- 3SAT: Each clause must contain at least one literal whose value is true
- S must contain at least k vertices
l Restrictions:
- 3SAT: If x is assigned true then x must be false and vice versa.
- IS: If u is selected to be in S, then vertices adjacent to u cannot be in S
3SAT IS
l Given F (3-CNF), create G and set k
- Create one vertex in G for each literal that appears in F
l The vertices are grouped into clause clusters.
l Assigning true to a literal from some clause corresponds to
selecting a vertex to place in S
Create one vertex in G for each
literal that appears in F
F3 = ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 )
x1 x2 x3
x1 x1
x2 x2
x3 x3
x1 x2 x3
3SAT IS
l Given F (3-CNF), create G and set k
- Create one vertex in G for each literal that appears in F
l The vertices are grouped into clause clusters.
l Assigning true to a literal from some clause corresponds to
selecting a vertex to place in S
- Set k to be the number of clauses
l Forces IS to pick one vertex from each clause—thus one
literal from each clause is true
l connect all vertices in the same clause cluster to each other
to avoid IS selecting two literals from the same clause
connect all vertices in the same
clause cluster to each other
F3 = ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 )
x1 x2 x3
x1 x1
x2 x2
x3 x3
x1 x2 x3
3SAT IS
l Given F (3-CNF), create G and set k
- Create one vertex in G for each literal that appears in F
l The vertices are grouped into clause clusters.
l Assigning true to a literal from some clause corresponds to
selecting a vertex to place in S
- Set k to be the number of clauses
l Forces IS to pick one vertex from each clause—thus one
literal from each clause is true
l connect all vertices in the same clause cluster to each other
to avoid IS selecting two literals from the same clause
- Put an edge between each literal and its negation
l To avoid IS placing both in S (to avoid assigning true to
both)
Put an edge between each literal
and its negation
F3 = ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 )
x1 x2 x3
x1 x1
x2 x2
x3 x3
x1 x2 x3
Put an edge between each literal
and its negation
F3 = ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 )
x1 x2 x3
x1 x1
x2 x2
x3 x3
x1 x2 x3
Put an edge between each literal
and its negation
F3 = ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 ) Ù ( x1 Ú x2 Ú x3 )
x1 x2 x3
x1 x1 G
x2 x2
x3 x3
k=4
x1 x2 x3
By this construction..
l F is satisfiable if and only if G has an IS of size k
Vertex Cover
Vertex Cover
l A vertex cover in an undirected graph G=(V,E)
is a subset of vertices S such that every edge
in G has at least one endpoint in S
G G’
k=3 k’=3
If G has a VC of size k then G’ has a VC of size k’
Isolated vertex: need not be in VC, has to be in DS
G G’
k=3 k’=3+1
No of isolated vertices
If G’ has a DS of size k’ then G has a VC of size k
DS fog G’ VC for G
If a special vertex is in DS, replace it with one of its
adjacent original vertices
DS fog G’ DS fog G’
If G’ has a DS of size k’ then G has a VC of size k
DS fog G’ VC for G