/// <summary> /// Create a merged path. /// </summary> /// <remarks> /// <para> /// This method creates an edge path that stops if an edge is not white /// or the edge has no more predecessors. /// </para> /// </remarks> /// <param name="se">end edge</param> /// <param name="colors">edge color dictionary</param> /// <returns>path to edge</returns> public EdgeCollection MergedPath(IEdge se, EdgeColorDictionary colors) { EdgeCollection path = new EdgeCollection(); IEdge ec = se; GraphColor c = colors[ec]; if (c != GraphColor.White) { return(path); } else { colors[ec] = GraphColor.Black; } path.Insert(0, ec); while (EdgePredecessors.Contains(ec)) { IEdge e = EdgePredecessors[ec]; c = colors[e]; if (c != GraphColor.White) { return(path); } else { colors[e] = GraphColor.Black; } path.Insert(0, e); ec = e; } return(path); }
/// <summary> /// Returns the path leading to the vertex v. /// </summary> /// <param name="se">end of the path</param> /// <returns>path leading to v</returns> public EdgeCollection Path(IEdge se) { EdgeCollection path = new EdgeCollection(); IEdge ec = se; path.Insert(0, ec); while (EdgePredecessors.Contains(ec)) { IEdge e = EdgePredecessors[ec]; path.Insert(0, e); ec = e; } return(path); }
/// <summary> /// Returns the path leading to the vertex v. /// </summary> /// <param name="v">end of the path</param> /// <returns>path leading to v</returns> public EdgeCollection Path(IVertex v) { EdgeCollection path = new EdgeCollection(); IVertex vc = v; while (Predecessors.Contains(v)) { IEdge e = Predecessors[v]; path.Insert(0, e); v = e.Source; } return(path); }