Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

NP-Completeness of Clique Problem through Reduction from 3-SAT - Prof. Michael R. Kowalczy, Study notes of Algorithms and Programming

The np-completeness of the clique problem in computer science. The author, mike kowalczyk, explains how the clique problem is in np and reduces 3-sat to clique. The document also demonstrates that if a 3-sat instance is satisfiable, then the corresponding clique instance is a 'yes', and vice versa. Essential for students studying algorithms and complexity theory.

Typology: Study notes

Pre 2010

Uploaded on 08/01/2009

koofers-user-0ou
koofers-user-0ou 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Algorithm Design and Analysis 4/15/2008
Lecture 36: More NP-completeness
Instructor: Mike Kowalczyk
1 Reduction from 3-SAT to Clique
The decision problem clique is defined to be the following: Input: graph G= (V, E) and an integer
k. Output: “yes” if there is a clique of size kin G, “no” otherwise. A clique of size kis k
vertices that all have edges going to each other. We would like to show that the clique problem is
NP-Complete. We will do this by showing that 3-SAT P
mclique, and clique NP.
Let’s show that clique is in NP first. Nondeterministically create a different branch for every
possible subset SVof size k. Then each branch checks to see if all k
2possible edges are there
for that vertex subset S. If so, it returns “yes”, and “no” otherwise. If there is a clique of size k
in G, then some branch will guess the right subset and verify it has all the edges and return “yes”,
which makes the whole machine return “yes”. If there is no clique of size k, then all branches return
“no” and so the whole machine returns “no”. The number of branhes required is n
k, where nis
the number of vertices. If the nondeterminstic machine makes 2 branches at every time step, then
in nlg nsteps, it can get 2nlg n=nnbranches, and nnn!n
k. Each branch checks for at most
n2edges. So then, it runs in polynomial time in the size of the input.
Let’s do the reduction now. We want to reduce 3-SAT to clique. Given a boolean formula φ,
we create a graph G= (V, E) as follows. For every clause in φ, we create 3 vertices corresponding
to the literals in that clause. We introduce an edge between vertices from different clauses if and
only if those two variables are consistent (meaning it’s not the case that one is the negation of the
other). As we will see, Ghas a clique of size mif and only if φis satisfiable, so the reduction maps
φto (G, m).
Now we show that if the instance of 3-SAT is a “yes” then the instance of clique is a “yes”
as well. If the 3-SAT instance is a “yes” then there is a truth assignment (true and false values
assigned to the variables) such that every clause has a true literal. By selecting a corresonding
vertex to a true literal in each clause, then we see that we have a clique in Gof size m(where
mis the number of clauses), because if there was a missing edge that would mean that our truth
assignment effectively set something to be true and false at the same time!
Now assume there is a clique of size mwhere mis the number of clauses. We need to show
that there must be a truth assignment that satisfies the above boolean formula. We claim that the
truth assignment induced by the labels of the vertices satisfies φ. This assignment is well-defined
because every pair of vertices in the clique has an edge, which precludes the possibility of some
variable being set to both true and false. Furthermore, since every trio of vertices corresponding
to a clause has no edges between those vertices, we must have a vertex from every clause gadget
in our clique. This shows that the corresponding clauses are satisfied in φand φis satisfied by
our assignment. Finally, creating this graph based on an input formula takes only polynomial time
(the construction can be carried out by a few simple for loops).
We conclude that clique is NP-complete.
1

Partial preview of the text

Download NP-Completeness of Clique Problem through Reduction from 3-SAT - Prof. Michael R. Kowalczy and more Study notes Algorithms and Programming in PDF only on Docsity!

Algorithm Design and Analysis 4/15/

Lecture 36: More NP-completeness

Instructor: Mike Kowalczyk

1 Reduction from 3-SAT to Clique

The decision problem clique is defined to be the following: Input: graph G = (V, E) and an integer k. Output: “yes” if there is a clique of size k in G, “no” otherwise. A clique of size k is k vertices that all have edges going to each other. We would like to show that the clique problem is NP-Complete. We will do this by showing that 3-SAT ≤Pm clique, and clique ∈ NP. Let’s show that clique is in NP first. Nondeterministically create a different branch for every possible subset S ⊆ V of size k. Then each branch checks to see if all

(k 2

possible edges are there for that vertex subset S. If so, it returns “yes”, and “no” otherwise. If there is a clique of size k in G, then some branch will guess the right subset and verify it has all the edges and return “yes”, which makes the whole machine return “yes”. If there is no clique of size k, then all branches return “no” and so the whole machine returns “no”. The number of branhes required is

(n k

, where n is the number of vertices. If the nondeterminstic machine makes 2 branches at every time step, then in n lg n steps, it can get 2n^ lg^ n^ = nn^ branches, and nn^ ≥ n! ≥

(n k

. Each branch checks for at most n^2 edges. So then, it runs in polynomial time in the size of the input. Let’s do the reduction now. We want to reduce 3-SAT to clique. Given a boolean formula φ, we create a graph G = (V, E) as follows. For every clause in φ, we create 3 vertices corresponding to the literals in that clause. We introduce an edge between vertices from different clauses if and only if those two variables are consistent (meaning it’s not the case that one is the negation of the other). As we will see, G has a clique of size m if and only if φ is satisfiable, so the reduction maps φ to (G, m). Now we show that if the instance of 3-SAT is a “yes” then the instance of clique is a “yes” as well. If the 3-SAT instance is a “yes” then there is a truth assignment (true and false values assigned to the variables) such that every clause has a true literal. By selecting a corresonding vertex to a true literal in each clause, then we see that we have a clique in G of size m (where m is the number of clauses), because if there was a missing edge that would mean that our truth assignment effectively set something to be true and false at the same time! Now assume there is a clique of size m where m is the number of clauses. We need to show that there must be a truth assignment that satisfies the above boolean formula. We claim that the truth assignment induced by the labels of the vertices satisfies φ. This assignment is well-defined because every pair of vertices in the clique has an edge, which precludes the possibility of some variable being set to both true and false. Furthermore, since every trio of vertices corresponding to a clause has no edges between those vertices, we must have a vertex from every clause gadget in our clique. This shows that the corresponding clauses are satisfied in φ and φ is satisfied by our assignment. Finally, creating this graph based on an input formula takes only polynomial time (the construction can be carried out by a few simple for loops). We conclude that clique is NP-complete.