Popular recipes tagged "bfs"http://code.activestate.com/recipes/tags/bfs/2011-09-28T12:06:25-07:00ActiveState Code RecipesPrinting breadth First Levels of a graph (Or) Tree (Python)
2011-09-28T12:06:25-07:00Venkateshhttp://code.activestate.com/recipes/users/4179376/http://code.activestate.com/recipes/577876-printing-breadth-first-levels-of-a-graph-or-tree/
<p style="color: grey">
Python
recipe 577876
by <a href="/recipes/users/4179376/">Venkatesh</a>
(<a href="/recipes/tags/bfs/">bfs</a>, <a href="/recipes/tags/level/">level</a>, <a href="/recipes/tags/tree/">tree</a>).
Revision 4.
</p>
<p>Prints the breadth first Levels of a graph (Or) Tree, by performing Breadth First Search</p>
BFS (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>