Find the start and end positions of the all-all path, then connect them

I have a form in my 2dArray like this (for example):

enter image description here

It is known that points A and B (I don't know where) and a path that spans the entire shape (must go through each cell) must exist. Can you give me some help on how to determine the A and B points and then the "cover" path? Perhaps there are some known algorithms for such a case. Or some help with the pseudocode algorithm. Thanks in advance.

+3


source to share


1 answer


Check the link nhahdth

to see what your problem is in general np-hard. this mathoverflow article links to a doc setting the result for plots on mesh with holes - you won't be much better than using brute force if you can't find more constraints.



You may be able to identify at least one of your start and end nodes by searching for vertices of degree 1 in the underlying grid cell plot.

0


source







All Articles