/// <summary> /// Constructor /// </summary> /// <param name="edges">Array of edges</param> /// <param name="inverse">The "inverse" sign</param> public DigraphPath(List <DigraphEdge> edges, bool inverse) { if (inverse) { for (int i = edges.Count - 1; i >= 0; i--) { object o = edges[i]; if (!(o is DigraphEdge)) { throw new Exception("Path should contains digraph edges only"); } DigraphEdge e = o as DigraphEdge; if (prev != null) { if (prev.Target != e.Source) { throw new Exception("Path edges are not connected"); } } prev = e; this.edges.Add(e); } } else { for (int i = 0; i < edges.Count; i++) { object o = edges[i]; if (!(o is DigraphEdge)) { throw new Exception("Path should contains digraph edges only"); } DigraphEdge e = o as DigraphEdge; if (prev != null) { if (prev.Target != e.Source) { throw new Exception("Path edges are not connected"); } } prev = e; this.edges.Add(e); } } }
/// <summary> /// Checks whether this path contains the edge /// </summary> /// <param name="edge">The edge to check</param> /// <returns>True if path contains edge and false otherwise</returns> public bool Contains(DigraphEdge edge) { return(edges.Contains(edge)); }
/// <summary> /// Checks whether this loop contains the edge /// </summary> /// <param name="edge">The edge to check</param> /// <returns>True if this loop contains edge and false otherwise</returns> public bool Contains(DigraphEdge edge) { return(paths[0].Contains(edge) | paths[1].Contains(edge)); }
/// <summary> /// Removes outcoming edge /// </summary> /// <param name="edge">The edge to remove</param> public void RemoveOutcoming(DigraphEdge edge) { outcomingEdges.Remove(edge); }
/// <summary> /// Adds outcoming edge /// </summary> /// <param name="edge">The edge to add</param> public void AddOutcoming(DigraphEdge edge) { outcomingEdges.Add(edge); }
/// <summary> /// Removes incoming edge /// </summary> /// <param name="edge">The edge to remove</param> public void RemoveIncoming(DigraphEdge edge) { incomingEdges.Remove(edge); }
/// <summary> /// Adds incoming edge /// </summary> /// <param name="edge">The edge to add</param> public void AddIncoming(DigraphEdge edge) { incomingEdges.Add(edge); }