Function pathfinding::directed::astar::astar_bag
source · pub fn astar_bag<N, C, FN, IN, FH, FS>(
start: &N,
successors: FN,
heuristic: FH,
success: FS
) -> Option<(AstarSolution<N>, C)>Expand description
Compute all shortest paths using the A* search
algorithm. Whereas astar
(non-deterministic-ally) returns a single shortest path, astar_bag returns all shortest paths
(in a non-deterministic order).
The shortest paths starting from start up to a node for which success returns true are
computed and returned in an iterator along with the cost (which, by definition, is the same for
each shortest path), wrapped in a Some. If no paths are found, None is returned.
startis the starting node.successorsreturns a list of successors for a given node, along with the cost for moving from the node to the successor.heuristicreturns an approximation of the cost from a given node to the goal. The approximation must not be greater than the real cost, or a wrong shortest path may be returned.successchecks whether the goal has been reached. It is not a node as some problems require a dynamic solution instead of a fixed node.
A node will never be included twice in the path as determined by the Eq relationship.
Each path comprises both the start and an end node. Note that while every path shares the same start node, different paths may have different end nodes.