Пример #1
0
        public void GetShortestPath(Graph graph, int sourceNode, int destinationNode, int[] expected)
        {
            var bellmanFord = new BellmanFord(graph, sourceNode);
            var result      = bellmanFord.GetShortestPath(destinationNode);

            Assert.Equal(expected, result);
        }
        public int[] FindCitiesInRoute(City departureCity, City arrivalCity)
        {
            var sourceNode      = departureCity.CityId - 1; //assumed CityId as index, may be changed.
            var destinationNode = arrivalCity.CityId - 1;

            var bellmanFord = new BellmanFord(this.graph, sourceNode);
            var result      = bellmanFord.GetShortestPath(destinationNode);

            Array.ForEach <int>(result, (value) => // TODO refactor.
            {
                value--;
            });

            return(result);
        }