All in all, your problem seems fuzzy. For example, given the following set of vertices:

which of these non-convex polygons would you consider the βrightβ way to connect them?



Now, obviously, there are various possible criteria that can be used to choose between the various possible orders. For example, you can choose the order in which it minimizes the total length of the edges , which should give quite βreasonableβ results if the points really lie close enough to each other on the border of a simple polygon:

Unfortunately, for a general set of points, finding an order that minimizes the total length of an edge is a well-known NP-complete problem . However, there are many heuristic algorithms.
Ilmari karonen
source share