One (or more) open polylines curve from many closed curves?

First I want to tell you that my Grasshopper knowledge is at a basic level.

I have the following situation and I wonder if there is a solution in Grasshopper.

I have a collection of closed curves (floor tiles like) that will be used for CNC v-carve. The trick is to find a way to join these curve in one (ideally) or at least fewest open polylines.

The idea is to have on the machining side fewer stops and fewer travellings above the material without lifting up.

Does anybody have any idea?

Thanks in advance.

v-carve-help.3dm (61.0 KB)

If you consider the curves as a graph, a path which travels along each edge exactly once is known as an Eulerian path.
Such a path only exists in a graph where a maximum of 2 of the vertices have an odd degree (the number of connected edges).
If you think of one continuous path, apart from the vertex it starts and ends at, to visit a vertex without travelling along any edge more than once, it needs one edge to enter the vertex and one edge to leave it. It can visit the vertex multiple times, but each time it needs to use 2 of the connected edges, hence the degree must be even.

Unfortunately the graph in your image above has nearly all degree 3 vertices, so it isn’t possible to mill in a continuous path without going over some edges more than once.

It’s ok to going over some edges more than once.

Do you have a possible solution?

Just a fast idea:

Forget the red squares, if you do the green path you’ll also do what red was.

If the green octagons are closed polylines, you’ll have all nodes with 4 connections… so you can use somewhat solver…