# Prove that a problem consisting of Clique and Independent Set is NP Complete

** 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.

__Explanation:__

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

Kexists in the given graph.

An Independent Set

graphSofG = (V, E)is a collection of vertices in the graphG = (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.

__Proof:__

**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****(x, y) âˆ‰ E**. This would take**O(n**time as^{2})**| I | = K**and**K â‰¤ n**where**n****Verify Clique Set:**For all pairs of vertices**(x, y)**such that**x, y âˆˆ C**and**(x, y) âˆˆ E**. This would take**O(n**time as^{2})**|C| = K****K â‰¤ n****n**is the number of vertices.**Verify Size of both sets:**To verify**|I| = |C| = k****O(1)**time.

So, verification of a solution for Clique+IS takes at most **O(n ^{2})** 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â€™****| 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**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**.

**Conclusion:**

Hence, we can conclude that

Clique+IS is an NP-complete problem.

For more details, please refer: Design and Analysis of Algorithms.

Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

## Please

Loginto comment...