Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.algorithms.shortest_paths.astar.astar_path_length

astar_path_length(G, source, target, heuristic=None, weight='weight')[source]

Returns the length of the shortest path between source and target using the A* (“A-star”) algorithm.

Parameters
  • G (NetworkX graph)

  • source (node) – Starting node for path

  • target (node) – Ending node for path

  • heuristic (function) – A function to evaluate the estimate of the distance from the a node to the target. The function takes two nodes arguments and must return a number.

Raises

NetworkXNoPath – If no path exists between source and target.

See also

astar_path()