Popular recipes by mojave kid http://code.activestate.com/recipes/users/4169379/2009-03-02T20:20:56-08:00ActiveState Code RecipesBFS (breadth first search) graph traversal (Python)
2009-03-02T20:20:56-08:00mojave kidhttp://code.activestate.com/recipes/users/4169379/http://code.activestate.com/recipes/576675-bfs-breadth-first-search-graph-traversal/
<p style="color: grey">
Python
recipe 576675
by <a href="/recipes/users/4169379/">mojave kid</a>
(<a href="/recipes/tags/bfs/">bfs</a>, <a href="/recipes/tags/breath/">breath</a>).
Revision 4.
</p>
<p>Guido illustrated the DFS recursive traversal of a graph (<a href="http://www.python.org/doc/essays/graphs.html" rel="nofollow">http://www.python.org/doc/essays/graphs.html</a>)
However if the graph is too big, recursion error occurs.</p>
<p>Here im pitching in my recipe for an iterative BFS traversal.</p>
<p>Im using Guido's graph representation using dictionary.</p>