Prerequisite: NPCompleteness, Hamiltonian cycle.
Hamiltonian Cycle: A cycle in an undirected graph G =(V, E) which traverses every vertex exactly once.
Problem Statement:Given a graph G(V, E), the problem is to determine if the graph contains a Hamiltonian cycle consisting of all the vertices belonging to V.
Explanation –
An instance of the problem is an input specified to the problem. An instance of the Independent Set problem is a graph G (V, E), and the problem is to check whether the graph can have a Hamiltonian Cycle in G.
Since an NPComplete problem, by definition, is a problem which is both in NP and NPhard, the proof for the statement that a problem is NPComplete consists of two parts:
 The problem itself is in NP class.
 All other problems in NP class can be polynomialtime reducible to that.
(B is polynomialtime reducible to C is denoted as )
If the 2nd condition is only satisfied then the problem is called NPHard.
But it is not possible to reduce every NP problem into another NP problem to show its NPCompleteness all the time. That is why if we want to show a problem is NPComplete, we just show that the problem is in NP and if any NPComplete problem is reducible to that, then we are done, i.e. if B is NPComplete and for C in NP, then C is NPComplete.

Hamiltonian Cycle is in NP
If any problem is in NP, then, given a ‘certificate’, which is 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 is a sequence of vertices forming Hamiltonian Cycle in the graph. We can validate this solution by verifying that all the vertices belong to the graph and each pair of vertices belonging to the solution are adjacent. This can be done in polynomial time, that is O(V +E) using the following strategy for graph G(V, E):flag=true For every pair {u, v} in the subset V’: Check that these two have an edge between them If there is no edge, set flag to false and break If flag is true: Solution is correct Else: Solution is incorrect

Hamiltonian Cycle is NP Hard
In order to prove the Hamiltonian Cycle is NPHard, we will have to reduce a known NPHard problem to this problem. We will carry out a reduction from the Hamiltonian Path problem to the Hamiltonian Cycle problem.
Every instance of the Hamiltonian Path problem consisting of a graph G =(V, E) as the input can be converted to Hamiltonian Cycle problem consisting of graph G’ = (V’, E’). We will construct the graph G’ in the following way: V’ = Add vertices V of the original graph G and add an additional vertex V_{new} such that all the vertices connected of the graph are connected to this vertex. The number of vertices increases by 1, V’ =V+1.
 E’ = Add edges E of the original graph G and add new edges between the newly added vertex and the original vertices of the graph. The number of edges increases by the number of vertices V, that is, E’=E+V.
The new graph G’ can be obtained in polynomial time, by adding new edges to the new vertex, that requires O(V) time. This reduction can be proved by the following two claims:

Let us assume that the graph G contains a hamiltonian path covering the V vertices of the graph starting at a random vertex say V_{start} and ending at Vend, now since we connected all the vertices to an arbitrary new vertex V_{new} in G’.
We extend the original Hamiltonian Path to a Hamiltonian Cycle by using the edges V_{end} to V_{new} and V_{new} to V_{start} respectively. The graph G’ now contains the closed cycle traversing all vertices once.  We assume that the graph G’ has a Hamiltonian Cycle passing through all the vertices, inclusive of V_{new}. Now to convert it to a Hamiltonian Path, we remove the edges corresponding to the vertex V_{new} in the cycle. The resultant path will cover the vertices V of the graph and will cover them exactly once.
Thus we can say that the graph G’ contains a Hamiltonian Cycle iff graph G contains a Hamiltonian Path. Therefore, any instance of the Hamiltonian Cycle problem can be reduced to an instance of the Hamiltonian Path problem. Thus, the Hamiltonian Cycle is NPHard.
Conclusion: Since, the Hamiltonian Cycle is both, a NPProblem and NPHard. Therefore, it is a NPComplete problem.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a studentfriendly price and become industry ready.
Recommended Posts:
 Proof that Hamiltonian Path is NPComplete
 Number of Hamiltonian cycle
 Hamiltonian Cycle  Backtracking6
 Proof that Dominant Set of a Graph is NPComplete
 Proof that vertex cover is NP complete
 Proof that Independent Set in Graph theory is NP Complete
 Proof that Clique Decision problem is NPComplete  Set 2
 Proof that traveling salesman problem is NP Hard
 Proof that Clique Decision problem is NPComplete
 Proof that Subgraph Isomorphism problem is NPComplete
 Coloring a Cycle Graph
 Degree of a Cycle Graph
 Detect Cycle in a Directed Graph
 Count of all cycles without any inner cycle in a given Graph
 Detect Cycle in a Linked List using Map
 Detect Cycle in a Directed Graph using BFS
 Detect cycle in an undirected graph using BFS
 Detect cycle in an undirected graph
 Check if a graphs has a cycle of odd length
 Shortest cycle in an undirected unweighted graph
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.