示例#1
0
 /// <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);
         }
     }
 }
示例#2
0
 /// <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));
 }
示例#3
0
 /// <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));
 }
示例#4
0
 /// <summary>
 /// Removes outcoming edge
 /// </summary>
 /// <param name="edge">The edge to remove</param>
 public void RemoveOutcoming(DigraphEdge edge)
 {
     outcomingEdges.Remove(edge);
 }
示例#5
0
 /// <summary>
 /// Adds outcoming edge
 /// </summary>
 /// <param name="edge">The edge to add</param>
 public void AddOutcoming(DigraphEdge edge)
 {
     outcomingEdges.Add(edge);
 }
示例#6
0
 /// <summary>
 /// Removes incoming edge
 /// </summary>
 /// <param name="edge">The edge to remove</param>
 public void RemoveIncoming(DigraphEdge edge)
 {
     incomingEdges.Remove(edge);
 }
示例#7
0
 /// <summary>
 /// Adds incoming edge
 /// </summary>
 /// <param name="edge">The edge to add</param>
 public void AddIncoming(DigraphEdge edge)
 {
     incomingEdges.Add(edge);
 }