...one of the most highly
regarded and expertly designed C++ library projects in the
world. — Herb Sutter and Andrei
template <class IncidenceGraph, class P, class T, class R> void breadth_first_visit(IncidenceGraph& G, typename graph_traits<IncidenceGraph>::vertex_descriptor s, const bgl_named_params<P, T, R>& params); template <class IncidenceGraph, class Buffer, class BFSVisitor, class ColorMap> void breadth_first_visit (const IncidenceGraph& g, typename graph_traits<IncidenceGraph>::vertex_descriptor s, Buffer& Q, BFSVisitor vis, ColorMap color)This function is basically the same as breadth_first_search() except that the color markers are not initialized in the algorithm. The user is responsible for making sure the color for every vertex is white before calling the algorithm. With this difference, the graph type is only required to be an Incidence Graph instead of a Vertex List Graph. Also, this difference allows for more flexibility in the color property map. For example, one could use a map that only implements a partial function on the vertices, which could be more space efficient when the search only reaches a small portion of the graph.
A directed or undirected graph. The graph type must be a model of Incidence Graph.IN: vertex_descriptor s
Python: The parameter is named graph.
The source vertex where the search is started.
Python: The parameter is named root_vertex.
A visitor object that is invoked inside the algorithm at the event-points specified by the BFS Visitor concept. The visitor object is passed by value .UTIL/OUT: color_map(ColorMap color)
Python: The parameter should be an object that derives from the BFSVisitor type of the graph.
This is used by the algorithm to keep track of its progress through the graph. The type ColorMap must be a model of Read/Write Property Map and its key type must be the graph's vertex descriptor type and the value type of the color map must model ColorValue.UTIL: buffer(Buffer& Q)
Default: get(vertex_color, g)
Python: The color map must be a vertex_color_map for the graph.
The queue used to determine the order in which vertices will be discovered. If a FIFO queue is used, then the traversal will be according to the usual BFS ordering. Other types of queues can be used, but the traversal order will be different. For example Dijkstra's algorithm can be implemented using a priority queue. The type Buffer must be a model of Buffer.
Python: The buffer must derive from the Buffer type for the graph.
The time complexity is O(E).
Since the visitor parameter is passed by value, if your visitor
contains state then any changes to the state during the algorithm
will be made to a copy of the visitor object, not the visitor object
passed in. Therefore you may want the visitor to hold this state by
pointer or reference.
|Copyright © 2000-2001||Jeremy Siek, Indiana University (email@example.com)|