Exemplo n.º 1
0
 public SCC_KosarajuSharir(Digraph G)
 {
     marked = new bool[G.V];
     id = new int[G.V];
     DepthFirstOrder dfs = new DepthFirstOrder(G.Reverse());
     foreach (int v in dfs.GetReversePost())
     {
         if (!marked[v])
         {
             DFS(G, v);
             count++;
         }
     }
 }
Exemplo n.º 2
0
 public void DepthFirstOrder_Test()
 {
     var G = new Digraph(4);
     G.AddEdge(3, 2);
     G.AddEdge(3, 1);
     G.AddEdge(1, 0);
     G.AddEdge(2, 0);
     var DFO = new DepthFirstOrder(G);
     var actual = new List<int>( DFO.GetReversePost());
     Assert.AreEqual(3, actual[0]);
     Assert.AreEqual(0, actual[3]);
 }