Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. Alan Kay

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.