I have a list of unordered line segments, some of whose endpoints lie on the same point. How do I connect these segments efficiently to form a minimal amount of paths?
For example, if I have the following lines $(x_1, y_1, x_2, y_2)$: [[0, 0, 2, 2], [4, 0, 2, 1], [2, 2, 4, 0]]
the algorithm should be able to join these three segments into one path $(x, y)$: [[0, 0], [4, 0], [2, 1]]
.