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.PyDAG.find_successors_by_edge#

PyDAG.find_successors_by_edge(node, filter_fn, /)#

Return a list of data associated with the successors of the given node, where the edges connecting to those nodes satisfy the provided filter function.

A predecessor is defined as a node that has a directed edge pointing to the specified node. This method returns all nodes where the edges match the condition.

>>> G = rx.PyDiGraph()
>>> G.add_nodes_from(["A", "B", "C", "D", "E"])
NodeIndices[0, 1, 2, 3, 4]
>>> G.extend_from_weighted_edge_list([(0, 1, 10), (1, 2, 10), (1, 3, 20), (1, 4, 30)])
>>> G.find_successors_by_edge(1, lambda x: x < 25)
['D', 'C']

To get one node only, see find_successor_node_by_edge().

See also find_predecessors_by_edge().

Parameters:
  • node (int) – The index of the node to get the successors for

  • filter_fn – The filter function to apply on edges. It takes in one argument, the edge data payload/weight object, and returns a boolean whether the edge matches the conditions or not. If any edge returns True, the node will be included.

Returns:

A list of the node data for all the successor nodes where at least one edge leading to it matches the filter

Return type:

list[S]