コード例 #1
0
ファイル: DigraphPath.cs プロジェクト: Erroman/universal
 /// <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
ファイル: DigraphPath.cs プロジェクト: Erroman/universal
 /// <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
ファイル: DigraphLoop.cs プロジェクト: Erroman/universal
 /// <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
ファイル: DigraphVertex.cs プロジェクト: Erroman/universal
 /// <summary>
 /// Removes outcoming edge
 /// </summary>
 /// <param name="edge">The edge to remove</param>
 public void RemoveOutcoming(DigraphEdge edge)
 {
     outcomingEdges.Remove(edge);
 }
コード例 #5
0
ファイル: DigraphVertex.cs プロジェクト: Erroman/universal
 /// <summary>
 /// Adds outcoming edge
 /// </summary>
 /// <param name="edge">The edge to add</param>
 public void AddOutcoming(DigraphEdge edge)
 {
     outcomingEdges.Add(edge);
 }
コード例 #6
0
ファイル: DigraphVertex.cs プロジェクト: Erroman/universal
 /// <summary>
 /// Removes incoming edge
 /// </summary>
 /// <param name="edge">The edge to remove</param>
 public void RemoveIncoming(DigraphEdge edge)
 {
     incomingEdges.Remove(edge);
 }
コード例 #7
0
ファイル: DigraphVertex.cs プロジェクト: Erroman/universal
 /// <summary>
 /// Adds incoming edge
 /// </summary>
 /// <param name="edge">The edge to add</param>
 public void AddIncoming(DigraphEdge edge)
 {
     incomingEdges.Add(edge);
 }