tp927
Dec 19th, 2009, 03:43 PM
hi,
perhaps this should be in 'code it better', or perhaps here.
I'm writing a program to find hamiltonian cycles in a graph, which could be very large (18 vertices).
currently, i start at the vertex of least degree, then store all possible hamiltonian (i.e. don't visit a vertex more than once) paths of length 3 in an array, then all of length 4.... continuing up to 18, then check which ones can have their ends joined up to find a cycle.
the thing is, i need to my array to be about 10,000,000 entries long for me to get up to about 10!!!
if the probability of one vertex being joined to another is 0.5, then you'd expect there to be about:
8.5*8*7.5*...*(0.5*(17-n))
paths of length n, right?
so this is only going to get bigger.
I only want to check whether a hamiltonion cycle exists though, not find all of them!
what can i do to make my code more manageable and specific to my problem?
perhaps this should be in 'code it better', or perhaps here.
I'm writing a program to find hamiltonian cycles in a graph, which could be very large (18 vertices).
currently, i start at the vertex of least degree, then store all possible hamiltonian (i.e. don't visit a vertex more than once) paths of length 3 in an array, then all of length 4.... continuing up to 18, then check which ones can have their ends joined up to find a cycle.
the thing is, i need to my array to be about 10,000,000 entries long for me to get up to about 10!!!
if the probability of one vertex being joined to another is 0.5, then you'd expect there to be about:
8.5*8*7.5*...*(0.5*(17-n))
paths of length n, right?
so this is only going to get bigger.
I only want to check whether a hamiltonion cycle exists though, not find all of them!
what can i do to make my code more manageable and specific to my problem?