descendants¶
- descendants(G, source)[source]¶
Returns all nodes reachable from
source
inG
.- Parameters
- GNetworkX Graph
- sourcenode in
G
- Returns
- set()
The descendants of
source
inG
- Raises
- NetworkXError
If node
source
is not inG
.
See also
Examples
>>> DG = nx.path_graph(5, create_using=nx.DiGraph) >>> sorted(list(nx.descendants(DG, 2))) [3, 4]