Exemple #1
0
        private AlgorithmResult RunDijkstra(Func <ObjectId, Weight> weightFunction)
        {
            var graph = new SimpleGraph(_cities.Select(c => c.Id), weightFunction);

            foreach (var road in _roads)
            {
                graph.AddEdge(road.ToCityId, road.FromCityId, road.Id);
            }

            var startTime = DateTime.Now;

            graph.RunDijkstra(_centralCities.Select(c => c.Id));

            var algorithmResult = new AlgorithmResult()
            {
                RunDate = startTime,
                Nodes   = graph.Results
            };

            return(algorithmResult);
        }