graph/example/python/breadth_first_search.py
Douglas Gregor 631d35bcc2 Started documenting Python bindings
libs/graph/src/python/basic_graph.cpp, libs/graph/src/python/basic_graph.hpp:
  - Allow one to build a graph from anything that looks like a Python list or
    tuple.


[SVN r28324]
2005-04-19 17:01:07 +00:00

15 lines
407 B
Python

from bgl import *
class bfs_print_discover_visitor(Graph.BFSVisitor):
def discover_vertex(self, u, g):
print "Discovered vertex ",
print u
g = Graph((("r", "s"), ("r", "v"), ("s", "w"), ("w", "r"), ("w", "t"), ("w", "x"), ("x", "t"), ("t", "u"), ("x", "y"), ("u", "y")))
iter = g.vertices.__iter__()
iter.next()
s = iter.next()
breadth_first_search(g, s, visitor=bfs_print_discover_visitor())