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

PyDAG.successors(node, /)#

Return a list of data of all node successors in a directed graph

A successor is defined as a node that has a directed edge pointing from the specified node. In a multigraph, where two nodes can be connected by multiple edges, each successor node is returned only once.

>>> G = rx.PyDiGraph()
>>> G.add_nodes_from(["A", "B", "C", "D", "E"])
NodeIndices[0, 1, 2, 3, 4]
>>> G.extend_from_edge_list([(0, 1), (1, 2), (1, 3), (1, 4)])
>>> G.successors(1)  # successors of the 'B' node
['E', 'D', 'C']
>>> G.successors(10) # successors of an non-existing node
[]

See also

To filter the successors by the attributes of the connecting edge, see find_successors_by_edge().

See also predecessors() and neighbors().

For undirected graphs, see neighbors().

To go beyond the nearest successors, see descendants().

Parameters:

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

Returns:

A list of the node data of all node’s predecessors

Return type:

list[S]