Skip to main content

astar

Function astar 

Source
pub fn astar<N, FH, FN, I>(
    start: N,
    goal: N,
    heuristic: FH,
    neighbors: FN,
) -> Option<AStarResult<N>>
where N: Clone + Eq + Hash, FH: FnMut(&N, &N) -> f64, FN: FnMut(&N) -> I, I: IntoIterator<Item = (N, f64)>,
Expand description

Generic A* pathfinding.

  • start: starting node
  • goal: target node
  • heuristic: estimates cost from a node to the goal (must be admissible)
  • neighbors: returns neighbors and the edge cost to reach each

Returns Some(AStarResult) with the shortest path and total cost, or None if no path exists.