Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
C++ Boost

property_writer<PropertyMap, OutputIterator, EventTag>

This is an EventVisitor that can be used to output the property of a vertex or edge at some event-point within an algorithm.

property_writer can be used with graph algorithms by wrapping it with the algorithm-specific adaptor, such as bfs_visitor and dfs_visitor. Also, this event visitor can be combined with other event visitors using std::pair to form an EventVisitorList.

Example

The following is an excerpt from examples/dave.cpp.
  std::ostream_iterator cout_int(std::cout, " ");
  std::ostream_iterator cout_char(std::cout, " ");

  boost::breadth_first_search
    (G, vertex(a, G), make_bfs_visitor(
     std::make_pair(write_property(name, cout_char, on_discover_vertex()),
     std::make_pair(write_property(distance.begin(), cout_int,
                                   on_discover_vertex()),
     std::make_pair(print_edge(name, std::cout, on_examine_edge()),
                    print_endl(std::cout, on_finish_vertex()
                    ))))));

Model of

EventVisitor

Where Defined

boost/graph/visitors.hpp

Template Parameters

ParameterDescriptionDefault
PropertyMap A ReadablePropertyMap where the key_type is the vertex descriptor type or edge descriptor of the graph (depending on the kind of event tag) and the value_type of the property is convertible to the value_type of the OutputIterator.  
OutputIterator The iterator type used to write out the property values, which must be a model of OutputIterator.  
EventTag The tag to specify when the property_writer should be applied during the graph algorithm.  

Associated Types

TypeDescription
property_writer::event_filter This will be the same type as the template parameter EventTag.

Member Functions

MemberDescription
property_writer(PropertyMap pa, OutputIterator out); Construct a property writer object with the property map pa and output iterator out.
template <class X, class Graph>
void operator()(X x, const Graph& g);
This writes the property value for x to the output iterator.
*out++ = get(pa, x);

Non-Member Functions

FunctionDescription
template <class PropertyMap, class OutputIterator, class Tag>
property_writer<PropertyMap, OutputIterator, Tag>
write_property(PropertyMap pa, OutputIterator out, Tag);
A convenient way to create a property_writer.

See Also

Visitor concepts

The following are other event visitors: distance_recorder, predecessor_recorder, and time_stamper.


Copyright © 2000-2001 Jeremy Siek, Indiana University (jsiek@osl.iu.edu)
Lie-Quan Lee, Indiana University (llee@cs.indiana.edu)
Andrew Lumsdaine, Indiana University (lums@osl.iu.edu)