C++ Boost

Foundation Visitor Classes

Foundation visitor is just the name we use for visitor classes that are used inside the implementation of BGL algorithms. Typically you will never need to see or use these classes, however perhaps they will be of interest as examples or can reused in some unforeseen circumstances.

User-Level Visitor Classes

There are a handful of visitors defined by BGL, but the visitor mechanism is mainly intended as a way for users to extend BGL with their own custom visitors. Use the BGL visitors as examples for how to implement you own. The visitors in this section are models of UserVisitor.


null_visitor

This is a visitor that does nothing. It is useful as a base class for user-defined visitors that only implement some of the visitor methods. The unimplemented methods will default to the empty ones in the base_visitor class. Due to deficiencies in VC++ this class can not be used with that compiler. Use base_visitor instead if you need VC++ portability.

Members

null_visitor::category
The category for this visitor is every_edge_tag.

template <class Vertex>
void null_visitor::initialize(Vertex u) { }

template <class Vertex>
void null_visitor::start(Vertex s) { }

template <class Vertex>
void null_visitor::discover(Vertex s) { }

template <class Vertex>
void null_visitor::finish(Vertex s) { }

template <class Edge, class Graph>
void null_visitor::process(Edge e, Graph& g) { }


base_visitor

base_visitor<Visitor>

This is a visitor that does nothing. It is useful as a base class for user-defined visitors that only implement some of the visitor methods. The unimplemented methods will default to the empty ones in the base_visitor class. The template argument Visitor must be the deriving visitor class. This class is a workaround for VC++. If VC++ portability is not an issue use null_visitor instead.

Members

base_visitor::category
The category for this visitor is every_edge_tag.

template <class Vertex>
void base_visitor::initialize(Vertex u) { }

template <class Vertex>
void base_visitor::start(Vertex s) { }

template <class Vertex>
void base_visitor::discover(Vertex s) { }

template <class Vertex>
void base_visitor::finish(Vertex s) { }

template <class Edge, class Graph>
void base_visitor::process(Edge e, Graph& g) { }


distance_visitor

distance_visitor<Distance>

The distance visitor records the distance from the starting vertex to each vertex in a search tree. The type of search tree depends on the algorithm being applied.

Example

Template Parameters

Distance Must be a model of ReadWritePropertyAccessor.

Model of

Visitor

Members

distance_visitor::category
The visitor category for this class is tree_edge_tag.

distance_visitor::distance_visitor(Distance p)
Constructor.

template <class Vertex>
distance_visitor::initialize(Vertex u)
This initializes the distance property for all the vertices to std::numeric_limits<T>::max() where T is the value type of the distance property accessor.

template <class Vertex>
distance_visitor::start(Vertex u)
This initializes the distance of the starting vertex to zero.

template <class Edge, class Graph>
distance_visitor::process(Edge e, Graph& g)
This records the distance of for the target(e,g) as d[source(e,g)] + 1.


predecessor_visitor

predecessor_visitor<Predecessor>

The predecessor visitor records the predecessors (or parents) of the nodes in a search tree, where the search tree depends on the kind of graph search algorithm being applied.

Example

Template Parameters

Predecessor Must be a model of WritablePropertyAccessor.

Model of

Visitor

Members

predecessor_visitor::category
The visitor category for this class is tree_edge_tag.

predecessor_visitor::predecessor_visitor(Predecessor p)
Constructor.

template <class Edge, class Graph>
predecessor_visitor::process(Edge e, Graph& g)
This method records the predecessor (or parent), where target(e) is the parent and source(e) is the child. The implementation is simply p[target(e,g)] = source(e,g).


timestamp_visitor

timestamp_visitor<DiscoverTime,FinishTime>

The time-stamp visitor is for recording the ``discover'' and ``finish'' order for vertices during a graph search. The time-stamp starts at zero and increments one each time a vertex is discovered or finished.

Example

Template Parameters

DiscoverTime Must be a model of WritablePropertyAccessor.
FinishTime Must be a model of WritablePropertyAccessor.

Model of

Visitor

Members

timestamp_visitor::category
The visitor category for this class is tree_edge_tag.

timestamp_visitor::timestamp_visitor(DiscoverTime d, FinishTime f)
Constructor.

template <class Vertex>
timestamp_visitor::discover(Vertex u)
This method records the discover time for vertex u. The implementation is simply d[u] = ++time.

template <class Vertex>
timestamp_visitor::finish(Vertex u)
This method records the finish time for vertex u. The implementation is simply f[u] = ++time.



Copyright © 2000 Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu)
Lie-Quan Lee, Univ.of Notre Dame (llee1@lsc.nd.edu)
Andrew Lumsdaine, Univ.of Notre Dame (lums@lsc.nd.edu)