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.has_path#

has_path(graph, source, target, as_undirected=False)[source]#

Checks if a path exists between a source and target node

Parameters:
  • graph – The input graph to use. Can either be a PyGraph or PyDiGraph

  • source (int) – The node index to find paths from

  • target (int) – The index of the target node

  • as_undirected (bool) – If set to true the graph will be treated as undirected for finding existence of a path. This only works with a PyDiGraph input for graph

Returns:

True if a path exists, False if not

Return type:

bool