Popular recipes by Paul W. Miller http://code.activestate.com/recipes/users/4172186/2009-11-09T04:46:21-08:00ActiveState Code RecipesDepth first search generator (Python) 2009-11-09T04:46:21-08:00Paul W. Millerhttp://code.activestate.com/recipes/users/4172186/http://code.activestate.com/recipes/576946-depth-first-search-generator/ <p style="color: grey"> Python recipe 576946 by <a href="/recipes/users/4172186/">Paul W. Miller</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/graphs/">graphs</a>). Revision 7. </p> <p>This is the standard iterative DFS code modified to yield the vertices visited, so you don't have to pass a function into the DFS routine to process them. Note that this code is not quite complete... you'll need to define the function neighbors (v) based on your graph representation.</p>