Пример #1
0
        public void Test_Dfs_Matrix_Directed()
        {
            Graph g = new GraphM(7);

            g.SetEdge(0, 1, 2);
            g.SetEdge(0, 2, 1);
            g.SetEdge(0, 3, 1);
            g.SetEdge(0, 4, 1);
            g.SetEdge(1, 5, 1);
            g.SetEdge(2, 5, 1);
            g.SetEdge(3, 6, 1);
            g.SetEdge(5, 4, 1);
            g.SetEdge(6, 4, 1);
            g.SetEdge(6, 5, 1);


            ITravel dfs = new Dfs(g, preVisit);

            dfs.Travel(0);
            Assert.AreEqual(10, g.EdgeNum());
            Assert.AreEqual("0154236", stringBuilder.ToString());
        }