Reasonably quick way of checking for subsets in a list of edges
I have a list of edges, these edges are made up of an array of Points, a type containing a coordinate.
I'm attempting to remove any edges that are subsets of another edge, i.e. in which all the points of one edge are contained, in order, in another edge (although in order can mean both backwards and forwards).
I'm struggling to come up with a solution for this that doesn't require four nested for loops (loop through edges, loop through edges again, loop through points of first, loop through points of second, comparing). Is there a faster way of handling this? Or at least something that won't be quite as bad.
Edit: This is all being done in C#. I also already have a method for comparing points to one another for equality.
if this is a line (pretend the numbers are coordinates).
and this is another line made up of some of the same points:
The second is a subline of the first, so I want to remove the second from the list.
Construct a map from each pair of points (i.e., segments) to a collection of pairs of edges and indexes, where the edge has that segment at that index. Then, iterate through the map entries, iterate the first edge through the collection, iterate the second edge through the collection, and compare them outward starting from the given indexes.