Exemple #1
0
        public static void ClassInit(TestContext context)
        {
            basicGraph = new Graph(9);
            basicGraph.AddEdge(0, 1);
            basicGraph.AddEdge(0, 2);
            basicGraph.AddEdge(0, 5);
            basicGraph.AddEdge(0, 6);
            basicGraph.AddEdge(2, 7);
            basicGraph.AddEdge(6, 4);
            basicGraph.AddEdge(4, 3);
            basicGraph.AddEdge(4, 5);

            baseicDigraph = new Digraph(7);
            baseicDigraph.AddEdge(5, 0);
            baseicDigraph.AddEdge(2, 4);
            baseicDigraph.AddEdge(3, 2);
            baseicDigraph.AddEdge(1, 2);
            baseicDigraph.AddEdge(0, 1);
            baseicDigraph.AddEdge(4, 3);
            baseicDigraph.AddEdge(3, 5);
            baseicDigraph.AddEdge(0, 2);
            baseicDigraph.AddEdge(6, 5);
        }
Exemple #2
0
 public Digraph Reverse()
 {
     var rev = new Digraph(this._V);
     for (int v = 0; v < _V; v++)
     {
         foreach (int w in adj[v])
         {
             rev.AddEdge(w, v);
         }
     }
     return rev;
 }
Exemple #3
0
 public void Digraph_API_Test()
 {
     Digraph G = new Digraph(3);
     G.AddEdge(0, 1);
     G.AddEdge(0, 2);
     List<int> e = new List<int>(G.Adj(0));
     Assert.AreEqual(1, e[0]);
 }
Exemple #4
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]);
 }