find_path

Function find_path 

Source
pub fn find_path<H>(
    graph: &Graph,
    start: usize,
    goal: usize,
    heuristic: H,
) -> Option<(f64, Vec<usize>)>
where H: Fn(usize) -> f64,
Expand description

Finds shortest path from start to goal using A* algorithm

§Arguments

  • graph - The input graph
  • start - Starting node
  • goal - Goal node
  • heuristic - Admissible heuristic function h(n) estimating cost from n to goal

§Returns

Option containing (cost, path) if a path exists

§Requirements

The heuristic must be admissible (never overestimate) and consistent for optimality