Esempio n. 1
0
        public void TestCase_FromTestData_Success()
        {
            int vertexesCount = 4;

            Tuple <int, int>[] edges =
            {
                new Tuple <int, int>(1, 2),
                new Tuple <int, int>(1, 3),
                new Tuple <int, int>(2, 4),
                new Tuple <int, int>(3, 4),
                new Tuple <int, int>(4, 5),
            };

            Dictionary <int, int> expectedDistances = new Dictionary <int, int>
            {
                { 1, 0 },
                { 2, 6 },
                { 3, 6 },
                { 4, 12 },
                { 5, 18 }
            };

            BreadthFirstSearchShortestReachSolution solution = new BreadthFirstSearchShortestReachSolution(
                vertexesCount,
                edges);

            Dictionary <int, int> distances = solution.FindDistances(1);

            Assert.That(distances, Is.EqualTo(expectedDistances));
        }
Esempio n. 2
0
        public void TestCase_FromSecondTestData_Success()
        {
            int vertexesCount = 3;

            Tuple <int, int>[] edges =
            {
                new Tuple <int, int>(3, 2)
            };

            Dictionary <int, int> expectedDistances = new Dictionary <int, int>
            {
                { 1, -1 },
                { 2, 0 },
                { 3, 6 }
            };

            BreadthFirstSearchShortestReachSolution solution = new BreadthFirstSearchShortestReachSolution(
                vertexesCount,
                edges);

            Dictionary <int, int> distances = solution.FindDistances(2);

            Assert.That(distances, Is.EqualTo(expectedDistances));
        }