Function pathfinding::directed::astar::astar_bag [−][src]
pub fn astar_bag<N, C, FN, IN, FH, FS>(
start: &N,
successors: FN,
heuristic: FH,
success: FS
) -> Option<(AstarSolution<N>, C)> where
N: Eq + Hash + Clone,
C: Zero + Ord + Copy,
FN: FnMut(&N) -> IN,
IN: IntoIterator<Item = (N, C)>,
FH: FnMut(&N) -> C,
FS: FnMut(&N) -> bool,
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.
start
is the starting node.successors
returns a list of successors for a given node, along with the cost for moving from the node to the successor.heuristic
returns 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.success
checks 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.