Intro To NP Completeness Modified
Intro To NP Completeness Modified
NP Completeness
CO6 - Make use ofthe complexity classes like NP-Complete, NP-hard
and develop polynomial reductions for the real world problems
Limitations of the algorithm
Power/Computational Complexity of
the Problem
TRACTABLE INTRACTABLE
As they (Problem) grow large, we are As they grow large, we are unable to
able to solve them in reasonable time solve them in reasonable time
The lower bound suggests the The upper bound suggests the
problem is tractable problem is intractable
the class of decision problems that set of problems for which a solution can
can be solved /run in polynomial-time be verified in polynomial time
For a particular input the computer will give For a particular input the computer will give
always same output. different output on different execution.
Can solve the problem in polynomial time. Can’t solve the problem in polynomial time.
Logic Gates 0 1 0
1 1
NOT
1 1
0
OR 1
0 0 1
1
AND
(xy)(yz)(xz)(zy)
• Any of the OR clauses can be converted to
implication clauses
2-SAT is in P
• Create the implication graph
x
y
x
y
z
z
Satisfiability via path finding
• If there is a path from
• And if there is a path from
• Then FAIL!
• How to find paths in graphs?
– DFS/BFS and modifications thereof
Example: CNF satisfiability
• This problem is in NP. Nondeterministic algorithm:
– Guess truth assignment
– Check assignment to see if it satisfies CNF formula
• Example:
(A¬B ¬C ) (¬A B) (¬ B D F ) (F ¬ D)
• Truth assignments:
ABCDEF
0 1 1 0 1 0
1 0 0 0 0 1
1 1 0 0 0 1
... (how many more?)
w A f(w) B
• If L1 L2 then L2 is in P implies L1 is in P
(or L1 is not in P implies L2 is not in P)
• If L1 L2 and L2 L3 then L1 L3
Lemma :
If L1 and L2 belong to NP,
L1 is NP-complete, and L1 L2
then L2 is NP-complete.
i.e. L1, L2 NP and for all other L'
NP, L' L1 and L1 L2 L' L2
1
• For each two cities, an integer cost is given to travel from one
of the two cities to the other. The salesperson wants to make
a minimum cost circuit visiting each city exactly once.
The clique problem is the
computational problem of
finding cliques (subsets of
vertices, all adjacent to each
other, also called complete
subgraphs) in a graph. It has
several different formulations
depending on which cliques,
and what information about the
cliques, should be found
Clique
A clique is a subgraph of a graph such that all the vertices in this subgraph are
connected with each other that is the subgraph is a complete graph. The Maximal
Clique Problem is to find the maximum sized clique of a given graph G, that is a
complete graph which is a subgraph of G and contains the maximum number of
vertices. This is an optimization problem. Correspondingly, the Clique Decision
Problem is to find if a clique of size k exists in the given graph or not.
4 – Clique Problem
K-Cliques
• A K-clique is a set of K nodes with all K(K-1)/2
possible edges between them
1. Certificate – Let the certificate be a set S consisting of nodes in the clique and S is a subgraph of G.
2. Verification – We have to check if there exists a clique of size k in the graph. Hence, verifying if number
of nodes in S equals k, takes O(1) time. Verifying whether each vertex has an out-degree of (k-1) takes
O(k2) time. (Since in a complete graph, each vertex is connected to every other vertex through an edge.
Hence the total number of edges in a complete graph = kC2 = k*(k-1)/2 ). Therefore, to check if the graph
formed by the k nodes in S is complete or not, it takes O(k2) = O(n2) time (since k<=n, where n is number
of vertices in G).
• Therefore, the Clique Decision Problem has polynomial time verifiability and hence belongs to the NP
Class.
• The Clique Decision Problem belongs to NP-Hard – A problem L belongs to NP-Hard if every NP
problem is reducible to L in polynomial time. Now, let the Clique Decision Problem by C. To prove that C
is NP-Hard, we take an already known NP-Hard problem, say S, and reduce it to C for a particular
instance. If this reduction can be done in polynomial time, then C is also an NP-Hard problem. The
Boolean Satisfiability Problem (S) is an NP-Complete problem as proved by the Cook’s theorem.
Therefore, every problem in NP can be reduced to S in polynomial time. Thus, if S is reducible to C in
polynomial time, every NP problem can be reduced to C in polynomial time, thereby proving C to be NP-
Hard.
Proof that the Boolean Satisfiability problem reduces to the Clique Decision
Problem