Prerequisite: NP-Completeness, NP Class, Clique, Independent Set
Problem: Given an undirected graph G = (V, E) and an integer K, determine if a clique of size K as well as an independent set (IS) of size K, exists. Demonstrate that it is an NP Complete.
A Clique is a subgraph of a graph in which all of the vertices are connected, forming a complete graph. The Clique Decision Problem involves determining whether or not a clique of size K exists in the given graph.
An Independent Set S of graph G = (V, E) is a collection of vertices in the graph G = (V, E) where no two vertices are adjacent.
Given Clique+IS problem is a combination of both Clique and Independent set can be described as follows:
- Input – Graph G (V, E) and integer K
- Output – Clique and Independent Set of size K
To prove a problem NP Complete, there are two steps involved:
- Prove given problem belong to NP Class
- All other problems in the NP class can be polynomial time reducible to that problem. (This is the prove of being NP-Hard)
Now it is not possible to reduce every NP problem to another NP problem to prove it’s NP completeness all the time. That’s why we show that any known NP complete problem is reducible to that problem in polynomial time.
1.Clique+IS belongs to NP Class:
A problem is said to be in NP Class if the solution for the problem can be verified in polynomial time.
Given an input G = (V, E) and a set size of K, the answer is two sets: I (Independent Set) and C (Clique Set). There are three steps to verify the solution for this problem:
- Verify Independent Set: For all pairs of vertices (x, y) such that x, y ∈ I and (x, y) ∉ E. This would take O(n2) time as | I | = K and K ≤ n where n is the number of vertices.
- Verify Clique Set: For all pairs of vertices (x, y) such that x, y ∈ C and (x, y) ∈ E. This would take O(n2) time as |C| = K and K ≤ n where n is the number of vertices.
- Verify Size of both sets: To verify |I| = |C| = k takes O(1) time.
So, verification of a solution for Clique+IS takes at most O(n2) which is polynomial in nature so Clique+IS belongs to NP Class.
2. Clique + IS is an NP-Hard problem:
Now we need to show Clique + IS is at least as hard as a known NP-Complete Problem by reduction technique.
Here the known problem is going to be the Clique problem which is already known to be NP-complete which is explained in Proof of Clique being the NP-Complete.
We are going to show the reduction from Clique -> Clique+IS.
However, it is also possible to show reduction as Independent Set -> Clique + IS where it is known that Independent Set is NP-Complete Problem.
Input Conversion: We need to convert the input from Clique to input to Clique+IS.
Clique takes an input graph G = (V, E) and parameter K for set size. To convert the input from Clique to Clique+IS:
- We will create a graph such as G’(V’, E’) which is going to be the copy of the given graph G = (V, E).
- We are going to add the vertices in Independent Set I to graph G’ such that | I | = K and K ≤ n.
So, Graph G’ is going to be the graph that will have all the vertices and edges from Graph G and vertices from the independent set I.
The creation of a new graph is going to take O(|n| + |m|) time. Adding new vertices is going to take O(n). Since |I| = K and K ≤ n where n is the number of vertices and m are the edges. Thus the input conversion can be done in polynomial time.
Output Conversion: We need to convert the solution from Clique + IS to the solution for the Clique problem.
- Clique+IS solution yields set C, which is a Clique of size K, and set I, which is an Independent-Set of size K.
- This solution can be transformed into a Clique problem solution by setting C as a Clique of size K for graph G.
- We will remove the Independent-Set vertices I from graph G'(V’, E’), resulting in Graph G (V, E), with Clique for G equal to Clique for G’ because there is no edge difference between G and G’.
The vertices can be dropped in O(n) since | I | = K and K ≤ n where n is the number of vertices, thus the output conversion can be done in polynomial time.
Correctness: Now we need to prove the correctness of the claim which says that the “Solution of Clique + IS exits if a solution to the Clique problem exists”.
- We created a new graph G’= (V’, E’) from graph G in the Clique problem, which contains all the vertices and edges from graph G as well as vertices from the independent set I.
- In comparison to graph G, no additional edges have been added in G’.
- Now, if a Clique C exists in graph G'(V’, E’), it will also exist in graph G(V, E), because the only difference between G and G’ is the vertices from the independent set I, which are not connected by any edge and hence will not be part of Clique set C.
- This demonstrates that if Clique+IS has a solution, then Clique will as well, i.e. Clique+IS → Clique.
Also, as both graphs have the same edges, if there is no clique in graph G'(V’, E’), no clique in graph G(V, E) can exist. G’ has extra vertices from the independent set I, but there are no edges connecting them. This proved that if Clique+IS does not have a solution then Clique also has no solution i.e., ! Clique-IS → ! Clique (¬Clique-IS → ¬Clique). This proved Clique + IS exits if a solution to the Clique problem exists.
Hence, we can conclude that Clique+IS is an NP-complete problem.
For more details, please refer: Design and Analysis of Algorithms.
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!