predecessor_recorder.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Boost Graph Library: predecessor_recorder</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H1>
  16. <pre>
  17. predecessor_recorder&lt;PredecessorMap, EventTag&gt;
  18. </pre>
  19. </H1>
  20. This is an <a href="./EventVisitor.html">EventVisitor</a> that records
  21. the predecessor (or parent) of a vertex in a predecessor property
  22. map. This is particularly useful in graph search algorithms where
  23. recording the predecessors is an efficient way to encode the search
  24. tree that was traversed during the search. The predecessor recorder is
  25. typically used with the <tt>on_tree_edge</tt> or
  26. <tt>on_relax_edge</tt> events and cannot be used with vertex events.
  27. <p>
  28. <tt>predecessor_recorder</tt> can be used with graph algorithms by
  29. wrapping it with an algorithm-specific adaptor, such as <a
  30. href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and <a
  31. href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>. Also, this event
  32. visitor can be combined with other event visitors using
  33. <tt>std::pair</tt> to form an EventVisitorList.
  34. <p>
  35. Algorithms such as Dijkstra's and breadth-first search will not assign
  36. a predecessor to the source vertex (which is the root of the search
  37. tree). It is often useful to initialize the source vertex's
  38. predecessor to itself, thereby identifying the root vertex as the only
  39. vertex which is its own parent. When using an algorithm like
  40. depth-first search that creates a forest (multiple search trees) it
  41. is useful to initialize the predecessor of every vertex to itself. This
  42. way all the root nodes can be distinguished.
  43. <h3>Example</h3>
  44. See the example for <a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>.
  45. <h3>Model of</h3>
  46. <a href="./EventVisitor.html">EventVisitor</a>
  47. <H3>Where Defined</H3>
  48. <P>
  49. <a href="../../../boost/graph/visitors.hpp">
  50. <TT>boost/graph/visitors.hpp</TT></a>
  51. <H3>Template Parameters</H3>
  52. <P>
  53. <TABLE border>
  54. <TR>
  55. <th>Parameter</th><th>Description</th><th>Default</th>
  56. </tr>
  57. <TR><TD><TT>PredecessorMap</TT></TD>
  58. <TD>
  59. A <a
  60. href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>
  61. where the key type and the value type are the vertex descriptor type
  62. of the graph.
  63. </TD>
  64. <TD>&nbsp;</TD>
  65. </TR>
  66. <TR><TD><TT>EventTag</TT></TD>
  67. <TD>
  68. The tag to specify when the <tt>predecessor_recorder</tt> should be
  69. applied during the graph algorithm. <tt>EventTag</tt> must be an
  70. edge event.
  71. </TD>
  72. <TD>&nbsp;</TD>
  73. </TR>
  74. </table>
  75. <H2>Associated Types</H2>
  76. <table border>
  77. <tr>
  78. <th>Type</th><th>Description</th>
  79. </tr>
  80. <tr>
  81. <td><tt>predecessor_recorder::event_filter</tt></td>
  82. <td>
  83. This will be the same type as the template parameter <tt>EventTag</tt>.
  84. </td>
  85. </tr>
  86. </table>
  87. <h3>Member Functions</h3>
  88. <p>
  89. <table border>
  90. <tr>
  91. <th>Member</th><th>Description</th>
  92. </tr>
  93. <tr>
  94. <td><tt>
  95. predecessor_recorder(PredecessorMap pa);
  96. </tt></td>
  97. <td>
  98. Construct a predecessor recorder object with predecessor property map
  99. <tt>pa</tt>.
  100. </td>
  101. </tr>
  102. <tr>
  103. <td><tt>
  104. template &lt;class Edge, class Graph&gt;<br>
  105. void operator()(Edge e, const Graph& g);
  106. </tt></td>
  107. <td>
  108. Given edge <i>e = (u,v)</i>, this records <i>u</i> as the
  109. predecessor (or parent) of <i>v</i>.
  110. </td>
  111. </tr>
  112. </table>
  113. <h3>Non-Member Functions</h3>
  114. <table border>
  115. <tr>
  116. <th>Function</th><th>Description</th>
  117. </tr>
  118. <tr><td><tt>
  119. template &lt;class PredecessorMap, class Tag&gt;<br>
  120. predecessor_recorder&lt;PredecessorMap, Tag&gt; <br>
  121. record_predecessors(PredecessorMap pa, Tag);
  122. </tt></td><td>
  123. A convenient way to create a <tt>predecessor_recorder</tt>.
  124. </td></tr>
  125. </table>
  126. <h3>See Also</h3>
  127. <a href="./visitor_concepts.html">Visitor concepts</a>
  128. <p>
  129. The following are other event visitors: <a
  130. <a href="./distance_recorder.html"><tt>distance_recorder</tt></a>,
  131. <a href="./time_stamper.html"><tt>time_stamper</tt></a>,
  132. and <a href="./property_writer.html"><tt>property_writer</tt></a>.
  133. <br>
  134. <HR>
  135. <TABLE>
  136. <TR valign=top>
  137. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  138. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
  139. Indiana University (<A
  140. HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
  141. <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>
  142. <A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>,
  143. Indiana University (<A
  144. HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
  145. </TD></TR></TABLE>
  146. </BODY>
  147. </HTML>
  148. <!-- LocalWords: PredecessorMap EventTag EventVisitor map bfs dfs const
  149. -->
  150. <!-- LocalWords: EventVisitorList WritablePropertyMap Siek Univ Quan
  151. -->
  152. <!-- LocalWords: Lumsdaine
  153. -->