Exemple #1
0
 public static void SetReference(this IEnumerable <DirectedGraphNode> nodes)
 {
     foreach (var node in nodes)
     {
         DirectedGraphNode a = node;
         foreach (var id in a.EdgesId)
         {
             DirectedGraphNode b    = nodes.Where(x => x.Id == id).FirstOrDefault();
             DirectedGraphEdge edge = new DirectedGraphEdge(a, b);
         }
     }
 }
Exemple #2
0
 internal void Build(DirectedGraphEdge member)
 {
     if (!IsComplete)
     {
         if (member == Members[0])
         {
             IsComplete = true;
         }
         else
         {
             this.Members.Add(member);
         }
     }
 }
Exemple #3
0
 private static IEnumerable <DirectedGraphCycle> FindAllCycles(HashSet <DirectedGraphNode> alreadyVisited, DirectedGraphNode a, Boolean issub = false)
 {
     for (int i = 0; i < a.Edges.Count; i++)
     {
         DirectedGraphEdge e = a.Edges[i];
         if (alreadyVisited.Contains(e.B))
         {
             yield return(new DirectedGraphCycle(e));
         }
         else
         {
             HashSet <DirectedGraphNode> newSet = i == a.Edges.Count - 1 ? alreadyVisited : new HashSet <DirectedGraphNode>(alreadyVisited);
             newSet.Add(e.B);
             foreach (DirectedGraphCycle c in FindAllCycles(newSet, e.B))
             {
                 c.Build(e);
                 yield return(c);
             }
         }
     }
 }
Exemple #4
0
 public DirectedGraphCycle(DirectedGraphEdge firstMember)
     : this()
 {
     this.Members.Add(firstMember);
 }