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.

**Formula:**

**Examples:**

Input :N = 6Output :Hamiltonian cycles = 60Input :N = 4Output :Hamiltonian cycles = 3

**Explaination:**

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:

*chevron_right*

*filter_none*

**Output:**

Hamiltonian cycles = 12

## Recommended Posts:

- Hamiltonian Cycle | Backtracking-6
- Proof that Hamiltonian Path is NP-Complete
- Total number of Spanning trees in a Cycle Graph
- Number of single cycle components in an undirected graph
- C++ Program for Cycle Sort
- Coloring a Cycle Graph
- Degree of a Cycle Graph
- Detect Cycle in a Directed Graph using BFS
- Detect Cycle in a Directed Graph
- Check if a graphs has a cycle of odd length
- Detect cycle in an undirected graph using BFS
- Detect cycle in an undirected graph
- Check if there is a cycle with odd weight sum in an undirected graph
- Detecting negative cycle using Floyd Warshall
- Detect Cycle in a directed graph using colors