2
0
mirror of https://github.com/boostorg/graph.git synced 2026-02-01 08:32:11 +00:00

some new docs, and more documentation edits

[SVN r7746]
This commit is contained in:
Jeremy Siek
2000-09-19 18:40:30 +00:00
parent 29f146132d
commit d11f5e8e0e
11 changed files with 537 additions and 112 deletions

View File

@@ -167,6 +167,11 @@ search tree and all of the adjacent vertices have been discovered
</table>
<h3>Models</h3>
<ul>
<li><a href="./ucs_visitor.html"><tt>ucs_visitor</tt></a>
</ul>
<br>
<HR>

View File

@@ -44,6 +44,10 @@ review. The pending items are:
<li><tt>disjoint_sets</tt>
</ul>
<li>Port the graph library to Borland C++</li>
<li>Port the graph library to Metrowerks C++</li>
<li>Construct a set of planar graph algorithms.</li>
<ul>
<li> Is the graph planar?
@@ -73,6 +77,9 @@ polygons.
<li>Explore the use of Algorithm Objects as an alternative to
the current approach with visitors.
<li>Analyze the algorithms that do not yet have visitors, and
come up with visitor interfaces for them.</li>
</ul>
<br>

View File

@@ -32,7 +32,7 @@ source vertex during a graph search. When applied to edge <i>e =
(u,v)</i>, the distance of <i>v</i> is recorded to be one more than
the distance of <i>u</i>. The distance recorder is typically used with
the <tt>on_tree_edge</tt> or <tt>on_relax_edge</tt> events, and
connot be used with vertex events.
cannot be used with vertex events.
<p>
<tt>distance_recorder</tt> can be used with graph algorithms by
@@ -147,7 +147,7 @@ template &lt;class DistancePA, class Tag&gt;<br>
distance_recorder&lt;DistancePA, Tag&gt; <br>
record_distances(DistancePA pa, Tag);
</tt></td><td>
A convenient wat to create a <tt>distance_recorder</tt>.
A convenient way to create a <tt>distance_recorder</tt>.
</td></tr>
</table>
@@ -178,3 +178,9 @@ HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
</BODY>
</HTML>
<!-- LocalWords: DistancePA EventTag EventVisitor accessor bfs dfs const Siek
-->
<!-- LocalWords: EventVisitorList WritablePropertyAccessor Univ Quan
-->
<!-- LocalWords: Lumsdaine
-->

View File

