Ejemplo n.º 1
0
 /// <summary>
 /// Solves the single-source shortest path problem for a graph with nonnegative edge path costs and returns the min-weight sum to each point in the grid using a custom neighbor function.
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="start"></param>
 /// <param name="neighbors"></param>
 /// <returns></returns>
 public static long[,] DijkstraMinPathWeights(this long[,] grid, Coordinate start, Func <long[, ], Coordinate, IEnumerable <Coordinate> > neighbors) =>
 grid.DijkstraMinPathWeights(start, null, neighbors);
Ejemplo n.º 2
0
 // Dijkstra
 // http://en.wikipedia.org/wiki/Dijkstra's_algorithm
 /// <summary>
 /// Solves the single-source shortest path problem for a graph with nonnegative edge path costs and returns the min-weight sum to the goal point in the grid using a custom neighbor function.
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="start"></param>
 /// <param name="goal"></param>
 /// <param name="neighbors"> </param>
 /// <returns></returns>
 public static long DijkstraMinPathWeight(this long[,] grid, Coordinate start, Coordinate goal, Func <long[, ], Coordinate, IEnumerable <Coordinate> > neighbors) =>
 grid.DijkstraMinPathWeights(start, goal, neighbors)[goal.Row, goal.Col];
Ejemplo n.º 3
0
 /// <summary>
 /// Solves the single-source shortest path problem for a graph with nonnegative edge path costs and returns the min-weight sum to each point in the grid.
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="start"></param>
 /// <returns></returns>
 public static long[,] DijkstraMinPathWeights(this long[,] grid, Coordinate start) =>
 grid.DijkstraMinPathWeights(start, null, Neighbors8);
Ejemplo n.º 4
0
 /// <summary>
 /// Solves the single-source shortest path problem for a graph with nonnegative edge path costs and returns the min-weight sum to the goal point in the grid.
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="start"></param>
 /// <param name="goal"></param>
 /// <returns></returns>
 public static long DijkstraMinPathWeight(this long[,] grid, Coordinate start, Coordinate goal) =>
 grid.DijkstraMinPathWeights(start, goal, Neighbors8)[goal.Row, goal.Col];