def dfs_preorder_nodes(G, source=None):
 pre = (v for (u, v, d) in nx.dfs_labeled_edges(G, source=source) if (d == 'forward'))
 return pre

def dfs_preorder_nodes ( G , source = None ) : pre = ( v for ( u , v , d ) in nx . dfs_labeled_edges ( G , source = source ) if ( d == 'forward' ) ) return pre
produce nodes in a depth-first-search pre-ordering starting from source .