code: def _dfs(graph, visited, node, pre, post):
      
      visited[node] = 1
      if (pre): yield node
      # Explore recursively the connected component
      for each in graph[node]:
          if (each not in visited):
              for other in _dfs(graph, visited, each, pre, post):
                  yield other
      if (post): yield node
docs: Depth-first search subfunction for traversals.
      
      @type  graph: graph, digraph
      @param graph: Graph.
  
      @type  visited: dictionary
      @param visited: List of nodes (visited nodes are marked non-zero).
  
      @type  node: node
      @param node: Node to be explored by DFS.