I have been playing with Hamiltonian paths for some time and have found some cool uses of it. One being a sort of puzzle where the goal is to connect all the nodes to form a hamiltonian path.
So, being a novice programmer I am, I created a very basic brute force graph generator that creates graphs having a hamiltonian path. But the problem arises when I try to increase the graph size to 10x10. Needless to say, by brute force does not works there.
I understand Hamiltonian path is an NP-Complete problem, but is there a method to optimize the graph generation process. Any sort of trick that can create 15x15 grids in reasonable time.
Thank you very much.
3 -> 1 -> 2 -> 4) you want to create a graph (e.g.3 -> 1,1 -> 2,2 -> 4,3 -> 4, the last edge is not mandatory one)? If it is, why not take vertexes in arbitrary order (shuffle them), declare them to be on the path, create corresponding edges (path) and then add arbitrary edges (that are on on the path)?