Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Greedy.Architecture;
  7. using System.Drawing;
  8.  
  9. namespace Greedy
  10. {
  11.     class DijkstraData
  12.     {
  13.         public Point PointState { get; set; }
  14.         public double Price { get; set; }
  15.     }
  16.     public class DijkstraPathFinder
  17.     {
  18.         public IEnumerable<PathWithCost> GetPathsByDijkstra(State state, Point start,
  19.             IEnumerable<Point> targets)
  20.         {
  21.             HashSet<Point> targetsState = new HashSet<Point>(targets); //сундуки координаты
  22.             var track = new Dictionary<Point, DijkstraData>(); //откуда пришли и цена
  23.             track[start] = new DijkstraData { Price = 0, PointState = new Point(0,0) };
  24.             var visitedPoints = new List<Point>(); //посещеные точки
  25.    
  26.             for (var i=0; i < targetsState.Count ; i++)
  27.             {
  28.                 Point toOpen = new Point(-1,-1);
  29.                 var bestPrice = double.PositiveInfinity;
  30.                 foreach (var n in track)
  31.                 {
  32.                     if (!(visitedPoints.Contains(n.Key)) && n.Value.Price < bestPrice)
  33.                     {
  34.                        
  35.                         toOpen = n.Key;
  36.                     }
  37.                     if (toOpen == new Point(-1,-1)) break;
  38.  
  39.  
  40.                 }
  41.  
  42.             }
  43.             throw new NotImplementedException();
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement