Given an undirected complete graph of N vertices where N > 2. The task is to find the number of different Hamiltonian cycle of the graph.
Complete Graph: A graph is said to be complete if each possible vertices is connected through an Edge.
Hamiltonian Cycle: It is a closed walk such that each vertex is visited at most once except the initial vertex. and it is not necessary to visit all the edges.
Input : N = 6 Output : Hamiltonian cycles = 60 Input : N = 4 Output : Hamiltonian cycles = 3
Let us take the example of N = 4 complete undirected graph, The 3 different hamiltonian cycle is as shown below:
Below is the implementation of the above approach:
Hamiltonian cycles = 12
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Hamiltonian Cycle | Backtracking-6
- Proof that Hamiltonian Cycle is NP-Complete
- Proof that Hamiltonian Path is NP-Complete
- Number of single cycle components in an undirected graph
- Total number of Spanning trees in a Cycle Graph
- Detect Cycle in a Directed Graph
- Disjoint Set (Or Union-Find) | Set 1 (Detect Cycle in an Undirected Graph)
- Detect cycle in an undirected graph
- Detect Cycle in a directed graph using colors
- Find minimum weight cycle in an undirected graph
- Karp's minimum mean (or average) weight cycle algorithm
- Coloring a Cycle Graph
- Check if a graphs has a cycle of odd length
- Check if there is a cycle with odd weight sum in an undirected graph
- C++ Program for Cycle Sort
- Detect a negative cycle in a Graph | (Bellman Ford)
- Detecting negative cycle using Floyd Warshall
- Degree of a Cycle Graph
- Detect cycle in an undirected graph using BFS
- Detect Cycle in a Directed Graph using BFS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.