Esempio n. 1
0
        public void BreadthFirstSearch_ValidParamsPassed_Success()
        {
            string[] nodes = new[] { "0", "1", "2", "3", "4", "5", "6", "7" };
            UndirectedGraph <string> graph = new UndirectedGraph <string>(nodes);

            graph.SetEdge(0, 1);
            graph.SetEdge(0, 2);
            graph.SetEdge(0, 3);

            graph.SetEdge(1, 4);

            graph.SetEdge(3, 5);

            graph.SetEdge(4, 5);

            graph.SetEdge(5, 6);
            graph.SetEdge(5, 7);

            var visitedNodes = graph.BreadthFirstSearch();

            Assert.That(visitedNodes, Is.EquivalentTo(new string[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        }