private IEnumerable <Cell> ShortestPathCells(Cell source, Cell destination) { IEnumerable <DirectedEdge> path = DijkstraShortestPath .FindPath(_graph, IndexFor(source.Point), IndexFor(destination.Point)); if (path == null) { yield break; } yield return(source); foreach (DirectedEdge edge in path) { yield return(CellFor(edge.To)); } }
public List <Point> ShortestPathList(Point source, Point destination) { var list = new List <Point>(); IEnumerable <DirectedEdge> path = DijkstraShortestPath .FindPath(_graph, IndexFor(source), IndexFor(destination)); if (path == null) { return(list); } foreach (DirectedEdge edge in path) { list.Add(CoordFor(edge.To)); } return(list); }