dfs_tree

dfs_tree(G, source=None)[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 – An oriented tree

Return type:

NetworkX DiGraph

Examples

>>> G = nx.path_graph(3)
>>> T = nx.dfs_tree(G,0)
>>> print(list(T.edges()))
[(0, 1), (1, 2)]