def _dfs(graph, visited, node, pre, post):
visited[node] = <NUM_LIT:1><EOL>if (pre): yield node<EOL>for each in graph[node]:<EOL><INDENT>if (each not in visited):<EOL><INDENT>for other in _dfs(graph, visited, each, pre, post):<EOL><INDENT>yield other<EOL><DEDENT><DEDENT><DEDENT>if (post): yield node<EOL>
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.