code: def dfs_tree(G, source=None, depth_limit=None):
      """Returns oriented tree constructed from a depth-first-search from source.
  
      Parameters
      ----------
      G : NetworkX graph
  
      source : node, optional
         Specify starting node for depth-first search.
  
      depth_limit : int, optional (default=len(G))
         Specify the maximum search depth.
  
      Returns
      -------
      T : NetworkX DiGraph
         An oriented tree
  
      Examples
      --------
      >>> G = nx.path_graph(5)
      >>> T = nx.dfs_tree(G, source=0, depth_limit=2)
      >>> list(T.edges())
      [(0, 1), (1, 2)]
      >>> T = nx.dfs_tree(G, source=0)
      >>> list(T.edges())
      [(0, 1), (1, 2), (2, 3), (3, 4)]
  
      See Also
      --------
      dfs_preorder_nodes
      dfs_postorder_nodes
      dfs_labeled_edges
      edge_dfs
      bfs_tree
      """
      T = nx.DiGraph()
      if source is None:
          T.add_nodes_from(G)
      else:
          T.add_node(source)
      T.add_edges_from(dfs_edges(G, source, depth_limit))
      return T
  
file_path: networkx/networkx/algorithms/traversal/depth_first_search.py
imports: from collections import defaultdict
  import networkx
label_desc: Use image node_id 2 for calling a global function with example usage: dfs_tree(G, source, depth_limit) and returns: T