Skip to main content

astar

Function astar 

Source
pub fn astar<H>(
    store: &LpgStore,
    source: NodeId,
    target: NodeId,
    weight_property: Option<&str>,
    heuristic: H,
) -> Option<(f64, Vec<NodeId>)>
where H: Fn(NodeId) -> f64,
Expand description

Runs A* algorithm with a heuristic function.

§Arguments

  • store - The graph store
  • source - Starting node ID
  • target - Target node ID
  • weight_property - Optional property name for edge weights
  • heuristic - Function estimating cost from node to target (must be admissible)

§Returns

The shortest path distance and path, or None if unreachable.

§Complexity

O(E) in the best case with a good heuristic, O((V + E) log V) in the worst case.