]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/graph/doc/BFSVisitor.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / graph / doc / BFSVisitor.html
CommitLineData
7c673cae
FG
1<HTML>
2<!--
3 Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
4
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)
8 -->
9<Head>
10<Title>Boost Graph Library: BFSVisitor</Title>
11<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
12 ALINK="#ff0000">
13<IMG SRC="../../../boost.png"
14 ALT="C++ Boost" width="277" height="86">
15
16<BR Clear>
17
18<H1><img src="figs/python.gif" alt="(Python)"/>BFS Visitor Concept</H1>
19
20This concept defines the visitor interface for <a
21href="./breadth_first_search.html"><tt>breadth_first_search()</tt></a>.
22Users can define a class with the BFS Visitor interface and pass and
23object of the class to <tt>breadth_first_search()</tt>, thereby
24augmenting the actions taken during the graph search.
25
26<h3>Refinement of</h3>
27
28<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
29(copying a visitor should be a lightweight operation).
30
31
32<h3>Notation</h3>
33
34<Table>
35<TR>
36<TD><tt>V</tt></TD>
37<TD>A type that is a model of BFS Visitor.</TD>
38</TR>
39
40<TR>
41<TD><tt>vis</tt></TD>
42<TD>An object of type <tt>V</tt>.</TD>
43</TR>
44
45<TR>
46<TD><tt>G</tt></TD>
47<TD>A type that is a model of Graph.</TD>
48</TR>
49
50<TR>
51<TD><tt>g</tt></TD>
52<TD>An object of type <tt>G</tt>.</TD>
53</TR>
54
55<TR>
56<TD><tt>e</tt></TD>
57<TD>An object of type <tt>boost::graph_traits&lt;G&gt;::edge_descriptor</tt>.</TD>
58</TR>
59
60<TR>
61<TD><tt>s,u</tt></TD>
62<TD>An object of type <tt>boost::graph_traits&lt;G&gt;::vertex_descriptor</tt>.</TD>
63</TR>
64
65</table>
66
67<h3>Associated Types</h3>
68
69none
70<p>
71
72<h3>Valid Expressions</h3>
73
74<table border>
75<tr>
76<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
77</tr>
78
79<tr>
80<td>Initialize Vertex</td>
81<td><tt>vis.initialize_vertex(s, g)</tt></td>
82<td><tt>void</tt></td>
83<td>
84This is invoked on every vertex of the graph before the start of the
85graph search.
86</td>
87</tr>
88
89<tr>
90<td>Discover Vertex</td>
91<td><tt>vis.discover_vertex(u, g)</tt></td>
92<td><tt>void</tt></td>
93<td>
94This is invoked when a vertex is encountered for the first time.
95</td>
96</tr>
97
98<tr>
99<td>Examine Vertex</td>
100<td><tt>vis.examine_vertex(u, g)</tt></td>
101<td><tt>void</tt></td>
102<td>
103This is invoked on a vertex as it is popped from the queue. This
104happens immediately before <tt>examine_edge()</tt> is invoked
105on each of the out-edges of vertex <tt>u</tt>.
106</td>
107</tr>
108
109<tr>
110<td>Examine Edge</td>
111<td><tt>vis.examine_edge(e, g)</tt></td>
112<td><tt>void</tt></td>
113<td>
114This is invoked on every out-edge of each vertex after it is discovered.
115</td>
116</tr>
117
118
119<tr>
120<td>Tree Edge</td>
121<td><tt>vis.tree_edge(e, g)</tt></td>
122<td><tt>void</tt></td>
123<td>
124This is invoked on each edge as it becomes a member of the edges that
125form the search tree.</td>
126</tr>
127
128<tr>
129<td>Non-Tree Edge</td>
130<td><tt>vis.non_tree_edge(e, g)</tt></td>
131<td><tt>void</tt></td>
132<td>
133This is invoked on back or cross edges for directed graphs and cross
134edges for undirected graphs.
135</td>
136</tr>
137
138<tr>
139<td>Gray Target</td>
140<td><tt>vis.gray_target(e, g)</tt></td>
141<td><tt>void</tt></td>
142<td>
143This is invoked on the subset of non-tree edges whose target vertex is
144colored gray at the time of examination. The color gray indicates
145that the vertex is currently in the queue.
146</td>
147</tr>
148
149<tr>
150<td>Black Target</td>
151<td><tt>vis.black_target(e, g)</tt></td>
152<td><tt>void</tt></td>
153<td>
154This is invoked on the subset of non-tree edges whose target vertex is
155colored black at the time of examination. The color black indicates
156that the vertex has been removed from the queue.
157</td>
158</tr>
159
160<tr>
161<td>Finish Vertex</td>
162<td><tt>vis.finish_vertex(u, g)</tt></td>
163<td><tt>void</tt></td>
164<td>
165This invoked on a vertex after all of its out edges have been added to the
166search tree and all of the adjacent vertices have been discovered
167(but before the out-edges of the adjacent vertices have been examined).
168</td>
169</tr>
170
171</table>
172
173<h3>Models</h3>
174
175<ul>
176 <li><a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>
177</ul>
178
179<a name="python"></a><h3>Python</h3>
180To implement a model of the <tt>BFSVisitor</tt> concept in Python,
181create a new class that derives from the <tt>BFSVisitor</tt> type of
182the graph, which will be
183named <tt><i>GraphType</i>.BFSVisitor</tt>. The events and syntax are
184the same as with visitors in C++. Here is an example for the
185Python <tt>bgl.Graph</tt> graph type:
186
187<pre>
188class count_tree_edges_bfs_visitor(bgl.Graph.BFSVisitor):
189 def __init__(self, name_map):
190 bgl.Graph.BFSVisitor.__init__(self)
191 self.name_map = name_map
192
193 def tree_edge(self, e, g):
194 (u, v) = (g.source(e), g.target(e))
195 print "Tree edge ",
196 print self.name_map[u],
197 print " -> ",
198 print self.name_map[v]
199</pre>
200
201<h3>See also</h3>
202
203<a href="./visitor_concepts.html">Visitor concepts</a>
204
205<br>
206<HR>
207<TABLE>
208<TR valign=top>
209<TD nowrap>Copyright &copy; 2000-2001</TD><TD>
210<A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
211Indiana University (<A
212HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
213<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>
214<A HREF="http://www.osl.iu.edu/~lums">Andrew Lumsdaine</A>,
215Indiana University (<A
216HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
217</TD></TR></TABLE>
218
219</BODY>
220</HTML>