TemplateResults selectHallways(TemplateResults formattedRects) { var edges = new List <Edge>(); var coordinates = new List <Coordinate>(); formattedRects.centers.ForEach((p) => { coordinates.Add(new Coordinate(p.min.X, p.min.Y)); }); var triangulator = new DelaunayTriangulationBuilder(); triangulator.SetSites(coordinates.ToArray()); var triangulatedEdges = triangulator.GetEdges(new GeometryFactory(new PrecisionModel(.1))); triangulatedEdges.Geometries.ToList().ForEach((edge) => { var Q = edge.Coordinates[0]; var P = edge.Coordinates[1]; edges.Add(new Edge(new Point((int)Q.X, (int)Q.Y), new Point((int)P.X, (int)P.Y))); }); var edgePoints = new HashSet <Point>(); edges = new Prims().exec(edges); edges.ForEach((edge) => { var p12 = edge.getPoints(); edgePoints.UnionWith(edge.getPoints()); }); var newPaths = new HashSet <Rect>(); var newNonPaths = formattedRects.nonPathIndices; formattedRects.allRects.ForEach((r) => { if (edgePoints.Contains(r.min)) { newPaths.Add(r); } else { newNonPaths.Add(r); } }); formattedRects.nonPathIndices = newNonPaths.ToList(); formattedRects.pathIndices = newPaths.ToList(); return(formattedRects); }