descendants#
- descendants(G, source)[source]#
Returns all nodes reachable from
sourceinG.- Parameters:
- GNetworkX Graph
- sourcenode in
G
- Returns:
- set()
The descendants of
sourceinG
- Raises:
- NetworkXError
If node
sourceis not inG.
See also
Examples
>>> DG = nx.path_graph(5, create_using=nx.DiGraph) >>> sorted(nx.descendants(DG, 2)) [3, 4]
The
sourcenode is not a descendant of itself, but can be included manually:>>> sorted(nx.descendants(DG, 2) | {2}) [2, 3, 4]