# Backtracking algorithms

... programming requires more concentration than other activities. It's the reason programmers get upset about quick interruptions' - such interruptions are tantamount to asking a juggler to keep three balls in the air and hold your groceries at the same time. Steve McConnell

## Hamiltonian Cycle

Language Java | Level Intermediate | Category Algorithms | August 3, 2015 10:15 pm

### Algorithm Problem Description

Hamiltonian path is a path in an undirected or directed graph that visits each vertex exactly once. A Hamiltonian cycle is a Hamiltonian path that is a cycle. Hamiltonian Path problem is actually looking for a longest simple path in a graph. This is a classic NP-complete problem.

Write a program to find the Hamiltonian Cycle.

### Output

```

Print the values from graph: [[0, 1, 0, 1, 0], [1, 0, 1, 1, 1], [0, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 1, 1, 1, 0]]
Hamiltonian Cycle Solution found
Display the Hamiltonian Cycle Path: 0-> 1-> 2-> 4-> 3-> 0

```