networkx.dfs_tree¶
-
networkx.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.path_graph(3) >>> T = nx.dfs_tree(G,0) >>> print(list(T.edges())) [(0, 1), (1, 2)]