Ejemplo n.º 1
0
        public void Test_SGG_Creation()
        {
            var g = new SquireGridGraph(ROW, COL, false);


            for (int i = 0; i < g.VerticesNum(); i++)
            {
                int row, col;
                g.GetRowAndColFromVertex(i, out row, out col);

                g.SetNeighbor(row, col, Direction.East, 1);
                g.SetNeighbor(row, col, Direction.South, 1);
                g.SetNeighbor(row, col, Direction.West, 1);
                g.SetNeighbor(row, col, Direction.North, 1);
            }

            ITravel dfs = new Bfs(g, preVisit);

            dfs.Travel(16);
            Assert.AreEqual(6280, g.EdgeNum());
        }
Ejemplo n.º 2
0
        public void Test_Bfs_List_Non_Directed()
        {
            Graph g = new GraphL(7, false);

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


            ITravel bfs = new Bfs(g, preVisit);

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