Example #1
0
        public void DfsNonRecursive()
        {
            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 dfs = sut.DepthFirstSearch();

            for (var i = 0; i < 6; i++)
            {
                Assert.Equal(i, dfs[i]);
            }
        }