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

C++ Boost

edge_predecessor_recorder<PredEdgeMap, EventTag>

This is an EventVisitor that records the predecessor (or parent) edge of a vertex in a property map. This is particularly useful in graph search algorithms where recording the predecessors is an efficient way to encode the search tree that was traversed during the search. The edge predecessor recorder is typically used with the on_tree_edge or on_relax_edge events and cannot be used with vertex events. This visitor is meant to be used instead of predecessor_recorder when a graph has parallel edges and it is necessary to know which incoming edge a search algorithm used to get to a particular vertex.

edge_predecessor_recorder can be used with graph algorithms by wrapping it with an 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.

Algorithms such as Dijkstra's and breadth-first search will not assign a predecessor edge to the source vertex (which is the root of the search tree). It is often useful to initialize the source vertex's predecessor to a special value, thereby identifying the root vertex. When using an algorithm like depth-first search that creates a forest (multiple search trees) it is useful to do the same for every vertex. This way all the root nodes can be distinguished.

Model of


Where Defined


Template Parameters

PredEdgeMap A WritablePropertyMap where the key and value types are the vertex and edge descriptor types, respectively, of the graph.  
EventTag The tag to specify when the edge_predecessor_recorder should be applied during the graph algorithm. EventTag must be an edge event.  

Associated Types

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

Member Functions

edge_predecessor_recorder(PredEdgeMap pa); Construct an edge predecessor recorder object with predecessor property map pa.
template <class Edge, class Graph>
void operator()(Edge e, const Graph& g);
Given edge e = (u,v), this records e as the predecessor (or parent) edge of v.

Non-Member Functions

template <class PredEdgeMap, class Tag>
edge_predecessor_recorder<PredEdgeMap, Tag>
record_edge_predecessors(PredEdgeMap pa, Tag);
A convenient way to create a edge_predecessor_recorder.

See Also

Visitor concepts

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

Copyright © 2000-2001 Jeremy Siek, Indiana University (
Lie-Quan Lee, Indiana University (
Andrew Lumsdaine, Indiana University (