The Wayback Machine - https://web.archive.org/web/20240813141844/https://www.geeksforgeeks.org/proof-that-vertex-cover-is-np-complete/
Open In App

Proof that vertex cover is NP complete

Last Updated : 03 Aug, 2018
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite – Vertex Cover Problem, NP-Completeness
Problem – Given a graph G(V, E) and a positive integer k, the problem is to find whether there is a subset V’ of vertices of size at most k, such that every edge in the graph is connected to some vertex in V’.

Explanation –
First let us understand the notion of an instance of a problem. An instance of a problem is nothing but an input to the given problem. An instance of the Vertex Cover problem is a graph G (V, E) and a positive integer k, and the problem is to check whether a vertex cover of size at most k exists in G. Since an NP Complete problem, by definition, is a problem which is both in NP and NP hard, the proof for the statement that a problem is NP Complete consists of two parts:

  1. Proof that vertex cover is in NP –
    If any problem is in NP, then, given a ‘certificate’ (a solution) to the problem and an instance of the problem (a graph G and a positive integer k, in this case), we will be able to verify (check whether the solution given is correct or not) the certificate in polynomial time.

    The certificate for the vertex cover problem is a subset V’ of V, which contains the vertices in the vertex cover. We can check whether the set V’ is a vertex cover of size k using the following strategy (for a graph G(V, E)):

    let count be an integer
    set count to 0
    for each vertex v in V’
        remove all edges adjacent to v from set E
        increment count by 1
        if count = k and E is empty
        then
            the given solution is correct
        else
            the given solution is wrong
    

    It is plain to see that this can be done in polynomial time. Thus the vertex cover problem is in the class NP.

  2. Proof that vertex cover is NP Hard –
    To prove that Vertex Cover is NP Hard, we take some problem which has already been proven to be NP Hard, and show that this problem can be reduced to the Vertex Cover problem. For this, we consider the Clique problem, which is NP Complete (and hence NP Hard).

    “In computer science, 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.”

    Here, we consider the problem of finding out whether there is a clique of size k in the given graph. Therefore, an instance of the clique problem is a graph G (V, E) and a non-negative integer k, and we need to check for the existence of a clique of
    size k in G.

    Now, we need to show that any instance (G, k) of the Clique problem can be reduced to an instance of the vertex cover problem. Consider the graph G’ which consists of all edges not in G, but in the complete graph using all vertices in G. Let us call this the complement of G. Now, the problem of finding whether a clique of size k exists in the graph G is the same as the problem of finding whether there is a vertex cover of size |V| – k in G’. We need to show that this is indeed the case.

    Assume that there is a clique of size k in G. Let the set of vertices in the clique be V’. This means |V’| = k. In the complement graph G’, let us pick any edge (u, v). Then at least one of u or v must be in the set V – V’. This is because, if both u and v were from the set V’, then the edge (u, v) would belong to V’, which, in turn would mean that the edge (u, v) is in G. This is not possible since (u, v) is not in G. Thus, all edges in G’ are covered by vertices in the set V – V’.

    Now assume that there is a vertex cover V’’ of size |V| – k in G’. This means that all edges in G’ are connected to some vertex in V’’. As a result, if we pick any edge (u, v) from G’, both of them cannot be outside the set V’’. This means, all
    edges (u, v) such that both u and v are outside the set V’’ are in G, i.e., these edges constitute a clique of size k.

Thus, we can say that there is a clique of size k in graph G if and only if there is a vertex cover of size |V| – k in G’, and hence, any instance of the clique problem can be reduced to an instance of the vertex cover problem. Thus, vertex cover is NP Hard. Since vertex cover is in both NP and NP Hard classes, it is NP Complete.

To understand the proof, consider the following example graph and its complement:

See for – Proof that Hamiltonian Path is NP-Complete



Similar Reads

