Ejemplo n.º 1
0
        public void BfsNonRecursive()
        {
            var sut = new AdjacencyListGraph <int>();

            sut.AddEdge(0, 1);
            sut.AddEdge(0, 3);
            sut.AddEdge(1, 2);
            sut.AddEdge(3, 4);
            sut.AddEdge(4, 5);

            var bfs = sut.BreadthFirstSearch();

            Assert.Equal(0, bfs[0]);
            Assert.Equal(1, bfs[1]);
            Assert.Equal(3, bfs[2]);
            Assert.Equal(2, bfs[3]);
            Assert.Equal(4, bfs[4]);
            Assert.Equal(5, bfs[5]);
        }