Warning

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

networkx.algorithms.shortest_paths.unweighted.bidirectional_shortest_path

bidirectional_shortest_path(G, source, target)[source]

Returns a list of nodes in a shortest path between source and target.

Parameters:
  • G (NetworkX graph)
  • source (node label) – starting node for path
  • target (node label) – ending node for path
Returns:

path – List of nodes in a path from source to target.

Return type:

list

Raises:

NetworkXNoPath – If no path exists between source and target.

See also

shortest_path()

Notes

This algorithm is used by shortest_path(G, source, target).