rustworkx.digraph_astar_shortest_path#
- digraph_astar_shortest_path(graph, node, goal_fn, edge_cost_fn, estimate_cost_fn, /)#
Compute the A* shortest path for a PyDiGraph
- Parameters:
graph (PyDiGraph) – The input graph to use
node (int) – The node index to compute the path from
goal_fn – A python callable that will take in 1 parameter, a node’s data object and will return a boolean which will be True if it is the finish node.
edge_cost_fn – A python callable that will take in 1 parameter, an edge’s data object and will return a float that represents the cost of that edge. It must be non-negative.
estimate_cost_fn – A python callable that will take in 1 parameter, a node’s data object and will return a float which represents the estimated cost for the next node. The return must be non-negative. For the algorithm to find the actual shortest path, it should be admissible, meaning that it should never overestimate the actual cost to get to the nearest goal node.
- Returns:
The computed shortest path between node and finish as a list of node indices.
- Return type:
- Raises:
ValueError – when an edge weight with NaN or negative value is provided.