Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.graph_astar_shortest_path#
- graph_astar_shortest_path(graph, node, goal_fn, edge_cost_fn, estimate_cost_fn, /)#
Compute the A* shortest path for a PyGraph
- Parameters:
graph (PyGraph) – 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.