Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
dfs_tree¶
- dfs_tree(G, source)[source]¶
Return oriented tree constructed from a depth-first-search from source.
Parameters : G : NetworkX graph
source : node, optional
Specify starting node for depth-first search.
Returns : T : NetworkX DiGraph
An oriented tree
Examples
>>> G = nx.Graph() >>> G.add_path([0,1,2]) >>> T = nx.dfs_tree(G,0) >>> print(T.edges()) [(0, 1), (1, 2)]