@@ -42,7 +42,7 @@ interface.
<P>
The BGL graph interface and graph components are <I>generic</I> in the
same sense as the the Standard Template Library (STL)&nbsp;[<A
HREF="node18.html#austern99:_gener_progr_stl">2</A>].
HREF="bibliography.html#austern99:_gener_progr_stl">2</A>].
In the following sections
we review the role that generic programming plays in the STL and
@@ -137,7 +137,7 @@ of their graph algorithms.
<P>
In contrast, custom-made (or even legacy) graph structures can be used
as-is with the generic graph algorithms of BGL using <I>external
adaptation</I> (see Section<A HREF="./leda_conversion.html">How to
adaptation</I> (see Section <A HREF="./leda_conversion.html">How to
Convert Existing Graphs to BGL</A>). External adaptation wraps a new
interface around a data-structure without copying and without placing
the data inside adaptor objects. The BGL interface was carefully
@@ -155,13 +155,11 @@ notion of a <I>visitor</I> which is just a function object with
multiple methods. In graph algorithms there are often several key
``event points'' at which it is useful to insert user-defined
operations. The visitor object has a different method that is invoked
at each event point. These methods include <TT>initialize()</TT>,
<TT>start()</TT>, <TT>discover()</TT>, <TT>explore()</TT>, and
<TT>finish()</TT>. In addition, several of the graph algorithms
naturally separate the edges of the graph into categories such as
forward and back edges. These categories can be used to obtain finer
grained control over when the <TT>process()</TT> method will be
invoked.
at each event point. The particular event points and corresponding
visitor methods depend on the particular algorithm. They often
include methods like <TT>start_vertex()</TT>,
<TT>discover_vertex()</TT>, <TT>examine_edge()</TT>,
<tt>tree_edge()</tt> and <TT>finish_vertex()</TT>.
<P>
@@ -208,8 +206,6 @@ algorithms. The core algorithm patterns are
</LI>
<LI>Uniform Cost Search
</LI>
<LI>Generalized Graph Initialization
</LI>
</UL>
<P>
@@ -221,28 +217,19 @@ include
<P>
<UL>
<LI>Dijkstra's Shortest Paths
</LI>
<LI>Bellman-Ford Shortest Paths
</LI>
<LI>Johnson's All-Pairs Shortest Paths
</LI>
<LI>Kruskal's Minimum Spanning Tree
</LI>
<LI>Prim's Minimum Spanning Tree
</LI>
<LI>Connected Components
</LI>
<LI>Strongly Connected Components
</LI>
<LI>Dynamic Connected Components (using Disjoint Sets)
</LI>
<LI>Topological Sort
</LI>
<LI>Transpose
</LI>
<LI>Reverse Cuthill Mckee Ordering
</LI>
<LI>Dijkstra's Shortest Paths</LI>
<LI>Bellman-Ford Shortest Paths</LI>
<LI>Johnson's All-Pairs Shortest Paths</LI>
<LI>Kruskal's Minimum Spanning Tree</LI>
<LI>Prim's Minimum Spanning Tree</LI>
<LI>Connected Components</LI>
<LI>Strongly Connected Components</LI>
<LI>Dynamic Connected Components (using Disjoint Sets)</LI>
<LI>Topological Sort</LI>
<LI>Transpose</LI>
<LI>Reverse Cuthill Mckee Ordering</LI>
<LI>Smallest Last Vertex Ordering</LI>
<LI>Sequential Vertex Coloring</LI>
</UL>
<P>

View File

@@ -25,10 +25,60 @@ null_visitor
</pre>
</H1>
This is an <a href="./EventVisitor.html">EventVisitor</a> that
does nothing.
<h3>Model of</h3>
<a href="./EventVisitor.html">EventVisitor</a>
<H2>Associated Types</H2>
<table border>
<tr>
<th>Type</th><th>Description</th>
</tr>
<tr>
<td><tt>null_visitor::event_filter</tt></td>
<td>
This type is <tt>void</tt>
</td>
</tr>
</table>
<h3>Member Functions</h3>
<p>
<table border>
<tr>
<th>Member</th><th>Description</th>
</tr>
<tr>
<td><tt>
null_visitor();
</tt></td>
<td>
Default constructor.
</td>
</tr>
<tr>
<td><tt>
template &lt;class X, class Graph&gt;<br>
void operator()(X x, const Graph& g);
</tt></td>
<td>
This does nothing.
</td>
</tr>
</table>
<br>
<HR>

View File

@@ -31,7 +31,7 @@ accessor. 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 predecessor recorder is
typically used with the <tt>on_tree_edge</tt> or
<tt>on_relax_edge</tt> events, and connot be used with vertex events.
<tt>on_relax_edge</tt> events, and cannot be used with vertex events.
<p>
<tt>predecessor_recorder</tt> can be used with graph algorithms by
@@ -146,7 +146,7 @@ template &lt;class PredecessorPA, class Tag&gt;<br>
predecessor_recorder&lt;PredecessorPA, Tag&gt; <br>
record_predecessors(PredecessorPA pa, Tag);
</tt></td><td>
A convenient wat to create a <tt>predecessor_recorder</tt>.
A convenient way to create a <tt>predecessor_recorder</tt>.
</td></tr>
</table>
@@ -177,3 +177,9 @@ HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
</BODY>
</HTML>
<!-- LocalWords: PredecessorPA EventTag EventVisitor accessor bfs dfs const
-->
<!-- LocalWords: EventVisitorList WritablePropertyAccessor Siek Univ Quan
-->
<!-- LocalWords: Lumsdaine
-->

207
docs/property_writer.html Normal file
View File

@@ -0,0 +1,207 @@
<HTML>
<!--
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
--
-- Permission to use, copy, modify, distribute and sell this software
-- and its documentation for any purpose is hereby granted without fee,
-- provided that the above copyright notice appears in all copies and
-- that both that copyright notice and this permission notice appear
-- in supporting documentation. We make no
-- representations about the suitability of this software for any
-- purpose. It is provided "as is" without express or implied warranty.
-->
<Head>
<Title>Boost Graph Library: property_writer</Title>
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
ALINK="#ff0000">
<IMG SRC="../../../c++boost.gif"
ALT="C++ Boost">
<BR Clear>
<H1>
<pre>
property_writer&lt;PropertyAccessor, OutputIterator, EventTag&gt;
</pre>
</H1>
This is an <a href="./EventVisitor.html">EventVisitor</a> that can be
used to output the property of a vertex or edge at some event-point
within an algorithm.
<p>
<tt>property_writer</tt> can be used with graph algorithms by
wrapping it with the algorithm specific adaptor, such as <a
href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and <a
href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>. Also, this event
visitor can be combined with other event visitors using
<tt>std::pair</tt> to form an EventVisitorList.
<h3>Example</h3>
The following is an excerpt from <a
href="../examples/dave.cpp"><tt>examples/dave.cpp</tt></a>.
<pre>
std::ostream_iterator<int> cout_int(std::cout, " ");
std::ostream_iterator<char> 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()
))))));
</pre>
<h3>Model of</h3>
<a href="./EventVisitor.html">EventVisitor</a>
<H3>Where Defined</H3>
<P>
<a href="../../../boost/graph/visitors.hpp">
<TT>boost/graph/visitors.hpp</TT></a>
<H3>Template Parameters</H3>
<P>
<TABLE border>
<TR>
<th>Parameter</th><th>Description</th><th>Default</th>
</tr>
<TR><TD><TT>PropertyAccessor</TT></TD>
<TD>
A <a
href="../../property_accessor/ReadablePropertyAccessor.html">ReadablePropertyAccessor</a>,
where the <tt>key_type</tt> is the vertex descriptor type or edge
descriptor of the graph (depending on the kind of event tag), and
the <tt>value_type</tt> of the property is convertible
to the <tt>value_type</tt> of the <tt>OutputIterator</tt>.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR><TD><TT>OutputIterator</TT></TD>
<TD>
The iterator type used to write out the property values, which must be
a model of <a
href="http://www.sgi.com/Technology/STL/OutputIterator.html">OutputIterator</a>.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR><TD><TT>EventTag</TT></TD>
<TD>
The tag to specify when the <tt>property_writer</tt> should be
applied during the graph algorithm.
</TD>
<TD>&nbsp;</TD>
</TR>
</table>
<H2>Associated Types</H2>
<table border>
<tr>
<th>Type</th><th>Description</th>
</tr>
<tr>
<td><tt>property_writer::event_filter</tt></td>
<td>
This will be the same type as the template parameter <tt>EventTag</tt>.
</td>
</tr>
</table>
<h3>Member Functions</h3>
<p>
<table border>
<tr>
<th>Member</th><th>Description</th>
</tr>
<tr>
<td><tt>
property_writer(PropertyAccessor pa, OutputIterator out);
</tt></td>
<td>
Construct a property writer object with the property accessor
<tt>pa</tt> and output iterator <tt>out</tt>.
</td>
</tr>
<tr>
<td><tt>
template &lt;class X, class Graph&gt;
void operator()(X x, const Graph& g);
</tt></td>
<td>
This writs the property value for <tt>x</tt> to the output iterator.<br>
<tt>*out++ = get(pa, x);</tt>
</td>
</tr>
</table>
<h3>Non-Member Functions</h3>
<table border>
<tr>
<th>Function</th><th>Description</th>
</tr>
<tr><td><tt>
template &lt;class PropertyAccessor, class OutputIterator, class Tag&gt;<br>
property_writer&lt;PropertyAccessor, OutputIterator, Tag&gt;<br>
write_property(PropertyAccessor pa, OutputIterator out, Tag);
</tt></td><td>
A convenient way to create a <tt>property_writer</tt>.
</td></tr>
</table>
<h3>See Also</h3>
<a href="./visitor_concepts.html">Visitor concepts</a>
<p>
The following are other event visitors: <a
<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>,
<a href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>,
and <a href="./time_stamper.html"><tt>time_stamper</tt></a>.
<br>
<HR>
<TABLE>
<TR valign=top>
<TD nowrap>Copyright &copy 2000</TD><TD>
<A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>,
Univ.of Notre Dame (<A
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
<A HREF=http://www.lsc.nd.edu/~llee1>Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
Univ.of Notre Dame (<A
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
</TD></TR></TABLE>
</BODY>
</HTML>
<!-- LocalWords: PropertyAccessor OutputIterator EventTag EventVisitor bfs dfs EventVisitorList
-->
<!-- LocalWords: cpp num dtime ftime int WritablePropertyAccessor accessor
-->
<!-- LocalWords: const Siek Univ Quan Lumsdaine
-->

View File

@@ -516,9 +516,8 @@ href="http://www.sgi.com/Technology/STL/RandomAccessIterator.html">RandomAccessI
<P>
<PRE>
typedef plugin&lt;weight_tag, int&gt; weightp;
typedef adjacency_list&lt;listS, vecS, directedS,
no_plugin, weightp&gt; Graph;
no_plugin, plugin&lt;weight_tag, int&gt; &gt; Graph;
typedef graph_traits&lt;Graph&gt;::vertex_descriptor Vertex;
typedef std::pair&lt;int,int&gt; E;
@@ -594,33 +593,46 @@ A visitor is like a functor, but instead of having just one
&quot;apply&quot; method, it has several. Each of these methods get
invoked at certain well-defined points within the algorithm. The
visitor methods are explained in detail in Section <a
href="./visitor_concepts.html">Visitor Concepts</a>. The BGL provides
a number of visitors for some common tasks including a predecessor
recording visitor. The user is encouraged to write his or her own
visitors as a way of extending the BGL. Here we will take a quick look
at the implementation and use of the predecessor recorder.
href="./visitor_concepts.html">Visitor Concepts</a>.
The BGL provides a number of visitors for some common tasks including
a predecessor recording visitor. The user is encouraged to write his
or her own visitors as a way of extending the BGL. Here we will take a
quick look at the implementation and use of the predecessor recorder.
Since we will be using the <a
href="./dijkstra_shortest_paths.html">dijkstra_shortest_paths()</a>
algorithm, the visitor we create must be a (a <a
href="./UniformCostVisitor.html">UniformCostVisitor</a>).
<P>
The functionality of the predecessor recorder is separated into two
parts. For the storage and access of the predecessor property, we will
use a property accessor. The predecessor visitor will then only be
responsible for what parent to record. To implement this, we create a
<TT>predecessor_recorder</TT> class and template it on the predecessor
property accessor <TT>Predecessor</TT>. Since this visitor will only be
filling in one of the visitor methods, we will inherit from
<TT>null_visitor</TT> which will provide empty methods for the rest.
The constructor of the <TT>predecessor_recorder</TT> will take the
property accessor object and save it away in a data member.
The functionality of the <tt>record_predecessors</tt> visitor is
separated into two parts. For the storage and access of the
predecessor property, we will use a <a
href="../../property_accessor/property_accessor.html">property
accessor</a>. The predecessor visitor will then only be responsible
for what parent to record. To implement this, we create a
<TT>record_predecessors</TT> class and template it on the predecessor
property accessor <TT>PredecessorAccessor</TT>. Since this visitor
will only be filling in one of the visitor methods, we will inherit
from <a href="./ucs_visitor.html"><TT>ucs_visitor</TT></a> which will
provide empty methods for the rest. The constructor of the
<TT>predecessor_recorder</TT> will take the property accessor object
and save it away in a data member.
<P>
<PRE>
template &lt;class PredecessorAccessor&gt;
class predecessor_recorder : public null_visitor
class record_predecessors : public ucs_visitor&lt;&gt;
{
public:
predecessor_recorder(PredecessorAccessor p)
record_predecessors(PredecessorAccessor p)
: m_predecessor(p) { }
//...
template &lt;class Edge, class Graph&gt;
void edge_relaxed(Edge e, Graph&amp; g) {
// set the parent of the target(e) to source(e)
put(m_predecessor, target(e, g), source(e, g));
}
protected:
PredecessorAccessor m_predecessor;
};
@@ -628,30 +640,15 @@ property accessor object and save it away in a data member.
<P>
The job of recording the predecessors is quite simple. When Dijkstra's
algorithm adds an edge to the shortest-paths tree we just record the
source vertex as the parent of the target vertex. Here we use the
<TT>put()</TT> function associated with the property accessor to record
the predecessor. The <TT>edge_filter</TT> of the visitor tells the
algorithm when to invoke the <TT>explore()</TT> method. In this case we
only want to be notified about edges in the shortest-paths tree so we
specify <TT>tree_edge_tag</TT>.
<P>
<PRE>
template &lt;class PredecessorAccessor&gt;
class predecessor_recorder
{
//...
typedef tree_edge_tag edge_filter;
template &lt;class Edge, class Graph&gt;
void explore(Edge e, Graph&amp; g) {
// set the parent of the target(e) to source(e)
put(m_predecessor, target(e, g), source(e, g));
}
//...
};
</PRE>
algorithm relaxes an edge (potentially adding it to the shortest-paths
tree) we record the source vertex as the predecessor of the target
vertex. Later, if the edge is relaxed again the predecessor property
will be overwritten by the new predecessor. Here we use the
<TT>put()</TT> function associated with the property accessor to
record the predecessor. The <TT>edge_filter</TT> of the visitor tells
the algorithm when to invoke the <TT>explore()</TT> method. In this
case we only want to be notified about edges in the shortest-paths
tree so we specify <TT>tree_edge_tag</TT>.
<P>
As a finishing touch, we create a helper function to make it more
@@ -661,14 +658,14 @@ helper function like this.
<P>
<PRE>
template &lt;class PredecessorAccessor&gt;
predecessor_recorder&lt;PredecessorAccessor&gt;
record_predecessors(PredecessorAccessor p) {
return predecessor_recorder&lt;PredecessorAccessor&gt;(p);
record_predecessors&lt;PredecessorAccessor&gt;
make_predecessor_recorder(PredecessorAccessor p) {
return record_predecessors&lt;PredecessorAccessor&gt;(p);
}
</PRE>
<P>
We are now ready to use the <TT>predecessor_recorder</TT> in
We are now ready to use the <TT>record_predecessors</TT> in
Dijkstra's algorithm. Luckily, BGL's Dijkstra's algorithm is already
equipped to handle visitors, so we just have to call the four argument
version of the algorithm and pass in our new visitor. In this example
@@ -683,7 +680,7 @@ handle the use of multiple visitors in the same algorithm (see Section
using std::endl;
vector&lt;Vertex&gt; p(num_vertices(G)); //the predecessor array
dijkstra_shortest_paths(G, s, d.begin(),
record_predecessors(p.begin()));
make_predecessor_recorder(p.begin()));
cout &lt;&lt; "parents in the tree of shortest paths:" &lt;&lt; endl;
for(vi = vertices(G).first; vi != vertices(G).second; ++vi) {
@@ -715,3 +712,15 @@ The output is:
</BODY>
</HTML>
<!-- LocalWords: STL BGL cpp vecS bidirectionalS directedS undirectedS hpp vp
-->
<!-- LocalWords: iostream namespace ggcl int const num sizeof accessor ID's
-->
<!-- LocalWords: iter ei interoperability struct typename GraphTraits src ai
-->
<!-- LocalWords: targ VertexPropertyGraph EdgePropertyGraph Plugins plugin
-->
<!-- LocalWords: VertexList dijkstra listS Edgelist RandomAccessIterator
-->
<!-- LocalWords: weightp UniformCostVisitor
-->

View File

@@ -27,8 +27,8 @@ time_stamper&lt;TimePA, TimeT, EventTag&gt;
This is an <a href="./EventVisitor.html">EventVisitor</a> that can be
used to &quot;stamp&quot; a time at some event-point within an
algorithm. An example of this is recording the discover or finish
time of a vertex during a graph search.
algorithm. An example of this is recording the discover or finish time
of a vertex during a graph search.
<p>
<tt>time_stamper</tt> can be used with graph algorithms by
@@ -79,17 +79,27 @@ href="../examples/bfs_basics.cpp"><tt>examples/bfs_basics.cpp</tt></a>.
<TD>
A <a
href="../../property_accessor/WritablePropertyAccessor.html">WritablePropertyAccessor</a>,
where the key type and the value type are the vertex descriptor type
of the graph.
where the <tt>key_type</tt> is the vertex descriptor type or edge
descriptor of the graph (depending on the kind of event tag), and
where the <tt>TimeT</tt> type is convertible to the
<tt>value_type</tt> of the time property accessor.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR><TD><TT>TimeT</TT></TD>
<TD>
The type for the time counter, which should be convertible to the
<tt>value_type</tt> of the time property accessor
</TD>
<TD>&nbsp;</TD>
</TR>
<TR><TD><TT>EventTag</TT></TD>
<TD>
The tag to specify when the <tt>time_stamper</tt> should be
applied during the graph algorithm. <tt>EventTag</tt> must be an
edge event.
applied during the graph algorithm.
</TD>
<TD>&nbsp;</TD>
</TR>
@@ -134,12 +144,12 @@ Construct a time stamper object with time property accessor
<tr>
<td><tt>
template &lt;class Vertex, class Graph&gt;
void operator()(Vertex u, const Graph& g);
template &lt;class X, class Graph&gt;
void operator()(X x, const Graph& g);
</tt></td>
<td>
This increments the time count and &quot;stamps&quot; the time:<br>
<tt>put(time_pa, u, ++t);</tt>
<tt>put(time_pa, x, ++t);</tt>
</td>
</tr>
@@ -153,11 +163,11 @@ This increments the time count and &quot;stamps&quot; the time:<br>
</tr>
<tr><td><tt>
template &lt;class TimePA, class Tag&gt;<br>
time_stamper&lt;TimePA, Tag&gt; <br>
record_predecessors(TimePA pa, Tag);
template &lt;class TimePA, class TimeT, class Tag&gt;<br>
time_stamper&lt;TimePA, TimeT, Tag&gt;<br>
stamp_times(TimePA pa, TimeT& t, Tag);
</tt></td><td>
A convenient wat to create a <tt>time_stamper</tt>.
A convenient way to create a <tt>time_stamper</tt>.
</td></tr>
</table>
@@ -188,3 +198,9 @@ HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
</BODY>
</HTML>
<!-- LocalWords: TimePA TimeT EventTag EventVisitor bfs dfs EventVisitorList
-->
<!-- LocalWords: cpp num dtime ftime int WritablePropertyAccessor accessor
-->
<!-- LocalWords: const Siek Univ Quan Lumsdaine
-->

131
docs/ucs_visitor.html Normal file
View File

@@ -0,0 +1,131 @@
<HTML>
<!--
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
--
-- Permission to use, copy, modify, distribute and sell this software
-- and its documentation for any purpose is hereby granted without fee,
-- provided that the above copyright notice appears in all copies and
-- that both that copyright notice and this permission notice appear
-- in supporting documentation. We make no
-- representations about the suitability of this software for any
-- purpose. It is provided "as is" without express or implied warranty.
-->
<Head>
<Title>Boost Graph Library: ucs_visitor</Title>
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
ALINK="#ff0000">
<IMG SRC="../../../c++boost.gif"
ALT="C++ Boost">
<BR Clear>
<H1>
<pre>
ucs_visitor&lt;EventVisitorList&gt;
</pre>
</H1>
This class is an adapter that converts a list of <a
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
<tt>std::pair</tt>) into a <a
href="./UniformCostVisitor.html">UniformCostVisitor</a>.
<h3>Example</h3>
This is an excerpt from <a
href="../examples/dijkstra.cpp"><tt>examples/dijkstra.cpp</tt></a>
where the <tt>predecessor_recorder</tt> single-event visitor
is used to record the shortest-paths search-tree calculated
by Dijkstra's algorithm.
<pre>
std::vector&lt;Vertex&gt; p(num_vertices(G));
std::vector&lt;int&gt; d(num_vertices(G));
Vertex s = *(vertices(G).first);
dijkstra_shortest_paths(G, s, d.begin(),
make_ucs_visitor(record_predecessors(p.begin(), on_edge_relaxed())));
</pre>
<h3>Model of</h3>
<a href="./UniformCostVisitor.html">UniformCostVisitor</a>
<H3>Template Parameters</H3>
<P>
<TABLE border>
<TR>
<th>Parameter</th><th>Description</th><th>Default</th>
</tr>
<TR><TD><TT>EventVisitorList</TT></TD>
<TD>
A list of <a href="./EventVisitor.html">EventVisitor</a>'s created
with <tt>std::pair</tt>.
</TD>
<TD><TT><a href="./null_visitor.html"><tt>null_visitor</tt></a></TT></TD>
</TR>
</table>
<H3>Where Defined</H3>
<P>
<a href="../../../boost/graph/uniform_cost_search.hpp">
<TT>boost/graph/uniform_cost_search.hpp</TT></a>
<h3>Member Functions</h3>
This class implements all of the member functions required by <a
href="./UniformCostVisitor.html">UniformCostVisitor</a>. In each
function the appropriate event is dispatched to the <a
href="./EventVisitor.html">EventVisitor</a>'s in the EventVisitorList.
<h3>Non-Member Functions</h3>
<table border>
<tr>
<th>Function</th><th>Description</th>
</tr>
<tr><td><tt>
template &lt;class EventVisitorList&gt;<br>
bfs_visitor&lt;EventVisitorList&gt;<br>
make_bfs_visitor(EventVisitorList ev_list);
</tt></td><td>
Returns the event visitor list adapted to be a BFS visitor.
</td></tr>
</table>
<h3>See Also</h3>
<a href="./visitor_concepts.html">Visitor concepts</a>
<p>
The following are event visitors: <a
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>,
<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>
<a href="./time_stamper.html"><tt>time_stamper</tt></a>,
and <a href="./property_writer.html"><tt>property_writer</tt></a>.
<br>
<HR>
<TABLE>
<TR valign=top>
<TD nowrap>Copyright &copy 2000</TD><TD>
<A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>,
Univ.of Notre Dame (<A
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
<A HREF=http://www.lsc.nd.edu/~llee1>Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
<A HREF=http://www.lsc.nd.edu/~lums>Andrew Lumsdaine</A>,
Univ.of Notre Dame (<A
HREF="mailto:lums@lsc.nd.edu">lums@lsc.nd.edu</A>)
</TD></TR></TABLE>
</BODY>
</HTML>

View File

@@ -111,25 +111,25 @@ variables of the distance property type.
</PRE>
<P>
There are two kinds of graph properties: internal and external.
There are two kinds of graph properties: interior and exterior.
<P>
<DL>
<DT><STRONG>Internal Properties</STRONG></DT>
<DT><STRONG>Interior Properties</STRONG></DT>
<DD>are stored ``inside'' the graph object
in some way, and the lifetime of the property value objects is the
same as that of the graph object.
<P>
</DD>
<DT><STRONG>External Properties</STRONG></DT>
<DT><STRONG>Exterior Properties</STRONG></DT>
<DD>are stored ``outside'' of the graph
object and the lifetime of the property value objects is independent
of the graph. This is useful for properties that are only needed
temporarily, perhaps for the duration of a particular algorithm such
as the color property used in <TT>breadth_first_search()</TT>. When
using external properties with a BGL algorithm a property accessor
object for the external property must be passed as an argument to the
using exterior properties with a BGL algorithm a property accessor
object for the exterior property must be passed as an argument to the
algorithm.
</DD>
</DL>
@@ -141,7 +141,7 @@ Interior Properties
</H2>
<P>
A graph type that supports internal property storage (such as
A graph type that supports interior property storage (such as
<TT>adjacency_list</TT>) provides access to its property accessor
objects through the interface defined in <I>VertexPropertyGraph</I>
and <I>EdgePropertyGraph</I>. There are two functions,
@@ -187,7 +187,7 @@ property accessors: distance, weight, color, and vertex ID.
</PRE>
<P>
Often times some or all of the properties will be internal to the
Often times some or all of the properties will be interior to the
graph, so one would call Dijkstra's algorithm in the following way
(given some graph <TT>g</TT> and source vertex <TT>src</TT>).
@@ -204,11 +204,11 @@ graph, so one would call Dijkstra's algorithm in the following way
<P>
Since it is somewhat cumbersome to specify all of the property
accessors, BGL provides several ``short-cut'' interfaces to each
algorithm that assume some of the properties are internal and can be
algorithm that assume some of the properties are interior and can be
accessed via <TT>get_vertex_property_accessor()</TT> from the
graph. Below we show a call to variant 1 of the
<TT>dijkstra_shortest_paths</TT> algorithm, which assumes
all of the properties are internal. This call is equivalent
all of the properties are interior. This call is equivalent
to the previous call to Dijkstra's algorithm.
<P>
@@ -217,7 +217,7 @@ to the previous call to Dijkstra's algorithm.
</PRE>
<P>
The next question is: how to internal properties become attached to a
The next question is: how to interior properties become attached to a
graph object in the first place? This depends on the graph class that
you are using. The <TT>adjacency_list</TT> graph class of BGL uses a
plugin mechanism (see Section <A
@@ -343,7 +343,8 @@ colors which will be needed in a call to
<TT>std::vector</TT> (obtained with a call to <TT>begin()</TT>) is a
pointer, the pointer property accessor method also works for
<TT>std::vector::iterator</TT>. The complete source code for this
examples is in <TT>examples/city_visitor.cpp</TT>.
examples is in <a
href="../examples/city_visitor.cpp"><TT>examples/city_visitor.cpp</TT></a>.
<P>
<PRE>
@@ -370,7 +371,7 @@ int main(int,char*[])
Graph G(N, edge_array, edge_array + sizeof(edge_array)/sizeof(E));
// DFS and BFS need to "color" the vertices.
// Here we use std::vector as external property storage.
// Here we use std::vector as exterior property storage.
std::vector&lt;default_color_type&gt; colors(N);
cout &lt;&lt; "*** Depth First ***" &lt;&lt; endl;
@@ -408,7 +409,7 @@ class.
<P>
The implementation of the
<TT>random_access_iterator_property_accessor</TT> class
serves as a good example for how to build and external property
serves as a good example for how to build and exterior property
accessor. Here we present a simplified implementation of the
<TT>random_access_iterator_property_accessor</TT> class
which we will name <TT>iterator_pa</TT>.