mirror of
https://github.com/boostorg/graph.git
synced 2025-05-10 07:23:58 +00:00
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]
15 lines
407 B
Python
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())
|
|
|