/// <summary> Calculates the route. </summary> /// /// <remarks> Vladyslav, 24.05.2016. </remarks> /// /// <exception cref="ApplicationException"> Thrown when route serch algorithm is not found. </exception> /// /// <param name="matrix"> The matrix. </param> /// <param name="origin"> The origin. </param> /// <param name="destination"> Destination for the. </param> /// <param name="algorithmName"> Name of the algorithm. </param> /// /// <returns> The calculated route. </returns> public Route CalculateRoute(double[,] matrix, int origin, int destination, string algorithmName) { IRouteSearchAlgorithm algorithm = _factory.GetRouteSearchAlgorithm(algorithmName); if (algorithm == null) { throw new ApplicationException("Unknown Algorithm"); } return(algorithm.FindRoute(matrix, origin, destination)); }
public static int Execute(CountRoutesFilter filter) { if (filter.maxCost == int.MaxValue && filter.maxStops == int.MaxValue) { throw new Exception("Please, select a max value or max cost or i'll be in a overflow :("); } using (IRouteSearchAlgorithm alg = AlgorithmFactory.RouteSearchAlgorithm(filter.graph)) { alg.SetMaxStops(filter.maxStops); alg.SetMaxCost(filter.maxCost); alg.SetExactlyStops(filter.exactlyStops); return(alg.NumberOfRoutes(filter.start, filter.end)); } }