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.successor_indices#
- PyDAG.successor_indices(node, /)#
Return a list of successor node indices 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 index 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.successor_indices(1) # successors of the 'B' node NodeIndices[4, 3, 2]
To get the data of these nodes, see
successors()
.`To filter the successors by the attributes of the connecting edge, see
find_successors_by_edge()
.See also
predecessor_indices()
andneighbors()
.For undirected graphs, see
neighbors()
.- Parameters:
node (int) – The index of the node to get the successors for
- Returns:
A list of the node indices of all node’s successors
- Return type: