People think that computer science is the art of geniuses but the actual reality is the opposite, just many people doing things that build on each other, like a wall of mini stones. Donald Knuth

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

          	        
          	        				    


Comments



Please login to add comments.