3 Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
10 <Title>Boost Graph Library: predecessor_recorder
</Title>
11 <BODY BGCOLOR=
"#ffffff" LINK=
"#0000ee" TEXT=
"#000000" VLINK=
"#551a8b"
13 <IMG SRC=
"../../../boost.png"
14 ALT=
"C++ Boost" width=
"277" height=
"86">
20 predecessor_recorder
<PredecessorMap, EventTag
>
24 This is an
<a href=
"./EventVisitor.html">EventVisitor
</a> that records
25 the predecessor (or parent) of a vertex in a predecessor property
26 map. This is particularly useful in graph search algorithms where
27 recording the predecessors is an efficient way to encode the search
28 tree that was traversed during the search. The predecessor recorder is
29 typically used with the
<tt>on_tree_edge
</tt> or
30 <tt>on_relax_edge
</tt> events and cannot be used with vertex events.
33 <tt>predecessor_recorder
</tt> can be used with graph algorithms by
34 wrapping it with an algorithm-specific adaptor, such as
<a
35 href=
"./bfs_visitor.html"><tt>bfs_visitor
</tt></a> and
<a
36 href=
"./dfs_visitor.html"><tt>dfs_visitor
</tt></a>. Also, this event
37 visitor can be combined with other event visitors using
38 <tt>std::pair
</tt> to form an EventVisitorList.
41 Algorithms such as Dijkstra's and breadth-first search will not assign
42 a predecessor to the source vertex (which is the root of the search
43 tree). It is often useful to initialize the source vertex's
44 predecessor to itself, thereby identifying the root vertex as the only
45 vertex which is its own parent. When using an algorithm like
46 depth-first search that creates a forest (multiple search trees) it
47 is useful to initialize the predecessor of every vertex to itself. This
48 way all the root nodes can be distinguished.
53 See the example for
<a href=
"./bfs_visitor.html"><tt>bfs_visitor
</tt></a>.
57 <a href=
"./EventVisitor.html">EventVisitor
</a>
60 <H3>Where Defined
</H3>
63 <a href=
"../../../boost/graph/visitors.hpp">
64 <TT>boost/graph/visitors.hpp
</TT></a>
66 <H3>Template Parameters
</H3>
71 <th>Parameter
</th><th>Description
</th><th>Default
</th>
74 <TR><TD><TT>PredecessorMap
</TT></TD>
77 href=
"../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap
</a>
78 where the key type and the value type are the vertex descriptor type
84 <TR><TD><TT>EventTag
</TT></TD>
86 The tag to specify when the
<tt>predecessor_recorder
</tt> should be
87 applied during the graph algorithm.
<tt>EventTag
</tt> must be an
95 <H2>Associated Types
</H2>
100 <th>Type
</th><th>Description
</th>
104 <td><tt>predecessor_recorder::event_filter
</tt></td>
106 This will be the same type as the template parameter
<tt>EventTag
</tt>.
112 <h3>Member Functions
</h3>
118 <th>Member
</th><th>Description
</th>
123 predecessor_recorder(PredecessorMap pa);
126 Construct a predecessor recorder object with predecessor property map
133 template
<class Edge, class Graph
><br>
134 void operator()(Edge e, const Graph& g);
137 Given edge
<i>e = (u,v)
</i>, this records
<i>u
</i> as the
138 predecessor (or parent) of
<i>v
</i>.
144 <h3>Non-Member Functions
</h3>
148 <th>Function
</th><th>Description
</th>
152 template
<class PredecessorMap, class Tag
><br>
153 predecessor_recorder
<PredecessorMap, Tag
> <br>
154 record_predecessors(PredecessorMap pa, Tag);
156 A convenient way to create a
<tt>predecessor_recorder
</tt>.
163 <a href=
"./visitor_concepts.html">Visitor concepts
</a>
165 The following are other event visitors:
<a
166 <a href=
"./distance_recorder.html"><tt>distance_recorder
</tt></a>,
167 <a href=
"./time_stamper.html"><tt>time_stamper
</tt></a>,
168 and
<a href=
"./property_writer.html"><tt>property_writer
</tt></a>.
175 <TD nowrap
>Copyright
© 2000-
2001</TD><TD>
176 <A HREF=
"http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek
</A>,
177 Indiana University (
<A
178 HREF=
"mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu
</A>)
<br>
179 <A HREF=
"http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee
</A>, Indiana University (
<A HREF=
"mailto:llee@cs.indiana.edu">llee@cs.indiana.edu
</A>)
<br>
180 <A HREF=
"http://www.osl.iu.edu/~lums">Andrew Lumsdaine
</A>,
181 Indiana University (
<A
182 HREF=
"mailto:lums@osl.iu.edu">lums@osl.iu.edu
</A>)
187 <!-- LocalWords: PredecessorMap EventTag EventVisitor map bfs dfs const
189 <!-- LocalWords: EventVisitorList WritablePropertyMap Siek Univ Quan
191 <!-- LocalWords: Lumsdaine