C++ Boost

(Python) breadth_first_visit

  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.

Where Defined

boost/graph/breadth_first_search.hpp

Parameters

IN: IncidenceGraph& g
A directed or undirected graph. The graph type must be a model of Incidence Graph.
Python: The parameter is named graph.
IN: vertex_descriptor s
The source vertex where the search is started.
Python: The parameter is named root_vertex.

Named Parameters

IN: visitor(BFSVisitor vis)
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 [1].
Default: bfs_visitor<null_visitor>
Python: The parameter should be an object that derives from the BFSVisitor type of the graph.
UTIL/OUT: color_map(ColorMap color)
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.
Default: get(vertex_color, g)
Python: The color map must be a vertex_color_map for the graph.
UTIL: buffer(Buffer& Q)
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.
Default: boost::queue
Python: The buffer must derive from the Buffer type for the graph.

Complexity

The time complexity is O(E).

Visitor Event Points

See Also

breadth_first_search(), bfs_visitor, and depth_first_search()

Notes

[1] 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 (jsiek@osl.iu.edu)