Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Greedy.Architecture;
- using System.Drawing;
- namespace Greedy
- {
- class DijkstraData
- {
- public Point PointState { get; set; }
- public double Price { get; set; }
- }
- public class DijkstraPathFinder
- {
- public IEnumerable<PathWithCost> GetPathsByDijkstra(State state, Point start,
- IEnumerable<Point> targets)
- {
- HashSet<Point> targetsState = new HashSet<Point>(targets); //сундуки координаты
- var track = new Dictionary<Point, DijkstraData>(); //откуда пришли и цена
- track[start] = new DijkstraData { Price = 0, PointState = new Point(0,0) };
- var visitedPoints = new List<Point>(); //посещеные точки
- for (var i=0; i < targetsState.Count ; i++)
- {
- Point toOpen = new Point(-1,-1);
- var bestPrice = double.PositiveInfinity;
- foreach (var n in track)
- {
- if (!(visitedPoints.Contains(n.Key)) && n.Value.Price < bestPrice)
- {
- toOpen = n.Key;
- }
- if (toOpen == new Point(-1,-1)) break;
- }
- }
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement