private static Stack <Location> GetShorterPath(DijkstraLocation destLocation) { var stack = new Stack <Location>(); while (destLocation != null) { stack.Push(destLocation.ToLocation()); destLocation = destLocation.PreviousLocation; } return(stack); }
private void Init(HashSet <Location> locations, string startingLocationId) { locations.ForEach(location => { DijkstraLocation locToAdd = location.Id == startingLocationId ? new DijkstraLocation(location) { Distance = 0 } : new DijkstraLocation(location); _dijkstraLocations.Add(locToAdd); }); DijkstraLocation.MapConnectedLocations(_dijkstraLocations, locations); }