pub fn shortest_path_generic_graph<T: AStarNode, P, N, G, F, O>(
start: &[T],
goal_fn: &P,
neighbors_fn: &N,
max_ops: u32,
max_cost: O,
initial_cost: O,
initial_estimate: O,
) -> AStarSearchResults<T, O>
Expand description
Highly-generic implementation of A* search algorithm on a graph.
Allows multiple starting nodes, a generic goal function, generic cost and heuristic functions, control over the maximum operations performed while searching, and the maximum travel cost the final path can have.
Parameters:
start
: A slice of the starting nodes for the searchgoal_fn
: A predicate function that takes a node and returns true if the node is a goal nodeneighbors_fn
: A function that takes in the current node and its g score and returns its neighbors, as well as their f and g scoresmax_ops
: The maximum number of expand operations to perform before stopping searchmax_cost
: The maximum cost to allow for the final path before stopping searchinitial_cost
: The initial cost to start the search with; this is the g_scoreinitial_estimate
: The initial estimate to start the search with; this is the f_score
Note: This function assumes that the heuristic function is consistent, and optimizes accordingly. If your heuristic function is admissible but not consistent, then you risk getting suboptimal paths, just like if your heuristic function is not admissible.