code: def dfs_preorder_nodes(G, source=None, depth_limit=None):
      """Generate nodes in a depth-first-search pre-ordering starting at source.
  
      Parameters
      ----------
      G : NetworkX graph
  
      source : node, optional
         Specify starting node for depth-first search and return nodes in
         the component reachable from source.
  
      depth_limit : int, optional (default=len(G))
         Specify the maximum search depth.
  
      Returns
      -------
      nodes: generator
         A generator of nodes in a depth-first-search pre-ordering.
  
      Examples
      --------
      >>> G = nx.path_graph(5)
      >>> list(nx.dfs_preorder_nodes(G, source=0))
      [0, 1, 2, 3, 4]
      >>> list(nx.dfs_preorder_nodes(G, source=0, depth_limit=2))
      [0, 1, 2]
  
      Notes
      -----
      If a source is not specified then a source is chosen arbitrarily and
      repeatedly until all components in the graph are searched.
  
      The implementation of this function is adapted from David Eppstein's
      depth-first search function in `PADS`_, with modifications
      to allow depth limits based on the Wikipedia article
      "`Depth-limited search`_".
  
      .. _PADS: http://www.ics.uci.edu/~eppstein/PADS
      .. _Depth-limited search: https://en.wikipedia.org/wiki/Depth-limited_search
  
      See Also
      --------
      dfs_edges
      dfs_postorder_nodes
      dfs_labeled_edges
      bfs_edges
      """
      edges = nx.dfs_labeled_edges(
          G, source=source, depth_limit=depth_limit
      )
      return (v for u, v, d in edges if d == "forward")
  
file_path: networkx/networkx/algorithms/traversal/depth_first_search.py
imports: from collections import defaultdict
  import networkx
label_desc: Use image node_id 6 for calling a global function with example usage: dfs_preorder_nodes(G, source, depth_limit) and returns: unknown