Пример #1
0
 private static void DuplicateGraph(DigraphBase g)
 {
     for (int i = 0; i < g.V; i++)
     {
         g.AddEdge(i, i);
         foreach (var v in g.Adj(i))
         {
             g.AddEdge(i, v);
         }
     }
 }
Пример #2
0
 private void DfsVisit(DigraphBase g, int u)
 {
     _ids[u]            = _count;
     _vertices[u].Color = Color.Gray;
     foreach (var v in g.Adj(u))
     {
         if (_vertices[v].Color == Color.White)
         {
             DfsVisit(g, v);
         }
     }
     _vertices[u].Color = Color.Black;
 }
Пример #3
0
 private void DfsOrderVisit(DigraphBase g, int u, Stack <int> stack)
 {
     _vertices[u].Color = Color.Gray;
     _vertices[u].D     = ++_time;
     foreach (var v in g.Adj(u))
     {
         if (_vertices[v].Color == Color.White)
         {
             DfsOrderVisit(g, v, stack);
         }
     }
     _vertices[u].F     = ++_time;
     _vertices[u].Color = Color.Black;
     stack.Push(u);
 }