Vertex Cover Problem (Dynamic Programming Solution for Tree)
A vertex cover of an undirected graph is a subset of its vertices such that for every edge (u, v) of the graph, either ‘u’ or ‘v’ is in vertex cover. Although the name is Vertex Cover, the set covers all edges of the given graph. The problem to find minimum size vertex cover of a graph is NP complete. But it can be solved in polynomial time for tre
15+ min read
Finding minimum vertex cover size of a graph using binary search
A vertex cover of an undirected graph is a subset of its vertices such that for every edge (u, v) of the graph, either ‘u’ or ‘v’ is in vertex cover. There may be a lot of vertex covers possible for a graph. Problem Find the size of the minimum size vertex cover, that is, cardinality of a vertex cover with minimum cardinality, for an undirected con
15+ min read
Introduction and Approximate Solution for Vertex Cover Problem
A vertex cover of an undirected graph is a subset of its vertices such that for every edge (u, v) of the graph, either 'u' or 'v' is in the vertex cover. Although the name is Vertex Cover, the set covers all edges of the given graph. Given an undirected graph, the vertex cover problem is to find minimum size vertex cover. The following are some exa
10 min read
Check if incoming edges in a vertex of directed graph is equal to vertex itself or not
Given a directed Graph G(V, E) with V vertices and E edges, the task is to check that for all vertices of the given graph, the incoming edges in a vertex is equal to the vertex itself or not. Examples: Input: Output: Yes Explanation: For vertex 0 there are 0 incoming edges, for vertex 1 there is 1 incoming edge. Same for vertex 2 nd 3. Approach: Th
6 min read
Check if vertex X lies in subgraph of vertex Y for the given Graph
Given an undirected graph and two vertices X and Y, our task is to check whether the vertex X lies in the subgraph of the vertex Y. Examples: Input: X = 2, Y = 3 Output: No Explanation: Subgraph of a vertex Y = 3 is set of all the vertex which lies below Y and are reachable by Y. Here subgraph of 3 contains {6} not 2. Input: X = 6, Y = 1 Output: Ye
10 min read
Check if every vertex triplet in graph contains two vertices connected to third vertex
Given an undirected graph with N vertices and K edges, the task is to check if for every combination of three vertices in the graph, there exists two vertices which are connected to third vertex. In other words, for every vertex triplet (a, b, c), if there exists a path between a and c, then there should also exist a path between b and c. Examples:
9 min read
Find the vertex diagonally opposite to the vertex M from an N-sided polygon
Given two integers N and M, the task is to find the vertex diagonally opposite to the Mth vertex of an N-sided polygon. Examples: Input: N = 6, M = 2 Output: 5 Explanation: It can be observed from the image above that the vertex opposite to vertex 5 is 2. Input: N = 8, M = 5 Output: 1 Explanation: It can be observed from the image above that the ve
3 min read
Area of a triangle with two vertices at midpoints of opposite sides of a square and the other vertex lying on vertex of a square
Given a positive integer N representing the side of a square, the task is to find the area of a triangle formed by connecting the midpoints of two adjacent sides and vertex opposite to the two sides. Examples: Input: N = 10Output: 37.5 Input: N = 1Output: 0.375 Approach: The given problem can be solved based on the following observations: The one s
5 min read
Proof that Hamiltonian Cycle is NP-Complete
Prerequisite: NP-Completeness, Hamiltonian cycle. Hamiltonian Cycle: A cycle in an undirected graph G=(V, E) traverses every vertex exactly once. Problem Statement: Given a graph G=(V, E), the problem is to determine if graph G contains a Hamiltonian cycle consisting of all the vertices belonging to V. Explanation: An instance of the problem is an
4 min read
Proof that Independent Set in Graph theory is NP Complete
Prerequisite: NP-Completeness, Independent set. An Independent Set S of graph G = (V, E) is a set of vertices such that no two vertices in S are adjacent to each other. It consists of non- adjacent vertices. Problem: Given a graph G(V, E) and an integer k, the problem is to determine if the graph contains an independent set of vertices of size >
5 min read
three90RightbarBannerImg