public IEnumerable <int> Build(IEnumerable <Vector2> vertices, IReadOnlyCollection <IEnumerable <int> > holeVertices) { var sortedVertices = vertices.Select((v, index) => new SortedVertex(index, v)) .OrderBy(v => v.Vertex.x).ThenBy(v => v.Vertex.y).ToList(); if (sortedVertices.Count < 3) { throw new ArgumentException($"Minimum vertices count for triangulation is 3, but was {sortedVertices.Count}"); } var convexHull = new HullEdgesList(sortedVertices.Count); var graph = new TriangulationGraph(); convexHull.Add(new HullEdge(1, 1)); convexHull.Add(new HullEdge(0, 0)); graph[new Edge(0, 1)].Insert(2); for (var i = 2; i < sortedVertices.Count; i++) { AddVertexToTriangulation(i, sortedVertices, convexHull, graph); } return(DelaunayTriangulationConverter.ConvertToTriangulation(graph, sortedVertices, holeVertices)); }