#Semi Hamiltonian Path through grid

7 messages · Page 1 of 1 (latest)

primal fog
#

so to clarify, you trying to make a pathfinding algorithm to visit each point at least once, starting from the top left, and ending in the bottom right?

#

and also to clarify, are you looking for the shortest path or just a path

#

if my assumptions that you are looking for just a path that visits all points, my mind first jumps to starting from one point, checking the distance to each point except the last (unless it is the only point left) and connecting that point to the closest one, followed by repeating these steps on the point you connected to (taking out the prior point)

#

if you are looking for the most optimal path, that is very close to the travelling salesman problem and is to my knowledge a o(n!) timescale problem (time increases by the factorial of the number of points) and so probably not viable unless you are working with a relatively small set of points that you need to only occassionally calculate

#

the name of a hamiltonian cycle that does not wrap around is called a Hamiltonian Path btw

#

anything more specific than that is beyond my expertise though

icy ocean