/// <summary> /// Iteratively removes the dangling links from the rank map /// </summary> public void RemoveDanglingLinks() { VertexCollection danglings = new VertexCollection(); do { danglings.Clear(); // create filtered graph IVertexListGraph fg = new FilteredVertexListGraph( this.VisitedGraph, new InDictionaryVertexPredicate(this.ranks) ); // iterate over of the vertices in the rank map foreach (IVertex v in this.ranks.Keys) { // if v does not have out-edge in the filtered graph, remove if (fg.OutDegree(v) == 0) { danglings.Add(v); } } // remove from ranks foreach (IVertex v in danglings) { this.ranks.Remove(v); } // iterate until no dangling was removed }while(danglings.Count != 0); }
/// <summary> /// Subdivide this edge by adding new vertices between the start and /// end vertices /// </summary> /// <param name="divisions"></param> /// <param name="lastScale">The relative size of the last division</param> public void SubDivide(int divisions, double lastScale = 1.0) { _Vertices.Clear(); Vector startPt = Start.Position; Vector endPt = End.Position; Vector trans = endPt - startPt; double step = 1.0 / (divisions - 1 + lastScale); _Vertices.Add(Start); for (int i = 1; i < divisions; i++) { _Vertices.Add(new Vertex(startPt + trans * (step * i))); } _Vertices.Add(End); }