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