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

bfs_predecessors(graph, node, /)#

Return predecessors in a breadth-first-search from a source node.

The return format is [(Parent Node, [Children Nodes])] in a bfs order from the source node provided.

Parameters:
  • graph (PyDiGraph) – The DAG to get the bfs_predecessors from

  • node (int) – The index of the dag node to get the bfs predecessors for

Returns:

A list of nodes’s data and their children in bfs order. The BFSPredecessors class that is returned is a custom container class that implements the sequence protocol. This can be used as a python list with index based access.

Return type:

BFSPredecessors