recommit after docs->doc dir name change
[SVN r8402]
150
doc/AdjacencyGraph.html
Normal file
@@ -0,0 +1,150 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>AdjacencyGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
|
||||
<H2><A NAME="concept:AdjacencyGraph"></A>
|
||||
AdjacencyGraph
|
||||
</H2>
|
||||
|
||||
The AdjacencyGraph concept provides and interface for efficient access
|
||||
of the adjacent vertices to a vertex in a graph. This is quite similar
|
||||
to the <a href="./IncidenceGraph.html">IncidenceGraph</a> concept (the
|
||||
target of an out-edge is an adjacent vertex). Both concepts are
|
||||
provided because in some contexts there is only concern for the
|
||||
vertices, whereas in other contexts the edges are also important.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::adjacency_iterator</pre>
|
||||
An adjacency iterator for a vertex <i>v</i> provides access to the
|
||||
vertices adjacent to <i>v</i>. As such, the value type of an
|
||||
adjacency iterator is the vertex descriptor type of its graph. An
|
||||
adjacency iterator must meet the requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:adjacent-vertices"><TT>adjacent_vertices(v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Returns an iterator-range providing access to the vertices adjacent to
|
||||
vertex <TT>v</TT> in graph <TT>g</TT>. <a href="adjacencygraph.html#1">[1]</a><br>
|
||||
Return type: <TT>std::pair<adjacency_iterator, adjacency_iterator></TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
The <TT>adjacent_vertices()</TT> function must return in constant time.
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct AdjacencyGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::adjacency_iterator
|
||||
adjacency_iterator;
|
||||
void constraints() {
|
||||
function_requires< IncidenceGraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<adjacency_iterator> >();
|
||||
|
||||
p = adjacent_vertices(v, g);
|
||||
v = *p.first;
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = adjacent_vertices(v, g);
|
||||
}
|
||||
std::pair<adjacency_iterator,adjacency_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor v;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<a name="1">[1]</a> The case of a
|
||||
<I>multigraph</I> (where multiple edges can connect the same two
|
||||
vertices) brings up an issue as to whether the iterators returned by
|
||||
the <TT>adjacent_vertices()</TT> function access a range that
|
||||
includes each adjacent vertex once, or whether it should match the
|
||||
behavior of the <TT>out_edges()</TT> function, and access a
|
||||
range that may include an adjacent vertex more than once. For now the
|
||||
behavior is defined to match that of <TT>out_edges()</TT>,
|
||||
though this decision may need to be reviewed in light of more
|
||||
experience with graph algorithm implementations.
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
90
doc/AdjacencyMatrix.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>AdjacencyMatrix</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
|
||||
<H2><A NAME="concept:AdjacencyMatrix"></A>
|
||||
AdjacencyMatrix
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The AdjacencyMatrix concept refines <a href="./Graph.html">Graph</a>
|
||||
concept and adds the requirement for efficient access to any edge in
|
||||
the graph given the source and target vertices. No Boost Graph Library
|
||||
algorithms currently use this concept. However there are algorithms
|
||||
not yet implemented such as Floyd-Warshall that would require this
|
||||
concept.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Direct Edge Access</td>
|
||||
<TD><TT>edge(u,v,g)</TT></TD>
|
||||
<TD><TT>std::pair<edge_descriptor, bool></TT></TD>
|
||||
<TD>
|
||||
Returns a pair consisting of a flag saying whether there exists an
|
||||
edge between <TT>u</TT> and <TT>v</TT> in graph <TT>g</TT>, and
|
||||
consisting of the edge descriptor if the edge was found.
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
No models of this concept are currently in the Boost Graph Library.
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct AdjacencyMatrix
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
p = edge(u, v, g);
|
||||
}
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
std::pair<bool, edge_descriptor> p;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
201
doc/BFSVisitor.html
Normal file
@@ -0,0 +1,201 @@
|
||||
<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: BFSVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>BFSVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./breadth_first_search.html"><tt>breadth_first_search()</tt></a>.
|
||||
Users can define a class with the BFSVisitor interface and pass and
|
||||
object of the class to <tt>breadth_first_search()</tt>, thereby
|
||||
augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of BFSVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every vertex of the graph before the start of the
|
||||
graph search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Start Vertex</td>
|
||||
<td><tt>vis.start_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the source vertex once before the start of the
|
||||
search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Discover Vertex</td>
|
||||
<td><tt>vis.discover_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked when a vertex is encountered for the first time.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every out-edge of each vertex after it is discovered.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>Tree Edge</td>
|
||||
<td><tt>vis.tree_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on each edge as it becomes a member of the edges that
|
||||
form the search tree.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Cycle Edge</td>
|
||||
<td><tt>vis.cycle_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on back or cross edges for directed graphs and cross
|
||||
edges for undirected graphs.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Gray Target</td>
|
||||
<td><tt>vis.gray_target(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the subset of cycle edges who's target vertex is
|
||||
colored gray at the time of examination. The color gray indicates
|
||||
that the vertex is currently in the queue.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Black Target</td>
|
||||
<td><tt>vis.black_target(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the subset of cycle edges who's target vertex is
|
||||
colored black at the time of examination. The color black indicates
|
||||
that the vertex has been removed from the queue.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This invoked on a vertex after all of its out edges have been added to the
|
||||
search tree and all of the adjacent vertices have been discovered
|
||||
(but before their out-edges have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>See also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
175
doc/BellmanFordVisitor.html
Normal file
@@ -0,0 +1,175 @@
|
||||
<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: BellmanFordVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>BellmanFordVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./bellman_ford_shortest.html"><tt>bellman_ford_shortest_paths()</tt></a>.
|
||||
Users can define a class with the BellmanFordVisitor interface and
|
||||
pass and object of the class to <tt>bellman_ford_shortest_paths()</tt>,
|
||||
thereby augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of BellmanFordVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every vertex of the graph before the start of the
|
||||
graph search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every edge in the graph <tt>num_vertices(g)</tt> times.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>Edge Relaxed</td>
|
||||
<td><tt>vis.edge_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the following condition holds then the edge
|
||||
is relaxed (its distance is reduced), and this method is invoked.<br>
|
||||
<tt>
|
||||
tie(u,v) = incident(e, g);<br>
|
||||
D d_u = get(d, u), d_v = get(d, v);<br>
|
||||
W w_e = get(w, e);<br>
|
||||
assert(compare(combine(d_u, w_e), d_v));<br>
|
||||
</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Not Relaxed</td>
|
||||
<td><tt>edge_not_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the edge is not relaxed (see above) then
|
||||
this method is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Minimized</td>
|
||||
<td><tt>vis.edge_minimized(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
After the <tt>num_vertices(g)</tt> iterations through the edge set
|
||||
of the graph is complete, one last iteration is made to test whether
|
||||
each edge was minimized. If the edge is minimized then this function
|
||||
is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Not Minimized</td>
|
||||
<td><tt>edge_not_minimized(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
If the edge is not minimized, this function is invoked. This happens
|
||||
when there is a negative cycle in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./bellman_visitor.html"><tt>bellman_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
169
doc/BidirectionalGraph.html
Normal file
@@ -0,0 +1,169 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Bidirectional</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2>
|
||||
<A NAME="concept:BidirectionalGraph"></A>
|
||||
BidirectionalGraph
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The BidirectionalGraph concept refines <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a> and adds the
|
||||
requirement for efficient access to the in-edges of each vertex. This
|
||||
concept is separated from <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a> because for directed
|
||||
graphs efficient access to in-edges typically requires more storage
|
||||
space, and many algorithms do not require access to in-edges. For
|
||||
undirected graphs this is not an issue, since the <TT>in_edges()</TT>
|
||||
and <TT>out_edges()</TT> functions are the same, they both return the
|
||||
edges incident to the vertex.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./IncidenceGraph.html">IncidenceGraph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::in_edge_iterator</pre>
|
||||
An in-edge iterator for a vertex <i>v</i> provides access to the
|
||||
in-edges of <i>v</i>. As such, the value type of an in-edge iterator
|
||||
is the edge descriptor type of its graph. An in-edge iterator must
|
||||
meet the requirements of <a href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</Table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:in-edges"><TT>in_edges(v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Returns an iterator-range providing access to the
|
||||
in-edges (for directed graphs) or incident edges (for
|
||||
undirected graphs) of vertex <TT>v</TT> in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>std::pair<in_edge_iterator, in_edge_iterator></TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>in_degree(v, g)</TT></TD>
|
||||
<TD>
|
||||
Returns the number of in-edges (for directed graphs) or the
|
||||
number of incident edges (for undirected graphs) of vertex <TT>v</TT>
|
||||
in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>degree_size_type</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>degree(v, g)</TT></TD>
|
||||
<TD>Returns the number of in-edges plus out-edges (for directed graphs) or the
|
||||
number of incident edges (for undirected graphs) of vertex <TT>v</TT>
|
||||
in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>degree_size_type</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</Table>
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./adjacency_list.html"><tt>adjacency_list</tt></a> with <tt>Directed=bidirectionalS</tt></li>
|
||||
<li><a href="./adjacency_list.html"><tt>adjacency_list</tt></a> with <tt>Directed=undirectedS</tt></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
The <TT>in_edges()</TT> function is required to be constant time. The
|
||||
<tt>in_degree()</tt> and <tt>degree()</tt> functions must be linear in
|
||||
the number of in-edges (for directed graphs) or incident edges (for
|
||||
undirected graphs).
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct BidirectionalGraph_concept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::in_edge_iterator
|
||||
in_edge_iterator;
|
||||
void constraints() {
|
||||
function_requires< IncidenceGraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<in_edge_iterator> >();
|
||||
|
||||
p = in_edges(v, g);
|
||||
e = *p.first;
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = in_edges(v, g);
|
||||
e = *p.first;
|
||||
}
|
||||
std::pair<in_edge_iterator, in_edge_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor v;
|
||||
typename boost::graph_traits<G>::edge_descriptor e;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
123
doc/Buffer.html
Normal file
@@ -0,0 +1,123 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Buffer</Title>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h3>Buffer Concept</h3>
|
||||
|
||||
A Buffer is something in which items can be put and removed.
|
||||
The Buffer <i>concept</i> has very few requirements. It does
|
||||
not require any particular ordering of how the items are stored or in
|
||||
what order they will appear when removed, however, there is typically
|
||||
some sort of ordering policy.
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<table>
|
||||
<tr> <td> <tt>B</tt> </td> <td> is a type that models Buffer. </td></tr>
|
||||
<tr> <td> <tt>T</tt> </td> <td> is the value type of <tt>B</tt>. </td></tr>
|
||||
<tr> <td> <tt>t</tt> </td> <td> is an object of type <tt>T</tt>. </td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Members</h3>
|
||||
|
||||
For a type to model the Buffer concept it must have the following members.
|
||||
|
||||
<p>
|
||||
|
||||
<table border="1">
|
||||
|
||||
<tr> <td><b>Member</b></td> <td><b>Description</b></td> </tr>
|
||||
|
||||
<tr> <td> <tt>value_type</tt> </td>
|
||||
<td> The type of object stored in the Buffer. The value type
|
||||
must be <A href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>size_type</tt> </td>
|
||||
<td> An unsigned integral type for representing the number of
|
||||
objects in the Buffer.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>void push(const T& t)</tt> </td>
|
||||
<td> Inserts <tt>t</tt> into the Buffer. <tt>size()</tt> will be
|
||||
incremented by one.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>void pop()</tt> </td>
|
||||
<td> Removes an object from the Buffer. <tt>size()</tt> will be
|
||||
decremented by one. Precondition: <tt>empty()</tt>
|
||||
is <tt>false</tt>. </td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>T& top()</tt> </td>
|
||||
<td> Returns a mutable reference to some object in the Buffer.
|
||||
Precondition: <tt>empty()</tt> is <tt>false</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>const T& top() const</tt> </td>
|
||||
<td> Returns a const reference to some object in the Buffer.
|
||||
Precondition: <tt>empty()</tt> is <tt>false</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>void size() const</tt> </td>
|
||||
<td> Returns the number of objects in the Buffer.
|
||||
Invariant: <tt>size() >= 0</tt>. </td>
|
||||
</tr>
|
||||
|
||||
<tr> <td> <tt>bool empty() const</tt> </td>
|
||||
<td> Equivalent to <tt>b.size() == 0</tt>.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Complexity Guarantees</h3>
|
||||
|
||||
<UL>
|
||||
|
||||
<LI> <tt>push()</tt>, <tt>pop()</tt>, and <tt>size()</tt> must be at
|
||||
most linear time complexity in the size of the Generalized Queue.
|
||||
|
||||
<LI> <tt>top()</tt> and <tt>empty()</tt> must be amortized constant time.
|
||||
|
||||
</UL>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<UL>
|
||||
<LI><a href="http://www.sgi.com/Technology/STL/stack.html"><tt>std::stack</tt></a>
|
||||
<LI><a href="../../pri_queue/queue.html"><tt>boost::queue</tt></a>
|
||||
<LI><a href="../../pri_queue/p_queue.html"><tt>boost::priority_queue</tt></a>
|
||||
</UL>
|
||||
|
||||
<p>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>, Univ.of Notre Dame and C++ Library & Compiler Group/SGI (<A HREF="mailto:jsiek@engr.sgi.com">jsiek@engr.sgi.com</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
112
doc/ColorValue.html
Normal file
@@ -0,0 +1,112 @@
|
||||
<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: ColorValue Concept</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="concept:ColorValue"></A>
|
||||
ColorValue
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
This concept describes the requirements for the type used for color
|
||||
values, as in for coloring a graph during a breath-first search to
|
||||
mark which vertices have been visited.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Refinement of</h3> <a
|
||||
href="http://www.sgi.com/Technology/STL/EqualityComparable.html">EqualityComparable</a>
|
||||
and <a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a>
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>T</tt></TD>
|
||||
<TD>A type that is a model of ColorValue.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>cv</tt></TD>
|
||||
<TD>An object of type <tt>T</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Get Color White </td>
|
||||
<TD><TT>white(cv)</TT></TD>
|
||||
<TD><TT>T</TT></TD>
|
||||
<TD>Returns an object that represents the color white.</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td>Get Color Gray </td>
|
||||
<TD><TT>gray(cv)</TT></TD>
|
||||
<TD><TT>T</TT></TD>
|
||||
<TD>Returns an object that represents the color gray.</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td>Get Color Black </td>
|
||||
<TD><TT>black(cv)</TT></TD>
|
||||
<TD><TT>T</TT></TD>
|
||||
<TD>Returns an object that represents the color black.</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><tt>default_color_type</tt> (in <a href="../../../boost/graph/properties.hpp"><tt>boost/graph/properties.hpp</tt>)
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
184
doc/DFSVisitor.html
Normal file
@@ -0,0 +1,184 @@
|
||||
<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>DFSVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>DFSVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./depth_first_search.html"><tt>depth_first_search()</tt></a>.
|
||||
Users can define a class with the DFSVisitor interface and pass and
|
||||
object of the class to <tt>depth_first_search()</tt>, thereby
|
||||
augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of DFSVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every vertex of the graph before the start of the
|
||||
graph search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Start Vertex</td>
|
||||
<td><tt>vis.start_vertex(s, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the source vertex once before the start of the
|
||||
search.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Discover Vertex</td>
|
||||
<td><tt>vis.discover_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked when a vertex is encountered for the first time.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every out-edge of each vertex after it is discovered.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>Tree Edge</td>
|
||||
<td><tt>vis.tree_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on each edge as it becomes a member of the edges that
|
||||
form the search tree.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Back Edge</td>
|
||||
<td><tt>vis.back_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the back edges in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Forward or Cross Edge</td>
|
||||
<td><tt>vis.forward_or_cross_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on forward or cross edges in the graph. In an
|
||||
undirected graph this method is never called.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This invoked on a vertex after all of its out edges have been added to the
|
||||
search tree and all of the adjacent vertices have been discovered
|
||||
(but before their out-edges have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
182
doc/EdgeListGraph.html
Normal file
@@ -0,0 +1,182 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>EdgeListGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:EdgeListGraph"></A>
|
||||
EdgeListGraph
|
||||
</H2>
|
||||
|
||||
The EdgeListGraph concept refines the <a href="./Graph.html">Graph</a>
|
||||
concept, and adds the requirement for efficient access to all the
|
||||
edges in the graph.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of EdgeListGraph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edge_iterator</pre>
|
||||
An edge iterator (obtained via <TT>edges(g)</TT>) provides access to
|
||||
all of the edges in a graph. An edge iterator type must meet the
|
||||
requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. The
|
||||
value type of the edge iterator must be the same as the edge
|
||||
descriptor of the graph.
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edges_size_type</pre>
|
||||
The unsigned integer type used to represent the number of edges in the
|
||||
graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:edges"><TT>edges(g)</TT></a></TD>
|
||||
<TD>Returns an iterator-range providing access to all
|
||||
the edges in the graph <TT>g</TT>.<br>
|
||||
Return type: <TT>std::pair<edge_iterator, edge_iterator></TT>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>num_edges(g)</TT></TD>
|
||||
<TD>Returns the number of edges in the graph <TT>g</TT>.<br>
|
||||
Return type: <TT>edges_size_type</TT>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>source(e, g)</TT></TD>
|
||||
<TD>
|
||||
Returns the vertex descriptor for <i>u</i> of the edge <i>(u,v)</i>
|
||||
represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><TT>target(e, g)</TT></TD>
|
||||
<TD>
|
||||
Returns the vertex descriptor for
|
||||
<i>v</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><a href="./adjacency_list.html"><TT>adjacency_list</TT></a></LI>
|
||||
<LI><a href="./edge_list.html"><TT>edge_list</TT></a></LI>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
The <TT>edges()</TT>, <TT>source()</TT>, and <TT>target()</TT> functions
|
||||
must all return in constant time.
|
||||
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct EdgeListGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_iterator
|
||||
edge_iterator;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<edge_iterator> >();
|
||||
|
||||
p = edges(g);
|
||||
E = num_edges(g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = edges(g);
|
||||
E = num_edges(g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
std::pair<edge_iterator,edge_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::edge_descriptor e;
|
||||
typename boost::graph_traits<G>::edges_size_type E;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
165
doc/EventVisitor.html
Normal file
@@ -0,0 +1,165 @@
|
||||
<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: EventVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>EventVisitor Concept</H1>
|
||||
|
||||
This concept defines the interface for single-event visitors. An
|
||||
EventVisitor has an apply member function (<tt>operator()</tt>) which
|
||||
is invoked within the graph algorithm at the event-point specified by
|
||||
the <tt>event_filter</tt> typedef within the
|
||||
EventVisitor. EventVisitor's can be combined into an <a
|
||||
href="./EventVisitorList.html">EventVistorList</a>.
|
||||
|
||||
<p>
|
||||
The following is the list of event tags that can be invoked in BGL
|
||||
algorithms. Each tag corresponds to a member function of the visitor
|
||||
for an algorithm. For example, the <a
|
||||
href="./BFSVisitor.html">BFSVisitor</a> of <a
|
||||
href="./breadth_first_search.html"><tt>breadth_first_search()</tt></a>
|
||||
has a <tt>cycle_edge()</tt> member function. The corresponding tag is
|
||||
<tt>on_cycle_edge</tt>. The first argument is the event visitor's
|
||||
<tt>operator()</tt> must be either an edge or vertex descriptor
|
||||
depending on the event tag.
|
||||
|
||||
<pre>
|
||||
namespace boost {
|
||||
struct on_initialize_vertex { };
|
||||
struct on_start_vertex { };
|
||||
struct on_discover_vertex { };
|
||||
struct on_examine_edge { };
|
||||
struct on_tree_edge { };
|
||||
struct on_cycle_edge { };
|
||||
struct on_finish_vertex { };
|
||||
struct on_forward_or_cross_edge { };
|
||||
struct on_back_edge { };
|
||||
struct on_edge_relaxed { };
|
||||
struct on_edge_not_relaxed { };
|
||||
struct on_edge_minimized { };
|
||||
struct on_edge_not_minimized { };
|
||||
} // namespace boost
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of <a href="./Graph.html">Graph</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of EventVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>x</tt></TD>
|
||||
<TD>An object of type
|
||||
<tt>boost::graph_traits<G>::vertex_descriptor</tt>
|
||||
or <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD>Event Filter </TD>
|
||||
<TD><TT>V::event_filter</TT></TD>
|
||||
<TD>
|
||||
A tag struct to specify on which event the visitor should be invoked.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Apply Visitor</td>
|
||||
<td><TT>vis(x, g)</TT></TD>
|
||||
<TD><TT>void</TT></TD>
|
||||
<TD>
|
||||
Invokes the visitor operation on object <tt>x</tt>, which is
|
||||
either a vertex or edge descriptor of the graph.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>
|
||||
<li><a href="./distance_recorder.html"><tt>distance_recorder</tt></a>
|
||||
<li><a href="./time_stamper.html"><tt>time_stamper</tt></a>
|
||||
<li><a href="./property_writer.html"><tt>property_writer</tt></a>
|
||||
<li><a href="./null_visitor.html"><tt>null_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./EventVisitorList.html">EventVisitorList</a>,
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
131
doc/EventVisitorList.html
Normal 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: EventVisitorList</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>EventVisitorList Concept</H1>
|
||||
|
||||
An EventVisitorList is either an <a
|
||||
href="./EventVisitor.html">EventVisitor</a>, or a list of
|
||||
EventVisitor's combined using <tt>std::pair</tt>. Each graph algorithm
|
||||
defines visitor adaptors that convert an EventVisitorList into the
|
||||
particular kind of visitor needed by the algorithm.
|
||||
|
||||
In the following example we will show how to combine event visitors
|
||||
into a list using <tt>std::pair</tt> and how to use an algorithm's
|
||||
visitor adaptor class.
|
||||
|
||||
<p>
|
||||
Suppose we would like to print out the parenthesis
|
||||
structure of the discover/finish times of vertices in a <a
|
||||
href="./graph_theory_review.html#sec:dfs-algorithm">depth-first
|
||||
search</a>. We can use the BGL algorithm <a
|
||||
href="./depth_first_search.html"><tt>depth_first_search()</tt></a> and
|
||||
two event visitors to accomplish this. The complete source code for
|
||||
the following example is in <a href="../example/dfs_parenthesis.cpp">
|
||||
<tt>examples/dfs_parenthesis.cpp</tt></a>. First we define the two
|
||||
event visitors. We use <tt>on_discover_vertex</tt> and
|
||||
<tt>on_finish_vertex</tt> as the event points, selected from the list
|
||||
of event points specified in <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
|
||||
<pre>
|
||||
struct open_paren : public base_visitor<open_paren> {
|
||||
typedef on_discover_vertex event_filter;
|
||||
template <class Vertex, class Graph>
|
||||
void operator()(Vertex v, Graph& G) {
|
||||
std::cout << "(" << v;
|
||||
}
|
||||
};
|
||||
struct close_paren : public base_visitor<close_paren> {
|
||||
typedef on_finish_vertex event_filter;
|
||||
template <class Vertex, class Graph>
|
||||
void operator()(Vertex v, Graph& G) {
|
||||
std::cout << v << ")";
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
|
||||
Next we create two event visitor objects and make an EventVisitorList
|
||||
out of them using a <tt>std::pair</tt> which created by
|
||||
<tt>std::make_pair</tt>.
|
||||
|
||||
<pre>
|
||||
std::make_pair(open_paren(), close_paren())
|
||||
</pre>
|
||||
|
||||
Next we want to pass this list into <tt>depth_first_search()</tt>, but
|
||||
<tt>depth_first_search()</tt> is expecting a <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>, not a EventVisitorList. We
|
||||
therefore use the <a
|
||||
href="./dfs_visitor.html"><tt>dfs_visitor</tt></a> adaptor which turns
|
||||
an EventVisitor list into a DFSVisitor. Like all of the visitor
|
||||
adaptors, <tt>dfs_visitor</tt> has a creation function called
|
||||
<tt>make_dfs_visitor()</tt>.
|
||||
|
||||
<pre>
|
||||
make_dfs_visitor(std::make_pair(open_paren(), close_paren()))
|
||||
</pre>
|
||||
|
||||
Now we can pass the resulting visitor object into
|
||||
<tt>depth_first_search()</tt> as follows.
|
||||
|
||||
<pre>
|
||||
// graph object G is created ...
|
||||
|
||||
std::vector<default_color_type> color(num_vertices(G));
|
||||
|
||||
depth_first_search(G, make_dfs_visitor(std::make_pair(open_paren(), close_paren())),
|
||||
color.begin());
|
||||
</pre>
|
||||
|
||||
For creating a list of more than two event visitors, nest calls to
|
||||
<tt>std::make_pair</tt> in the following way:
|
||||
|
||||
<pre>
|
||||
std::make_pair(<i>visitor1</i>,
|
||||
std::make_pair(<i>visitor2</i>,
|
||||
...
|
||||
std::make_pair(<i>visitorN-1</i>, <i>visitorN</i>)...));
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./EventVisitor.html">EventVisitor</a>,
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
133
doc/Graph.html
Normal file
@@ -0,0 +1,133 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Graph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:Graph"></A>
|
||||
Graph
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The Graph concept contains a few requirements that are common to all
|
||||
the graph concepts. These include some associated types for
|
||||
<tt>vertex_descriptor</tt>, <tt>edge_descriptor</tt>, etc., and the
|
||||
<tt>num_vertices()</tt> and <tt>num_edges()</tt> functions. One should
|
||||
note that a model of Graph is <B>not</B> required to be a model of <a
|
||||
href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>,
|
||||
so algorithms should pass graph objects by reference.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::vertex_descriptor</pre>
|
||||
A vertex descriptor corresponds to a unique vertex in an abstract
|
||||
graph instance. A vertex descriptor must be
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a>,
|
||||
<a href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>, and
|
||||
<a href="http://www.sgi.com/Technology/STL/EqualityComparable.html">EqualityComparable</a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edge_descriptor</pre>
|
||||
An edge descriptor corresponds to a unique edge <i>(u,v)</i> in a
|
||||
graph. An edge descriptor must be <a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</I>,
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>,
|
||||
and <a href="http://www.sgi.com/Technology/STL/EqualityComparable.html">EqualityComparable</a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::directed_category</pre>
|
||||
The choices are <TT>directed_tag</TT> and <TT>undirected_tag</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::edge_parallel_category</pre>
|
||||
This describes whether the graph class allows the insertion of
|
||||
parallel edges (edges with the same source and target). The two tags
|
||||
are <TT>allow_parallel_edge_tag</TT> and <TT>disallow_parallel_edge_tag</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
None required.
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct GraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
typedef typename boost::graph_traits<G>::directed_category directed_category;
|
||||
typedef typename boost::graph_traits<G>::edge_parallel_category edge_parallel_category;
|
||||
|
||||
void constraints() {
|
||||
function_requires< DefaultConstructibleConcept<vertex_descriptor> >();
|
||||
function_requires< EqualityComparableConcept<vertex_descriptor> >();
|
||||
function_requires< AssignableConcept<vertex_descriptor> >();
|
||||
function_requires< DefaultConstructibleConcept<edge_descriptor> >();
|
||||
function_requires< EqualityComparableConcept<edge_descriptor> >();
|
||||
function_requires< AssignableConcept<edge_descriptor> >();
|
||||
}
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
181
doc/IncidenceGraph.html
Normal file
@@ -0,0 +1,181 @@
|
||||
<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>IncidenceGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="concept:IncidenceGraph"></A>
|
||||
IncidenceGraph
|
||||
</H1>
|
||||
|
||||
The IncidenceGraph concept provides an interface for
|
||||
efficient access to the out-edges of each vertex in the graph.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of IncidenceGraph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD>
|
||||
<pre>boost::graph_traits<G>::out_edge_iterator</pre>
|
||||
An out-edge iterator for a vertex <i>v</i> provides access to the
|
||||
out-edges of the vertex. As such, the value type of an out-edge
|
||||
iterator is the edge descriptor type of its graph. An out-edge
|
||||
iterator must meet the requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::degree_size_type</pre>
|
||||
The unsigned intergral type used for representing the number
|
||||
out-edges or incident edges of a vertex.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:source"><TT>source(e, g)</TT></a></TD>
|
||||
<TD>Returns the vertex descriptor for <i>u</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:target"><TT>target(e, g)</TT></a></TD>
|
||||
<TD>Returns the vertex descriptor for <i>v</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:out-edges"><TT>out_edges(v, g)</TT></a></TD>
|
||||
<TD>Returns an iterator-range providing access to the
|
||||
out-edges (for directed graphs) or incident edges (for
|
||||
undirected graphs) of vertex <TT>v</TT> in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>std::pair<out_edge_iterator, out_edge_iterator></TT>
|
||||
</TD>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><TT>out_degree(v, g)</TT></TD>
|
||||
<TD>Returns the number of out-edges (for directed graphs) or the
|
||||
number of incident edges (for undirected graphs) of vertex <TT>v</TT>
|
||||
in graph <TT>g</TT>.<br>
|
||||
Return type: <TT>degree_size_type</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
<P>
|
||||
The <TT>source()</TT>, <TT>target()</TT>, and <TT>out_edges()</TT>
|
||||
functions must all be constant time. The <tt>out_degree()</tt>
|
||||
function must be linear in the number of out-edges.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct IncidenceGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::out_edge_iterator out_edge_iterator;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<out_edge_iterator> >();
|
||||
|
||||
p = out_edges(v, g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = out_edges(v, g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
std::pair<out_edge_iterator, out_edge_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::edge_descriptor e;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
292
doc/MutableGraph.html
Normal file
@@ -0,0 +1,292 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>MutableGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="sec:MutableGraph"></A>
|
||||
MutableGraph
|
||||
</H2>
|
||||
|
||||
A MutableGraph can be changed via the addition or removal of
|
||||
edges and vertices.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>u,v</tt></TD>
|
||||
<TD>are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>iter</tt></TD>
|
||||
<TD>is an object of type <tt>boost::graph_traits<G>::out_edge_iterator</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>p</tt></TD>
|
||||
<TD>is an object of a type that models <a
|
||||
href="http://www.sgi.com/Technology/STL/Predicate.html">Predicate</a>
|
||||
and whose argument type matches the <tt>edge_descriptor</tt> type.
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:add-edge"><TT>add_edge(u, v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Inserts the edge <i>(u,v)</i> into the graph.<br>
|
||||
Return type: <TT>std::pair<edge_descriptor, bool></TT>
|
||||
</TD>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:remove_edge"><TT>remove_edge(u, v, g)</TT></a></TD>
|
||||
<TD>
|
||||
Remove the edge <i>(u,v)</i> from the graph. If the
|
||||
graph allows parallel edges this remove all occurances of
|
||||
<i>(u,v)</i>.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <i>u</i> and <i>v</i> are vertices in the graph.<br>
|
||||
Postcondition: <i>(u,v)</i> is no longer in the edge set for
|
||||
<TT>g</TT>.<br>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_edge(e, g)</TT></TD>
|
||||
<TD>Remove the edge <i>e</i> from the graph.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <i>e</i> is an edge in the graph.<br>
|
||||
Postcondition: <i>e</i> is no longer in the edge set for <TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_edge(iter, g)</TT></TD>
|
||||
<TD>Remove the edge pointed to be <tt>iter</tt> from the graph. This
|
||||
expression is only required when the graph also models <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <tt>*iter</tt> is an edge in the graph.<br>
|
||||
Postcondition: <tt>*iter</tt> is no longer in the edge set for <TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_edge_if(p, g)</TT></TD>
|
||||
<TD>Remove all the edges from graph <tt>g</tt> for which
|
||||
the predicate <tt>p</tt> returns true.<br>
|
||||
Return type: <TT>void</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_out_edge_if(u, p, g)</TT></TD>
|
||||
<TD>Remove all the out-edges of vertex <tt>u</tt> for which the
|
||||
predicate <tt>p</tt> returns true. This expression is only required
|
||||
when the graph also models <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
|
||||
Return type: <TT>void</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>remove_in_edge_if(u, p, g)</TT></TD>
|
||||
<TD>Remove all the in-edges of vertex <tt>u</tt> for which the
|
||||
predicate <tt>p</tt> returns true. This expression is only required when the
|
||||
graph also models <a
|
||||
href="./BidirectionalGraph.html">BidirectionalGraph</a>.<br>
|
||||
Return type: <TT>void</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:add-vertex"><TT>add_vertex(g)</TT></a></TD>
|
||||
<TD>
|
||||
Add a new vertex to the graph. The <TT>vertex_descriptor</TT> for the
|
||||
new vertex is returned.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<tr>
|
||||
<TD><TT>clear_vertex(u, g)</TT></TD>
|
||||
<TD>
|
||||
Remove all edges to and from vertex <tt>u</tt> from the graph.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <tt>u</tt> is a valid vertex descriptor of <TT>g</TT>.<br>
|
||||
Postcondition: <tt>u</tt> does not appear as a source or target of
|
||||
any edge in <TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><a name="sec:remove-vertex"><TT>remove_vertex(u, g)</TT></a></TD>
|
||||
<TD>
|
||||
Remove <i>u</i> from the vertex set of the graph. Note that undefined
|
||||
behavior may result if there are edges remaining in the graph who's
|
||||
target is <i>u</i>. Typically the <TT>clear_vertex()</TT> function
|
||||
should be called first.<br>
|
||||
Return type: <TT>void</TT><br>
|
||||
Precondition: <TT>u</TT> is a valid vertex descriptor of <TT>g</TT>.<br>
|
||||
Postcondition: <TT>num_vertices(g)</TT> is one less, <TT>u</TT>
|
||||
no longer appears in the vertex set of the graph and it
|
||||
is no longer a valid vertex descriptor.
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity Guarantees</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>Edge insertion must be either amortized constant time or it
|
||||
can be <i>O(log(E/V))</i> if the insertion also checks to
|
||||
prevent the addition of parallel edges (which is a ``feature'' of
|
||||
some graph types).
|
||||
</LI>
|
||||
<LI>Edge removal is guaranteed to be <i>O(E)</i>.</LI>
|
||||
<LI>Vertex insertion is guaranteed to be amortized constant time.</LI>
|
||||
<LI>Clearing a vertex is <i>O(E + V)</i>.</LI>
|
||||
<LI>Vertex removal is <i>O(E + V)</i>.</LI>
|
||||
</UL>
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct MutableGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
v = add_vertex(g);
|
||||
clear_vertex(v, g);
|
||||
remove_vertex(v, g);
|
||||
e_b = add_edge(u, v, g);
|
||||
remove_edge(u, v, g);
|
||||
remove_edge(e, g);
|
||||
}
|
||||
G g;
|
||||
edge_descriptor e;
|
||||
std::pair<edge_descriptor, bool> e_b;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::out_edge_iterator iter;
|
||||
};
|
||||
|
||||
template <class edge_descriptor>
|
||||
struct dummy_edge_predicate {
|
||||
bool operator()(const edge_descriptor& e) const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableIncidenceGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< MutableGraph<G> >();
|
||||
remove_edge(iter, g);
|
||||
remove_out_edge_if(u, p, g);
|
||||
}
|
||||
G g;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
dummy_edge_predicate<edge_descriptor> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u;
|
||||
typename boost::graph_traits<G>::out_edge_iterator iter;
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableBidirectionalGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< MutableIncidenceGraph<G> >();
|
||||
remove_in_edge_if(u, p, g);
|
||||
}
|
||||
G g;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
dummy_edge_predicate<edge_descriptor> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u;
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableEdgeListGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< MutableGraph<G> >();
|
||||
remove_edge_if(p, g);
|
||||
}
|
||||
G g;
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
dummy_edge_predicate<edge_descriptor> p;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
154
doc/MutablePropertyGraph.html
Normal file
@@ -0,0 +1,154 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>MutablePropertyGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
|
||||
<H2>
|
||||
<A NAME="sec:MutablePropertyGraph"></A>
|
||||
MutablePropertyGraph
|
||||
</H2>
|
||||
|
||||
A MutablePropertyGraph is a <a
|
||||
href="./MutableGraph.html">MutableGraph</a> with properties attached
|
||||
internally to the vertices and edges. When adding vertices and edges
|
||||
the value of the properties can be given.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./MutableGraph.html">MutableGraph</a> and
|
||||
<a href="./PropertyGraph.html">PropertyGraph</a>
|
||||
|
||||
<H3>Notation</H3>
|
||||
|
||||
|
||||
<TABLE>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>u,v</tt></TD>
|
||||
<TD>are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><TT>ep</TT></TD><TD>is an object of type <TT>G::edge_property_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><TT>vp</TT></TD><TD>is an object of type <TT>G::vertex_property_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td>Edge Property Type </td>
|
||||
<td><TT>graph_traits<G>::edge_property_type</TT></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Vertex Property Type </td>
|
||||
<td><TT>graph_traits<G>::vertex_property_type</TT> </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<TD><TT>add_edge(g, u, v, ep)</TT></TD>
|
||||
<TD>Inserts the edge <i>(u,v)</i> into the graph, and
|
||||
copies object <TT>ep</TT> into the property property for that edge.<br>
|
||||
Return type: <TT>std::pair<edge_descriptor, bool></TT></TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>add_vertex(g, vp)</TT></TD>
|
||||
<TD>
|
||||
Add a new vertex to the graph and copy <TT>vp</TT> into the property
|
||||
property for the new vertex. The <TT>vertex_descriptor</TT> for the new
|
||||
vertex is returned.<br>
|
||||
Return type: <TT>vertex_descriptor</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT></LI>
|
||||
</UL>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct MutablePropertyGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
function_requires< MutableGraphConcept<G> >();
|
||||
v = add_vertex(g, vp);
|
||||
p = add_edge(g, u, v, ep);
|
||||
}
|
||||
G g;
|
||||
std::pair<edge_descriptor, bool> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor u, v;
|
||||
typename boost::graph_traits<G>::vertex_property_type vp;
|
||||
typename boost::graph_traits<G>::edge_property_type ep;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
105
doc/Property.html
Normal file
@@ -0,0 +1,105 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Property</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:Property"></A>
|
||||
Property
|
||||
</H2>
|
||||
|
||||
A Property type is a type used to name or identify properties that are
|
||||
attached to the vertices and edges of a graph. A Property type is not
|
||||
the type of the actual property values. Objects of the Property type
|
||||
are not used except to carry the type information which specifies the
|
||||
property.
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td>Property Kind </td>
|
||||
<td><TT>property_kind<Property>::type</TT> </td>
|
||||
<td>
|
||||
|
||||
This specifies whether the property is a <a
|
||||
name="VertexProperty">VertexProperty</a>
|
||||
(<tt>vertex_property_tag</tt>), an <a
|
||||
name="EdgeProperty">EdgeProperty</a> (<tt>edge_property_tag</tt>), or
|
||||
a <a name="GraphProperty">GraphProperty</a> which is attached to the
|
||||
graph object itself (<tt>graph_property_tag</tt>). The tags are
|
||||
defined in <a
|
||||
href="../../../boost/graph/properties.hpp"><tt>boost/graph/properties.hpp</tt></a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
The following models of the Property concept are defined
|
||||
in <a
|
||||
href="../../../boost/graph/properties.hpp"><tt>boost/graph/properties.hpp</tt></a>.
|
||||
|
||||
<ul>
|
||||
<li><tt>vertex_index_t</tt></li>
|
||||
<li><tt>edge_index_t</tt></li>
|
||||
<li><tt>graph_name_t</tt></li>
|
||||
<li><tt>vertex_name_t</tt></li>
|
||||
<li><tt>edge_name_t</tt></li>
|
||||
<li><tt>edge_weight_t</tt></li>
|
||||
<li><tt>vertex_distance_t</tt></li>
|
||||
<li><tt>vertex_color_t</tt></li>
|
||||
<li><tt>vertex_degree_t</tt></li>
|
||||
<li><tt>vertex_out_degree_t</tt></li>
|
||||
<li><tt>vertex_in_degree_t</tt></li>
|
||||
<li><tt>vertex_discover_time_t</tt></li>
|
||||
<li><tt>vertex_finish_time_t</tt></li>
|
||||
</ul>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./PropertyGraph.html">PropertyGraph</a>
|
||||
and
|
||||
<a href="../../property_map/property_map.html">Property Map Concepts</a>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
On compilers that do not support partial specialization, each Property
|
||||
type is also required to specialize
|
||||
<tt>property_num<Property></tt> to contain an enum named
|
||||
<tt>value</tt> which uniquely identifies the property type.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
213
doc/PropertyGraph.html
Normal file
@@ -0,0 +1,213 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>PropertyGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:PropertyGraph"></A>
|
||||
PropertyGraph
|
||||
</H2>
|
||||
|
||||
A PropertyGraph is a graph that has some property associated with each
|
||||
of the vertices or edges in the graph. As a given graph may have
|
||||
several properties associated with each vertex or edge, a tag is used
|
||||
to identity which property is being accessed. The graph provides a
|
||||
function which returns a property map object.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of PropertyGraph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>X</tt></TD>
|
||||
<TD>Either the vertex or edge descriptor type for <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>x</tt></TD>
|
||||
<TD>An object of type <tt>X</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR>
|
||||
<TD><tt>Map</tt></TD>
|
||||
<TD>The type <tt>boost::property_map<G, Property>::const_type</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>v</tt></TD>
|
||||
<TD>An object of type <tt>boost::property_traits<Map>::value_type</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>Property</tt></TD>
|
||||
<TD>A type that models the <a href="./Property.html">Property</a> concept.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>p</tt></TD>
|
||||
<TD>An object of type <tt>Property</tt>.</td>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>pmap</tt></TD>
|
||||
<TD>An object of type <tt>Map</tt>.</td>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated types</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::property_map<G, Property>::type</pre>
|
||||
The type of the property map for the property specified by
|
||||
<TT>Property</TT>. This type must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a> with a key type the same as the graph's vertex or descriptor type.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::property_map<G, Property>::const_type</pre>
|
||||
The type of the const property map for the property specified by
|
||||
<TT>Property</TT>. This type must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>
|
||||
with a key type the same as the graph's vertex or edge descriptor type.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td> <TT>get(p, g)</TT> </td>
|
||||
<td>
|
||||
Returns the property map for the property specified by the
|
||||
<tt>Property</tt> type. The object <tt>p</tt> is only used to
|
||||
carry the type.<br>
|
||||
Return type: <TT>boost::property_map<G, Property>::type</TT> if <TT>g</TT> is mutable and <br><TT>boost::property_map<G, Property>::const_type</TT> otherwise.
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td> <TT>get(p, g, x)</TT> </td>
|
||||
<td>
|
||||
Returns the property value (specified by the <tt>Property</tt> type)
|
||||
associated with object <tt>x</tt> (a vertex or edge).
|
||||
The object <tt>p</tt> is only used to carry the type.
|
||||
This function is equivalent to:<br>
|
||||
<tt>get(get(p, g), x)</tt><br>
|
||||
Return type: <tt>boost::property_traits<Map>::value_type</tt>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td> <TT>put(p, g, x, v)</TT> </td>
|
||||
<td>
|
||||
Set the property (specified by the <tt>Property</tt> type)
|
||||
associated with object <tt>x</tt> (a vertex or edge) to
|
||||
the value <tt>v</tt>. The object <tt>p</tt> is only used to carry the type.
|
||||
This function is equivalent to:<br>
|
||||
<tt>
|
||||
pmap = get(p, g);<br>
|
||||
put(pmap, x, v)
|
||||
</tt><br>
|
||||
Return type: <TT>void</TT>
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
|
||||
</TABLE>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
The <tt>get()</tt> property map function must be constant time.
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
|
||||
<UL>
|
||||
<LI><tt>adjacency_list</tt> with <tt>VertexProperty=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></tt> and <tt>Property=vertex_distance_t</tt>.</li>
|
||||
<li><tt>adjacency_list</tt> with <tt>VertexProperty=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></TT> and <tt>Property=vertex_in_degree_t</tt>.</li>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class Graph, class X, class Property>
|
||||
struct PropertyGraphConcept
|
||||
{
|
||||
typedef typename property_map<G, Property>::type Map;
|
||||
typedef typename property_map<G, Property>::const_type const_Map;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< ReadWritePropertyMapConcept<Map, X> >();
|
||||
function_requires< ReadablePropertyMapConcept<const_Map, X> >();
|
||||
|
||||
Map pmap = get(Property(), g);
|
||||
pval = get(Property(), g, x);
|
||||
put(Property(), g, x, pval);
|
||||
ignore_unused_variable_warning(pmap);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
const_Map pmap = get(Property(), g);
|
||||
pval = get(Property(), g, x);
|
||||
ignore_unused_variable_warning(pmap);
|
||||
}
|
||||
G g;
|
||||
X x;
|
||||
typename property_traits<Map>::value_type pval;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./property_map.html"><tt>property_map</tt></a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
199
doc/UniformCostVisitor.html
Normal file
@@ -0,0 +1,199 @@
|
||||
<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: UniformCostVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>UniformCostVisitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./uniform_cost_search.html"><tt>uniform_cost_search()</tt></a>
|
||||
and related algorithms. The user can create a class that matches this
|
||||
interface, and then pass objects of the class into
|
||||
<tt>uniform_cost_search()</tt> to augment the actions taken during the
|
||||
search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of UniformCostVisitor.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>vis</tt></TD>
|
||||
<TD>An object of type <tt>V</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>s,u,v</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>DistanceMap</tt></TD>
|
||||
<TD>A type that is a model of <a href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>d</tt></TD>
|
||||
<TD>An object of type <tt>DistanceMap</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>WeightMap</tt></TD>
|
||||
<TD>A type that is a model of <a href="../../property_map/ReadWritePropertyMap.html">ReadablePropertyMap</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>w</tt></TD>
|
||||
<TD>An object of type <tt>DistanceMap</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
none
|
||||
<p>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Initialize Vertex</td>
|
||||
<td><tt>vis.initialize_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked one each vertex of the graph when it is initialized.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Start Vertex</td>
|
||||
<td><tt>vis.start_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on the source vertex at the beginning of the algorithm.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Discover Vertex</td>
|
||||
<td><tt>vis.discover_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked when a vertex is encountered for the first time.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Edge</td>
|
||||
<td><tt>vis.examine_edge(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on every out-edge of each vertex after it is discovered.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Relaxed</td>
|
||||
<td><tt>vis.edge_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the following condition holds then the edge
|
||||
is relaxed (its distance is reduced), and this method is invoked.<br>
|
||||
<tt>
|
||||
tie(u,v) = incident(e, g);<br>
|
||||
D d_u = get(d, u), d_v = get(d, v);<br>
|
||||
W w_e = get(w, e);<br>
|
||||
assert(compare(combine(d_u, w_e), d_v));<br>
|
||||
</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Edge Not Relaxed</td>
|
||||
<td><tt>vis.edge_not_relaxed(e, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
Upon examination, if the edge is not relaxed (see above) then
|
||||
this method is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This invoked on a vertex after all of its out edges have been added to the
|
||||
search tree and all of the adjacent vertices have been discovered
|
||||
(but before their out-edges have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./ucs_visitor.html"><tt>ucs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
74
doc/VertexAndEdgeListGraph.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>VertexAndEdgeListGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:VertexAndEdgeListGraph"></A>
|
||||
VertexAndEdgeListGraph
|
||||
</H2>
|
||||
|
||||
The VertexAndEdgeListGraph concept refines the <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a> and the <a
|
||||
href="./EdgeListGraph.html">EdgeListGraph</a> concepts. No further
|
||||
requirements are added.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./VertexListGraph.html">VertexListGraph</a>,
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a>
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT></LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct VertexAndEdgeListGraph
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< VertexListGraphConcept<G> >();
|
||||
function_requires< EdgeListGraphConcept<G> >();
|
||||
}
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
136
doc/VertexListGraph.html
Normal file
@@ -0,0 +1,136 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>VertexListGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:VertexListGraph">
|
||||
VertexListGraph
|
||||
</H2>
|
||||
|
||||
The VertexListGraph</I> concept refines the <a
|
||||
href="./AdjacencyGraph.html">AdjacencyGraph</a> concept, and adds the
|
||||
requirement for efficient traversal of all the vertices in the graph.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./AdjacencyGraph.html">AdjacencyGraph</a>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<TR>
|
||||
<TD><tt>boost::graph_traits<G>::vertex_iterator</tt><br><br>
|
||||
A vertex iterator (obtained via <TT>vertices(g)</TT>) provides access
|
||||
to all of the vertices in a graph. A vertex iterator type must meet
|
||||
the requirements of <a
|
||||
href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. The
|
||||
value type of the vertex iterator must be the vertex descriptor of the
|
||||
graph.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td><tt>boost::graph_traits<G>::vertices_size_type</tt><br><br>
|
||||
The unsigned integer type used to represent the number of vertices
|
||||
in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Vertex Set of the Graph</td>
|
||||
<td><a name="sec:vertices"><TT>vertices(g)</TT></a></TD>
|
||||
<TD><TT>std::pair<vertex_iterator, vertex_iterator></TT></TD>
|
||||
<TD>
|
||||
Returns an iterator-range providing access to all the vertices in the
|
||||
graph<TT>g</TT>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td>Number of Vertices in the Graph </td>
|
||||
<td><TT>num_vertices(g)</TT></TD>
|
||||
<TD><TT>vertices_size_type</TT></TD>
|
||||
<TD>Returns the number of vertices in the graph <TT>g</TT>.</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
<P>
|
||||
The <TT>vertices()</TT> function must return in constant time.
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class G>
|
||||
struct VertexListGraphConcept
|
||||
{
|
||||
typedef typename boost::graph_traits<G>::vertex_iterator
|
||||
vertex_iterator;
|
||||
void constraints() {
|
||||
function_requires< AdjacencyGraphConcept<G> >();
|
||||
function_requires< MultiPassInputIteratorConcept<vertex_iterator> >();
|
||||
|
||||
p = vertices(g);
|
||||
V = num_vertices(g);
|
||||
v = *p.first;
|
||||
const_constraints(g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = vertices(g);
|
||||
V = num_vertices(g);
|
||||
v = *p.first;
|
||||
}
|
||||
std::pair<vertex_iterator, vertex_iterator> p;
|
||||
typename boost::graph_traits<G>::vertex_descriptor v;
|
||||
typename boost::graph_traits<G>::vertices_size_type V;
|
||||
G g;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
80
doc/acknowledgements.html
Normal file
@@ -0,0 +1,80 @@
|
||||
<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: Acknowledgements</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<h1>Acknowledgements</h1>
|
||||
|
||||
We owe many debts of thanks to a number of individuals who both
|
||||
inspired and encouraged us in developing the Boost Graph Library.
|
||||
|
||||
<p>
|
||||
A most profound thanks goes to Alexander Stepanov for his pioneering
|
||||
work in generic programming, for his encouragement, and for his
|
||||
algorithm contributions to the BGL. We thank Matthew Austern for his
|
||||
work on documenting the concepts of STL which provided a foundation
|
||||
for creating the concepts in the BGL. We thank Dietmar Kühl for
|
||||
his work on generic graph algorithms and design patterns; especially
|
||||
for the property map abstraction.
|
||||
|
||||
<p>
|
||||
Dave Abrahams, Jens Maurer, Beman Dawes, Gary Powell, Greg Colvin,
|
||||
Valentin Bonnard, and the rest of the group at Boost provided valuable
|
||||
input to the BGL interface, numerous suggestions for improvement,
|
||||
proof reads of the documentation, and help with polishing the code. A
|
||||
special thanks to Dave Abrahams for managing the formal review.
|
||||
|
||||
<p>
|
||||
We also thank the following BGL users whose questions helped to
|
||||
improve the BGL: Gordon Woodhull, Dave Longhorn, Joel Phillips, and
|
||||
Edward Luke.
|
||||
|
||||
<p>
|
||||
A special thanks to Jeffrey Squyres for editing and proof reading
|
||||
of the documentation.
|
||||
|
||||
<p>
|
||||
Our original work on the Boost Graph Library was supported in part by
|
||||
NSF grant ACI-9982205 and by the Director, Office of Science, Division
|
||||
of Mathematical, Information, and Computational Sciences of the U.S.
|
||||
Department of Energy under contract number DE-AC03-76SF00098.
|
||||
<p>
|
||||
In our work we also used resources of the National Energy Research
|
||||
Scientific Computing Center, which is supported by the Office of
|
||||
Science of the U.S. Department of Energy.
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
1019
doc/adjacency_list.html
Normal file
162
doc/adjacency_list_traits.html
Normal file
@@ -0,0 +1,162 @@
|
||||
<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: Graph Traits</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME=""></A>
|
||||
<pre>
|
||||
adjacency_list_traits<EdgeList, VertexList, Directed>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This class provides an alternate method for accessing some of the
|
||||
associated types of the <tt>adjacency_list</tt> class. The main reason
|
||||
for this class is that sometimes one would like to create graph
|
||||
properties whose values are vertex or edge descriptors. If you try to
|
||||
use <tt>graph_traits</tt> for this you will run into a problem with
|
||||
mutually recursive types. To get around this problem, the
|
||||
<tt>adjacency_list_traits</tt> class is provided, which gives the user
|
||||
access to the vertex and edge descriptor types without requiring the
|
||||
user to provide the property types for the graph.
|
||||
|
||||
<pre>
|
||||
template <class EdgeList, class VertexList, class Directed>
|
||||
struct adjacency_list_traits {
|
||||
typedef ... vertex_descriptor;
|
||||
typedef ... edge_descriptor;
|
||||
typedef ... directed_category;
|
||||
typedef ... edge_parallel_category;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/adjacency_list.hpp"><tt>boost/graph/adjacency_list.hpp</tt></a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EdgeList</TT></TD>
|
||||
<TD>
|
||||
The selector type for the edge container implementation.
|
||||
</TD>
|
||||
<td><tt>vecS</tt></td>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>VertexList</TT></TD>
|
||||
<TD>
|
||||
The selector type for the vertex container implementation.
|
||||
</TD>
|
||||
<td><tt>vecS</tt></td>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>Directed</TT></TD>
|
||||
<TD>
|
||||
The selector type whether the graph is directed or undirected.
|
||||
</TD>
|
||||
<td><tt>directedS</tt></td>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a> and
|
||||
<a href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>
|
||||
|
||||
<h3>Type Requirements</h3>
|
||||
|
||||
Under construction.
|
||||
|
||||
<H2>Members</H2>
|
||||
|
||||
<p>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Member</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
vertex_descriptor
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the objects used to identify vertices in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_descriptor
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the objects used to identify edges in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
directed_category
|
||||
</tt></td>
|
||||
<td>
|
||||
This says whether the graph is undirected (<tt>undirected_tag</tt>)
|
||||
or directed (<tt>directed_tag</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_parallel_category
|
||||
</tt></td>
|
||||
<td>
|
||||
This says whether the graph allows parallel edges to be inserted
|
||||
(<tt>allow_parallel_edge_tag</tt>) or if it automatically removes
|
||||
parallel edges (<tt>disallow_parallel_edge_tag</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./adjacency_list.html"><tt>adjacency_list</tt></a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
180
doc/bellman_ford_shortest.html
Normal file
@@ -0,0 +1,180 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Bellman Ford Shortest Paths</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="sec:bellman-ford"></A>
|
||||
<TT>bellman_ford_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed or undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">distance, weight</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(V E)</i></TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/bellman_ford_shortest_paths.hpp"><TT>boost/graph/bellman_ford_shortest_paths.hpp</TT></a>
|
||||
</TD>
|
||||
</TR></TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./EdgeListGraph.html">EdgeListGraph</a>, class Size, class WeightMap, class DistanceMap>
|
||||
bool bellman_ford_shortest_paths(EdgeListGraph& g, Size N,
|
||||
WeightMap w, DistanceMap d)
|
||||
|
||||
(2)
|
||||
template <class <a href="./EdgeListGraph.html">EdgeListGraph</a>, class Size, class WeightMap, class DistanceMap,
|
||||
class <a href="./BellmanFordVisitor.html">BellmanFordVisitor</a>>
|
||||
bool bellman_ford_shortest_paths(EdgeListGraph& g, Size N, WeightMap w,
|
||||
DistanceMap d, BellmanFordVisitor visit)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The Bellman-Ford algorithm [<A
|
||||
HREF="bibliography.html#bellman58">4</A>,<A
|
||||
HREF="bibliography.html#ford62:_flows">11</A>,<A
|
||||
HREF="bibliography.html#lawler76:_comb_opt">20</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>] solves the single-source
|
||||
shortest paths problem for a graph with both positive and negative
|
||||
edge weights. See Section <A
|
||||
HREF="./graph_theory_review.html#sec:shortest-paths-algorithms">Shortest-Paths
|
||||
Algorithms</A> for a description of the single-source shortest paths
|
||||
problem. If a cycle with negative length is detected, the algorithm
|
||||
returns <TT>false</TT>. The argument <TT>N</TT> should be the number
|
||||
of vertices in the graph. The source vertex is indicated by
|
||||
initializing the distance of the source vertex to zero and the
|
||||
distances of the rest of the vertices to
|
||||
<TT>std::numeric_limits<T>::max()</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>EdgeListGraph</TT> must be a model of
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>Distance</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the distance map. The value type of the distance
|
||||
map must be <a
|
||||
href="http://www.sgi.com/Technology/STL/LessThanComparable.html">LessThanComparable</a>.
|
||||
</LI>
|
||||
<LI>The <TT>Weight</TT> type must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>.
|
||||
The edge descriptor of the graph needs to be usable as the key
|
||||
type for the weight map. The value type for the
|
||||
weight map must be <I>Addable</I> with the
|
||||
distance map's value type.
|
||||
</LI>
|
||||
<LI>The <TT>Parent</TT> type must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
value type and key type should be the graph's vertex descriptor
|
||||
type.
|
||||
</LI>
|
||||
<LI>The type <TT>BellmanFordVisitor</TT> must be a model of <a href="./BellmanFordVisitor.html">BellmanFordVisitor</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(V E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
The source code for this example is in <a
|
||||
href="../example/bellman_ford.cpp"><TT>examples/bellman_ford.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
enum { u, v, x, y, z, N };
|
||||
char name[] = { 'u', 'v', 'x', 'y', 'z' };
|
||||
|
||||
typedef std::pair<int,int> E;
|
||||
E edges[] = { E(u,y), E(u,x), E(u,v),
|
||||
E(v,u),
|
||||
E(x,y), E(x,v),
|
||||
E(y,v), E(y,z),
|
||||
E(z,u), E(z,x) };
|
||||
|
||||
int weight[] = { -4, 8, 5,
|
||||
-2,
|
||||
9, -3,
|
||||
7, 2,
|
||||
6, 7 };
|
||||
|
||||
typedef edge_list<E*,E,ptrdiff_t> Graph;
|
||||
Graph g(edges, edges + sizeof(edges)/sizeof(E));
|
||||
|
||||
vector<int> distance(N,std::numeric_limits<short>::max());
|
||||
vector<int> parent(N,-1);
|
||||
|
||||
distance[z] = 0;
|
||||
parent[z] = z;
|
||||
bool r = bellman_ford_shortest_paths(g, int(N), weight,
|
||||
distance.begin(),
|
||||
parent.begin());
|
||||
if (r)
|
||||
for (int i = 0; i < N; ++i)
|
||||
std::cout << name[i] << ": " << distance[i]
|
||||
<< " " << name[parent[i]] << std::endl;
|
||||
else
|
||||
std::cout << "negative cycle" << std::endl;
|
||||
</PRE>
|
||||
The distance and predecessor for each vertex is:
|
||||
<PRE>
|
||||
u: 2 v
|
||||
v: 4 x
|
||||
x: 7 z
|
||||
y: -2 u
|
||||
z: 0 z
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
115
doc/bellman_visitor.html
Normal file
@@ -0,0 +1,115 @@
|
||||
<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: bellman_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
bellman_visitor<EventVisitorList>
|
||||
</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="./BellmanFordVisitor.html">BellmanFordVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./BellmanFordVisitor.html">BellmanFordVisitor</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/bellman_ford_shortest_paths.hpp">
|
||||
<TT>boost/graph/bellman_ford_shortest_paths.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./BellmanFordVisitor.html">BellmanFordVisitor</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 <class EventVisitorList><br>
|
||||
bellman_visitor<EventVisitorList><br>
|
||||
make_bellman_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be a BellmanFordVisitor.
|
||||
</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 © 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>
|
||||
132
doc/bfs_visitor.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<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: bfs_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
bfs_visitor<EventVisitorList>
|
||||
</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="./BFSVisitor.html">BFSVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
This is an excerpt from <a
|
||||
href="../example/bfs.cpp"><tt>examples/bfs.cpp</tt></a> where three
|
||||
event-visitors are combined to make a BFS visitor. The functions
|
||||
<tt>boost::record_distances</tt>, <tt>boost::record_predecessors</tt>,
|
||||
and <tt>copy_graph</tt> are all functions that create an event
|
||||
visitor.
|
||||
|
||||
<pre>
|
||||
// Construct graph G and obtain the source vertex s ...
|
||||
|
||||
boost::breadth_first_search(G, s,
|
||||
make_bfs_visitor(
|
||||
std::make_pair(boost::record_distances(d, boost::on_tree_edge()),
|
||||
std::make_pair(boost::record_predecessors(p.begin(),
|
||||
boost::on_tree_edge()),
|
||||
copy_graph(G_copy, boost::on_examine_edge())))) );
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./BFSVisitor.html">BFSVisitor</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><a href="./null_visitor.html"><tt>null_visitor</tt></a></TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/breadth_first_search.hpp">
|
||||
<TT>boost/graph/breadth_first_search.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./BFSVisitor.html">BFSVisitor</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 <class EventVisitorList><br>
|
||||
bfs_visitor<EventVisitorList><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 © 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>
|
||||
249
doc/bibliography.html
Normal file
@@ -0,0 +1,249 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes 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: Bibliography</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2>Bibliography</H2>
|
||||
|
||||
<DL COMMapCT><DD><P></P><DT><A NAME="aho83:_data_struct_algo">1</A>
|
||||
<DD>
|
||||
A. V. Aho, J. E. Hopcroft, and J. D. Ullman.
|
||||
<BR><EM>Data Structures and Algorithms</EM>.
|
||||
<BR>Addison-Wesley, 1983.
|
||||
|
||||
<P></P><DT><A NAME="austern99:_gener_progr_stl">2</A>
|
||||
<DD>
|
||||
M. H. Austern.
|
||||
<BR><EM>Generic Programming and the STL</EM>.
|
||||
<BR>Professional computing series. Addison-Wesley, 1999.
|
||||
|
||||
<P></P><DT><A NAME="baumgartner95:_signatures">3</A>
|
||||
<DD>
|
||||
G. Baumgartner and V. F. Russo.
|
||||
<BR>Signatures: A language extension for improving type abstraction and
|
||||
subtype polymorphism in C++.
|
||||
<BR><EM>Software-Practice and Experience</EM>, 25(8):863-889, August 1995.
|
||||
|
||||
<P></P><DT><A NAME="bellman58">4</A>
|
||||
<DD>
|
||||
R. Bellman.
|
||||
<BR>On a routing problem.
|
||||
<BR><EM>Quarterly of Applied Mathematics</EM>, 16(1):87-90, 1958.
|
||||
|
||||
<P></P><DT><A NAME="bruce95">5</A>
|
||||
<DD>
|
||||
K. B. Bruce, L. Cardelli, G. Castagna, the Hopkins Objects Group, G. T.
|
||||
Leavens, and B. Pierce.
|
||||
<BR>On binary methods.
|
||||
<BR><EM>Theory and Practice of Object Systems</EM>, 1:221-242, 1995.
|
||||
|
||||
<P></P><DT><A NAME="coleman85:_algor">6</A>
|
||||
<DD>
|
||||
T. F. Coleman, B. S. Garbow, and J. J. Mor'e.
|
||||
<BR>Algorithm 649: Fortran subroutines for estimating sparse hessian
|
||||
matrices.
|
||||
<BR><EM>ACM Transactions on Mathematical Software</EM>, 11(4):378, December
|
||||
1985.
|
||||
|
||||
<P></P><DT><A NAME="coleman84:_estim_jacob">7</A>
|
||||
<DD>
|
||||
T. F. Coleman and J. J. Mor'e.
|
||||
<BR>Estimation of sparse jacobian matrices and graph coloring problems.
|
||||
<BR><EM>SIAM Journal on Numerical Analysis</EM>, 20:187-209,, 1984.
|
||||
|
||||
<P></P><DT><A NAME="clr90">8</A>
|
||||
<DD>
|
||||
T. Cormen, C. Leiserson, and R. Rivest.
|
||||
<BR><EM>Introduction to Algorithms</EM>.
|
||||
<BR>McGraw-Hill, 1990.
|
||||
|
||||
<P></P><DT><A NAME="curtis74:_jacob">9</A>
|
||||
<DD>
|
||||
A. Curtis, M. Powell, and J. Reid.
|
||||
<BR>On the estimation of sparse jacobian matrices.
|
||||
<BR><EM>Journal of the Institute of Mathematics and its Applications</EM>,
|
||||
13:117-119, 1974.
|
||||
|
||||
<P></P><DT><A NAME="dijkstra59">10</A>
|
||||
<DD>
|
||||
E. Dijkstra.
|
||||
<BR>A note on two problems in connexion with graphs.
|
||||
<BR><EM>Numerische Mathematik</EM>, 1:269-271, 1959.
|
||||
|
||||
<P></P><DT><A NAME="ford62:_flows">11</A>
|
||||
<DD>
|
||||
L. R. Ford and D. R. Fulkerson.
|
||||
<BR><EM>Flows in networks</EM>.
|
||||
<BR>Princeton University Press, 1962.
|
||||
|
||||
<P></P><DT><A NAME="gamma95:_design_patterns">12</A>
|
||||
<DD>
|
||||
E. Gamma, R. Helm, R. Johnson, and J. Vlissides.
|
||||
<BR><EM>Design Patterns: Elements of Reusable Object-Oriented Software</EM>.
|
||||
<BR>Professional Computing. Addison-Welsey, 1995.
|
||||
|
||||
<P></P><DT><A NAME="george93:graphtheory">13</A>
|
||||
<DD>
|
||||
A. George, J. R. Gilbert, and J. W. Liu, editors.
|
||||
<BR><EM>Graph Theory and Sparse Matrix Computation</EM>.
|
||||
<BR>Springer-Verlag New York, Inc, 1993.
|
||||
|
||||
<P></P><DT><A NAME="george81:__sparse_pos_def">14</A>
|
||||
<DD>
|
||||
A. George and J. W.-H. Liu.
|
||||
<BR><EM>Computer Solution of Large Sparse Positive Definite Systems</EM>.
|
||||
<BR>Computational Mathematics. Prentice-Hall, 1981.
|
||||
|
||||
<P></P><DT><A NAME="graham85">15</A>
|
||||
<DD>
|
||||
R. Graham and P. Hell.
|
||||
<BR>On the history of the minimum spanning tree problem.
|
||||
<BR><EM>Annals of the History of Computing</EM>, 7(1):43-57, 1985.
|
||||
|
||||
<P></P><DT><A NAME="hart68">16</A>
|
||||
<DD>
|
||||
P. E. Hart, N. J. Nilsson, and B. Raphael.
|
||||
<BR>A formal basis for the heuristic determination of minimum cost paths.
|
||||
<BR><EM>IEEE Transactions on Systems Science and Cybernetics</EM>,
|
||||
4(2):100-107, 1968.
|
||||
|
||||
<P></P><DT><A NAME="kruskal56">18</A>
|
||||
<DD>
|
||||
J. B. Kruskal.
|
||||
<BR>On the shortest spanning subtree of a graph and the traveling
|
||||
salesman problem.
|
||||
<BR>In <EM>Proceedings of the American Mathematical Sofiety</EM>, volume 7,
|
||||
pages 48-50, 1956.
|
||||
|
||||
<P></P><DT><A NAME="kuehl96:_design_patterns_for_graph_algo">19</A>
|
||||
<DD>
|
||||
D. Kühl.
|
||||
<BR>Design patterns for the implementation of graph algorithms.
|
||||
<BR>Master's thesis, Technische Universität Berlin, July 1996.
|
||||
|
||||
<P></P><DT><A NAME="lawler76:_comb_opt">20</A>
|
||||
<DD>
|
||||
E. L. Lawler.
|
||||
<BR><EM>Combinatorial Opimization: Networks and Matroids</EM>.
|
||||
<BR>Holt, Rinehart, and Winston, 1976.
|
||||
|
||||
<P></P><DT><A NAME="LIU:MMD">21</A>
|
||||
<DD>
|
||||
J. W. H. Liu.
|
||||
<BR>Modification of the minimum-degree algorithm by multiple elimination.
|
||||
<BR><EM>ACM Transaction on Mathematical Software</EM>, 11(2):141-153, 1985.
|
||||
|
||||
<P></P><DT><A NAME="mehlhorn99:_leda">22</A>
|
||||
<DD>
|
||||
K. Mehlhorn and S. Näher.
|
||||
<BR><EM>The LEDA Platform of Combinatorial and Geometric Computing</EM>.
|
||||
<BR>Cambridge University Press, 1999.
|
||||
|
||||
<P></P><DT><A NAME="meyer88:_object_soft_const">23</A>
|
||||
<DD>
|
||||
B. Meyer.
|
||||
<BR><EM>Object-oriented Software Construction</EM>.
|
||||
<BR>Prentice Hall International Series in Computer Science. Prentice
|
||||
Hall, 1988.
|
||||
|
||||
<P></P><DT><A NAME="myers95:_trait">24</A>
|
||||
<DD>
|
||||
N. C. Myers.
|
||||
<BR>Traits: a new and useful template technique.
|
||||
<BR><EM>C++ Report</EM>, June 1995.
|
||||
|
||||
<P></P><DT><A NAME="prim57:_short">25</A>
|
||||
<DD>
|
||||
R. Prim.
|
||||
<BR>Shortest connection networks and some generalizations.
|
||||
<BR><EM>Bell System Technical Journal</EM>, 36:1389-1401, 1957.
|
||||
|
||||
<P></P><DT><A NAME="saad96:imsms">26</A>
|
||||
<DD>
|
||||
Y. Saad.
|
||||
<BR><EM>Iterative Methods for Sparse Minear System</EM>.
|
||||
<BR>PWS Publishing Company, 1996.
|
||||
|
||||
<P></P><DT><A NAME="tarjan83:_data_struct_network_algo">27</A>
|
||||
<DD>
|
||||
R. E. Tarjan.
|
||||
<BR><EM>Data Structures and Network Algorithms</EM>.
|
||||
<BR>Society for Industrial and Applied Mathematics, 1983.
|
||||
|
||||
<P></P><DT><A NAME="parter61:_gauss">28</A>
|
||||
<DD>
|
||||
Seymour Parter.
|
||||
<BR><EM>The use of linear graphs in Gauss elimination</EM>.
|
||||
<BR>SIAM Review, 1961 3:119-130.
|
||||
|
||||
<P></P><DT><A NAME="matula72:_graph_theory_computing">29</A>
|
||||
<DD>
|
||||
D. Matula, G. Marble, and J. Isaacson
|
||||
<BR><EM>Graph coloring algorithms in Graph Theory and
|
||||
Computing</EM>.<BR>
|
||||
Academic Press, pp.104-122, 1972.
|
||||
|
||||
<P></P><DT><A NAME="garey79:computers-and-intractability">30</a>
|
||||
<DD>
|
||||
M.R. Garey and D.S. Johnson<BR>
|
||||
<EM>Computers and Intractibility: A Guide to the Theory of
|
||||
NP-Completeness</EM><BR>
|
||||
W.H. Freeman, New York, 1979.
|
||||
|
||||
<P></P><DT><A NAME="welsch67">31</a>
|
||||
<DD>D. Welsch and M. B. Powel<BR>
|
||||
<EM>An upper bound for the chromatic number of a graph and its
|
||||
application to timetabling problems</EM>
|
||||
Computer Journal, 10:85-86, 1967.
|
||||
|
||||
<P></P><DT><A NAME="brelaz79:_new">32</a>
|
||||
<DD>D. Br'elaz<BR>
|
||||
<EM>New methods to color the vertices of a graph</EM><br>
|
||||
Communications of the ACM, vol. 22, 1979, pp. 251-256.
|
||||
|
||||
<P></P><DT><A NAME="heber99:_saw">33</a>
|
||||
<DD>G. Heber, R. Biswas, G.R. Gao<BR>
|
||||
<EM>Self-Avoiding Walks over Adaptive Unstructured Grids</EM><br>
|
||||
Parallel and Distributed Processing, LNCS 1586,
|
||||
Springer-Verlag, 1999, pp. 968-977
|
||||
|
||||
|
||||
<P></P><DT><A NAME="ng-raghavan">34</a>
|
||||
<DD>Esmond G. Ng amd Padma Raghavan<BR>
|
||||
<EM>Performance of greedy ordering heuristics for sparse {C}holesky factorization</EM><br>
|
||||
SIAM Journal on Matrix Analysis and Applications (To appear)
|
||||
|
||||
<P></P><DT><A NAME="George:evolution">35</a>
|
||||
<DD>Alan George and Joseph W. H. Liu<BR>
|
||||
<EM>The Evolution of the Minimum Degree Ordering Algorithm</EM><br>
|
||||
SIAM Review, March 1989, vol. 31, num. 1, pp. 1-19.
|
||||
|
||||
</DL>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
246
doc/breadth_first_search.html
Normal file
@@ -0,0 +1,246 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes 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: Breadth-First Search</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:bfs">
|
||||
<TT>breadth_first_search</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(V + E)</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./BFSVisitor.html">BFSVisitor</a>>
|
||||
void breadth_first_search(VertexListGraph& G,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
BFSVisitor vis);
|
||||
|
||||
(2)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./BFSVisitor.html">BFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void breadth_first_search(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
BFSVisitor vis, ColorMap color);
|
||||
|
||||
(3)
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./Buffer.html">Buffer</a>, <a href="./BFSVisitor.html">BFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void breadth_first_search(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The breadth-first search (BFS) algorithm is not really an algorithm in
|
||||
the sense that it has a particular purpose. Instead BFS is more like
|
||||
an algorithm <I>pattern</I>. One can do many different things with
|
||||
BFS. For example, the BFS pattern is used in the BGL to build several
|
||||
other algorithms: Dijkstra's shortest paths, Prim's Minimum Spanning
|
||||
Tree and best-first search. The definition of a <I>breadth-first
|
||||
search</I> is given in Section <A
|
||||
HREF="./graph_theory_review.html#sec:bfs-algorithm">Breadth-First
|
||||
Search</A>.
|
||||
|
||||
<P>
|
||||
The BGL BFS functions are highly parameterized so that they can be
|
||||
used in a wide variety of places. The way to customize the BFS
|
||||
algorithm to perform different operations is to supply a visitor,
|
||||
which is a function object with multiple functions. Each member
|
||||
function of the visitor gets invoked at special times during the
|
||||
algorithm as specified by <a
|
||||
href="./BFSVisitor.html">BFSVisitor</a>. Also, visitors can be layered
|
||||
on top of each other so that one can do lots of things during a single
|
||||
run of BFS. See the <a href="./bfs_visitor.html">bfs_visitor</a> class
|
||||
and the <A HREF="./EventVisitor.html">EventVisitor</A> concept for
|
||||
more details.
|
||||
|
||||
<P>
|
||||
Another way to customize the BFS algorithm is change the type of queue
|
||||
used. For instance, <TT>dijkstra_shortest_paths()</TT> uses a priority
|
||||
queue.
|
||||
|
||||
<p>
|
||||
The <tt>ColorMap</tt> is used by BFS to keep track of which vertices
|
||||
have been visited. At the beginning of the algorithm all vertices are
|
||||
white. As the algorithm proceeds, vertices are colored gray as they
|
||||
are inserted into the queue, and then colored black when they are
|
||||
finished and removed from queue.
|
||||
|
||||
|
||||
<P>
|
||||
Version 1 of the algorithm takes only three arguments: the graph
|
||||
object, the source vertex, and a visitor to specify the actions to be
|
||||
taken during the graph search. The algorithm will need to use a color
|
||||
property which must be provided by the graph object (through a vertex
|
||||
color property).
|
||||
|
||||
<P>
|
||||
Version 2 of the algorithm adds a color property argument to
|
||||
accommodate the use of an external property map.
|
||||
|
||||
<P>
|
||||
Version 3 of the algorithm is the most generalized. It adds a
|
||||
parameter for the queue. This version does not initialize the color of
|
||||
all the vertices to white at the start of the algorithm or invoke the
|
||||
<tt>initialize_vertex()</tt> visitor method, so that must be taken
|
||||
care of before calling this versin of <tt>breadth_first_search()</tt>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/breadth_first_search.hpp"><TT>boost/graph/breadth_first_search.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>IncidenceGraph</TT> must be a model of <a href="./IncidenceGraph.html">IncidenceGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>VertexListGraph</TT> must be a model of <a href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>BFSVisitor</TT> must be a model of <a href="./BFSVisitor.html">BFSVisitor</a>.
|
||||
</LI>
|
||||
<LI>In version (1) of the algorithm the graph must be a model
|
||||
of <a href="./PropertyGraph.html">PropertyGraph</a> for
|
||||
<TT>vertex_color_t</TT> and
|
||||
the color property map for the graph must meet the
|
||||
same requirements as <TT>ColorMap</TT>.
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>.
|
||||
A vertex descriptor must be usable as the key type of the map,
|
||||
and the value type of the map must be a model of <a
|
||||
href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
<LI>The type <TT>Buffer</TT> must be a model of <a href="./Buffer.html">Buffer</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001330300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E + V)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001330400000000000000">
|
||||
Example</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
This example demonstrates using the BGL Breadth-first search algorithm
|
||||
on the graph from <A
|
||||
HREF="./graph_theory_review.html#fig:bfs-example">Figure 5</A>. The
|
||||
source code for this example is in <a
|
||||
href="../example/bfs_basics.cpp"><TT>examples/bfs_basics.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
// Select the graph type we wish to use
|
||||
typedef adjacency_list<vecS, undirectedS> Graph;
|
||||
// Set up the vertex ID's and names
|
||||
enum { r, s, t, u, v, w, x, y, N };
|
||||
char name[] = { 'r', 's', 't', 'u', 'v', 'w', 'x', 'y' };
|
||||
// Specify the edges in the graph
|
||||
typedef pair<int,int> E;
|
||||
E edge_array[] = { E(r,s), E(r,v), E(s,w), E(w,r), E(w,t),
|
||||
E(w,x), E(x,t), E(t,u), E(x,y), E(u,y) };
|
||||
// Create the graph object
|
||||
Graph G(N, edge_array, edge_array + sizeof(edge_array)/sizeof(E));
|
||||
|
||||
// Some typedef's to save a little typing
|
||||
typedef Graph::vertex_descriptor Vertex;
|
||||
typedef std::vector<Vertex>::iterator Piter;
|
||||
typedef std::vector<Graph::size_type>::iterator Iiter;
|
||||
|
||||
// vectors to hold color, discover time, and finish time properties
|
||||
std::vector<default_color_type> color(num_vertices(G));
|
||||
std::vector<Graph::size_type> dtime(num_vertices(G));
|
||||
std::vector<Graph::size_type> ftime(num_vertices(G));
|
||||
|
||||
breadth_first_search(G, vertex(s,G),
|
||||
visit_timestamp(dtime.begin(), ftime.begin()),
|
||||
color.begin());
|
||||
|
||||
// Use std::sort to order the vertices by their discover time
|
||||
vector<Graph::size_type> discover_order(N);
|
||||
iota(discover_order.begin(), discover_order.end(), 0);
|
||||
std::sort(discover_order.begin(), discover_order.end(),
|
||||
indirect_cmp<Iiter, std::less<Graph::size_type> >(dtime.begin()));
|
||||
|
||||
cout << "order of discovery: ";
|
||||
for (int i = 0; i < N; ++i)
|
||||
cout << name[ discover_order[i] ] << " ";
|
||||
|
||||
vector<Graph::size_type> finish_order(N);
|
||||
iota(finish_order.begin(), finish_order.end(), 0);
|
||||
std::sort(finish_order.begin(), finish_order.end(),
|
||||
indirect_cmp<Iiter, std::less<Graph::size_type> >(ftime.begin()));
|
||||
|
||||
cout << endl << "order of finish: ";
|
||||
for (int i = 0; i < N; ++i)
|
||||
cout << name[ finish_order[i] ] << " ";
|
||||
cout << endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
order of discovery: s r w v t x u y
|
||||
order of finish: s r w v t x u y
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a> and
|
||||
<a href="./depth_first_search.html"><tt>depth_first_search()</tt></a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
121
doc/challenge.html
Normal file
@@ -0,0 +1,121 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Challenge</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<h2>Boost Graph Library Challenge and To-Do Items</h2>
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Polish up code/docs for pending items and champion the formal
|
||||
review. The pending items are:</li>
|
||||
<ul>
|
||||
<li><tt>container_traits.hpp</tt> (this should also include
|
||||
the work Matt Austern is doing on this topic)</li>
|
||||
|
||||
<li><tt>concept_checks.hpp</tt> </li>
|
||||
|
||||
<li><tt>property.hpp</tt></li>
|
||||
|
||||
<li>The queues and heaps: <tt>queue.hpp</tt>,
|
||||
<tt>mutable_queue.hpp</tt>, <tt>fibonacci_heap.hpp</tt>.
|
||||
Somehow merge implementation with Dietmer's heaps and queues.</li>
|
||||
|
||||
<li><tt>iterator_adaptor.hpp</tt> (need to figure out
|
||||
why this causes problems for VC++)</li>
|
||||
|
||||
<li><tt>disjoint_sets</tt> </li>
|
||||
</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?</li>
|
||||
<li> "Walk around the block" and similar open and closed neighborhood
|
||||
traversals. Note that edge traversals need to resolve to particular ends
|
||||
and sides (see below), not just to the edge as a whole.</li>
|
||||
<li> Given a point, find the nearest vertex, edge, or bounded polygon.
|
||||
Again, edges are viewed as having left and right sides.</li>
|
||||
<li> Given a line segment, find intersecting vertices, edges, or bounded
|
||||
polygons.</li>
|
||||
<li> Given a polygon, find intersecting whatever...</li>
|
||||
<li> Various minimum bounding rectangle and clipping problems.</li>
|
||||
<li> Construct a planar embedding of a planar graph.</li>
|
||||
<li> Find a balanced separator of a graph.</li>
|
||||
<li> Modify adjacency_list so that the out-edges can be ordered
|
||||
according to a user defined comparison object.</li>
|
||||
</ul>
|
||||
|
||||
<li>Finish and test Maximum Flow algorithm.</li>
|
||||
|
||||
<li>Create an <tt>adjacency_matrix</tt> class that models
|
||||
the <a href="./AdjacencyMatrix.html">AdjacencyMatrix</a>
|
||||
concept.</li>
|
||||
|
||||
<li>Floyd-Warshall algorithm.</li>
|
||||
|
||||
<li>Rewrite the Qhull algorithm using the Boost Graph Library.</li>
|
||||
|
||||
<li>Explore the use of Algorithm Objects as an alternative to
|
||||
the current approach with visitors.</li>
|
||||
|
||||
<li>Analyze the algorithms that do not yet have visitors, and
|
||||
come up with visitor interfaces for them.</li>
|
||||
|
||||
<li>Add a check in the adjacency_list class to make sure
|
||||
all the vertex property template arguments have kind=vertex_property_tag
|
||||
and all edge property template arguments have kind=edge_property_tag.</li>
|
||||
|
||||
<li>Clean up the output functions in graph_utility.hpp to
|
||||
use streams, and document all the utility functions. Replace
|
||||
the random number stuff with calls to the boost random number generator.</li>
|
||||
|
||||
<li>Modularize the tests in test/graph.cpp to apply to particular
|
||||
concepts. Make sure there are run-time tests for every BGL concept.</li>
|
||||
|
||||
<li>Write tests for the BGL algorithms. Currently the examples
|
||||
are used as a sanity check, but they do not constitute a real test. </li>
|
||||
|
||||
<li>Write up the examples from Knuth's <i>Stanford GraphBase</i> using
|
||||
the BGL. The file <a
|
||||
href="../example/miles_span.cpp"><tt>examples/miles_span.cpp</tt></a>
|
||||
is a start.
|
||||
|
||||
<li>Create a class to support sub-graph views of a graph, where a
|
||||
sub-graph behaves just like a graph, but shares vertex and edge
|
||||
properties with the original graph. Perhaps even support sub-graphs
|
||||
of sub-graphs, etc.
|
||||
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
267
doc/connected_components.html
Normal file
@@ -0,0 +1,267 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Jeremy Siek makes 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: Connected Components</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1>
|
||||
<A NAME="sec:connected-components"></A><A NAME="sec:strongly-connected-components"></A>
|
||||
<TT>connected_components</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">see below</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">components, color, discover time, finish time</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(V + E)</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class VertexListGraph, class Visitor,
|
||||
class Components>
|
||||
typename property_traits< Components >::value_type
|
||||
connected_components(VertexListGraph& G, Components c,
|
||||
Visitor v);
|
||||
|
||||
(2)
|
||||
template <class VertexListGraph, class Visitor,
|
||||
class Components, class Color>
|
||||
typename property_traits<Components>::value_type
|
||||
connected_components(VertexListGraph& G, Components c,
|
||||
Color color, Visitor v);
|
||||
|
||||
(3)
|
||||
template <class VertexListGraph, class Visitor,
|
||||
class Components, class DiscoverTime,
|
||||
class FinishTime, class Color>
|
||||
typename property_traits<Components>::value_type
|
||||
connected_components(VertexListGraph& G, Components c,
|
||||
DiscoverTime d, FinishTime f,
|
||||
Color color, Visitor v);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <TT>connected_component()</TT> function dispatches to two different
|
||||
algorithms depending on whether the graph in question is directed or
|
||||
undirected.
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>Computes the strongly connected components of a directed graph
|
||||
using the DFS/transpose/DFS algorithm [<A
|
||||
HREF="bibliography.html#aho83:_data_struct_algo">1</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>].
|
||||
|
||||
<P>
|
||||
</LI>
|
||||
<LI>Computes the connected components of an undirected graph using
|
||||
a DFS-based approach. If the connected-components are to be
|
||||
calculated over and over while a graph is changing the disjoint-set
|
||||
based approach of function
|
||||
<TT>dynamic_connected_components()</TT> is faster. For
|
||||
``static'' graphs this DFS-based approach is faster [<A
|
||||
HREF="bibliography.html#clr90">8</A>].
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The output of the algorithm is recorded in the component property
|
||||
map <TT>c</TT>, which will contain numbers giving the component ID
|
||||
assigned to each vertex. The number of components is the return value
|
||||
of the function.
|
||||
|
||||
<P>
|
||||
The algorithm requires the use of several property maps: color,
|
||||
discover time, and finish time. There are several versions of this
|
||||
algorithm to accommodate whether you wish to use interior or exterior
|
||||
property maps.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Definitions</H3>
|
||||
|
||||
<P>
|
||||
A <I>connected component</I> of an undirected graph is a set of
|
||||
vertices that are all reachable from each other. A <I>strongly
|
||||
connected component</I> of a directed graph <i>G=(V,E)</i> is a
|
||||
maximal set of vertices <i>U</i> which is in <i>V</i> such that for
|
||||
every pair of vertices <i>u</i> and <i>v</i> in <i>U</i>, we have both
|
||||
a path from <i>u</i> to <i>v</i> and path from <i>v</i> to
|
||||
<i>u</i>. That is to say that <i>u</i> and <i>v</i> are reachable from
|
||||
each other.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The graph type must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
|
||||
</LI>
|
||||
<LI><TT>DiscoverTime</TT> and <TT>FinishTime</TT> must be models of <a
|
||||
href="../../property_map/WritablePropertyMap.html">WritablePropertyMap</a>
|
||||
and their value type must be an integer type. Vertex descriptors from
|
||||
the graph should be usable as the key type for these maps.
|
||||
</LI>
|
||||
<LI>The <TT>Color</TT> map must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>
|
||||
and the graph's vertex descriptor type should be usable as the
|
||||
map's key type. The value type of the map must be a
|
||||
model of <I>ColorValue</I>.
|
||||
</LI>
|
||||
<LI>The <TT>Components</TT> type must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
value type of the <TT>Components</TT> property map should be
|
||||
an integer type, preferably the same as the <TT>size_type</TT> of
|
||||
the graph. The key type should be the graph's vertex descriptor
|
||||
type.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity for the strongly connected components algorithm is
|
||||
<i>O(V + E)</i>. The time complexity for the connected components
|
||||
algorithm is also <i>O(V + E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Calculating the connected components of an undirected graph. The
|
||||
complete source is in file <a
|
||||
href="../example/connected_components.cpp"><tt>examples/connected_components.cpp</tt></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
typedef discover_time_property< finish_time_property
|
||||
< color_property<> > > VertexProperty;
|
||||
typedef adjacency_list <vecS, vecS, undirectedS, VertexProperty> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
add_edge(0, 1, G);
|
||||
add_edge(1, 4, G);
|
||||
add_edge(4, 0, G);
|
||||
add_edge(2, 5, G);
|
||||
|
||||
std::vector<int> c(num_vertices(G));
|
||||
int num = connected_components(G, c.begin(),
|
||||
get_color_map(G), null_visitor());
|
||||
|
||||
cout << endl;
|
||||
std::vector<int>::iterator i;
|
||||
cout << "Total number of components: " << num << endl;
|
||||
for (i = c.begin(); i != c.end(); ++i)
|
||||
cout << "Vertex " << i - c.begin()
|
||||
<< " is in component " << *i << endl;
|
||||
cout << endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
Total number of components: 3
|
||||
Vertex 0 is in component 1
|
||||
Vertex 1 is in component 1
|
||||
Vertex 2 is in component 2
|
||||
Vertex 3 is in component 3
|
||||
Vertex 4 is in component 1
|
||||
Vertex 5 is in component 2
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Calculating the strongly connected components of a directed graph.
|
||||
<PRE>
|
||||
typedef discover_time_property< finish_time_property
|
||||
< color_property<> > > VertexProperty;
|
||||
typedef adjacency_list< vecS, vecS, directedS, VertexProperty > Graph;
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
add_edge(0, 1, G);
|
||||
add_edge(1, 1, G);
|
||||
add_edge(1, 3, G);
|
||||
add_edge(1, 4, G);
|
||||
add_edge(4, 3, G);
|
||||
add_edge(3, 4, G);
|
||||
add_edge(3, 0, G);
|
||||
add_edge(5, 2, G);
|
||||
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
std::vector<int> c(N);
|
||||
int num = connected_components(G, c.begin(),
|
||||
get_color_map(G), null_visitor());
|
||||
|
||||
cout << endl;
|
||||
cout << "Total number of components: " << num << endl;
|
||||
std::vector<int>::iterator i;
|
||||
for (i = c.begin(); i != c.end(); ++i)
|
||||
cout << "Vertex " << i - c.begin()
|
||||
<< " is in component " << *i << endl;
|
||||
}
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
Total number of components: 3
|
||||
Vertex 0 is in component 3
|
||||
Vertex 1 is in component 3
|
||||
Vertex 2 is in component 2
|
||||
Vertex 3 is in component 3
|
||||
Vertex 4 is in component 3
|
||||
Vertex 5 is in component 1
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
187
doc/constructing_algorithms.html
Normal file
@@ -0,0 +1,187 @@
|
||||
<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. Silicon Graphics makes 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: Constructing Graph Algorithms</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>Constructing graph algorithms with BGL</H1>
|
||||
|
||||
<P>
|
||||
The <I>main</I> goal of BGL is not to provide a nice graph class, or
|
||||
to provide a comprehensive set of reusable graph algorithms (though
|
||||
these are goals). The main goal of BGL is to encourage others to
|
||||
write reusable graph algorithms. By reusable we mean maximally
|
||||
reusable. Generic programming is a methodology for making algorithms
|
||||
maximally reusable, and in this section we will discuss how to apply
|
||||
generic programming to constructing graph algorithms.
|
||||
|
||||
<P>
|
||||
To illustrate the generic programming process we will step though the
|
||||
construction of a graph coloring algorithm. The graph coloring problem
|
||||
(or more specifically, the vertex coloring problem) is to label each
|
||||
vertex in a graph <i>G</i> with a color such that no two adjacent
|
||||
vertices are labeled with the same color and such that the minimum
|
||||
number of colors are used. In general, the graph coloring problem is
|
||||
NP-complete, and therefore it is impossible to find an optimal
|
||||
solution in a reasonable amount of time. However, there are many
|
||||
algorithms that use heuristics to find colorings that are close to the
|
||||
minimum.
|
||||
|
||||
<P>
|
||||
The particular algorithm we present here is based on the linear time
|
||||
<TT>SEQ</TT> subroutine that is used in the estimation of sparse
|
||||
Jacobian and Hessian matrices [<A
|
||||
HREF="bibliography.html#curtis74:_jacob">9</A>,<A
|
||||
HREF="bibliography.html#coleman84:_estim_jacob">7</A>,<A
|
||||
HREF="bibliography.html#coleman85:_algor">6</A>]. This algorithm
|
||||
visits all of the vertices in the graph according to the order defined
|
||||
by the input order. At each vertex the algorithm marks the colors of
|
||||
the adjacent vertices, and then chooses the smallest unmarked color
|
||||
for the color of the current vertex. If all of the colors are already
|
||||
marked, a new color is created. A color is considered marked if its
|
||||
mark number is equal to the current vertex number. This saves the
|
||||
trouble of having to reset the marks for each vertex. The
|
||||
effectiveness of this algorithm is highly dependent on the input
|
||||
vertex order. There are several ordering algorithms, including the
|
||||
<I>largest-first</I> [<A HREF="bibliography.html#welsch67">31</A>],
|
||||
<I>smallest-last</I> [<a
|
||||
href="bibliography.html#matula72:_graph_theory_computing">29</a>], and
|
||||
<I>incidence degree</I> [<a
|
||||
href="bibliography.html#brelaz79:_new">32</a>] algorithms, which
|
||||
improve the effectiveness of this coloring algorithm.
|
||||
|
||||
<P>
|
||||
The first decision to make when constructing a generic graph algorithm
|
||||
is to decide what graph operations are necessary for implementing the
|
||||
algorithm, and which graph concepts the operations map to. In this
|
||||
algorithm we will need to traverse through all of the vertices to
|
||||
intialize the vertex colors. We also need to access the adjacent
|
||||
vertices. Therefore, we will choose the <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a> concept because it
|
||||
is the minimum concept that includes these operations. The graph type
|
||||
will be parameterized in the template function for this algorithm. We
|
||||
do not restrict the graph type to a particular graph class, such as
|
||||
the BGL <a href="./adjacency_list.html"><TT>adjacency_list</TT></a>,
|
||||
for this would drastically limit the reusability of the algorithm (as
|
||||
most algorithms written to date are). We do restrict the graph type to
|
||||
those types that model <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>. This is enforced by
|
||||
the use of those graph operations in the algorithm, and furthermore by
|
||||
our explicit requirement added as a concept check with
|
||||
<TT>function_requires()</TT> (see Section <A
|
||||
HREF="../../concept_checking/concept_checking.html">Concept
|
||||
Checking</A> for more details about concept checking).
|
||||
|
||||
<P>
|
||||
Next we need to think about what vertex or edge properties will be
|
||||
used in the algorithm. In this case, the only property is vertex
|
||||
color. The most flexible way to specify access to vertex color is to
|
||||
use the propery map interface. This gives the user of the
|
||||
algorithm the ability to decide how they want to store the properties.
|
||||
Since we will need to both read and write the colors we specify the
|
||||
requirements as <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
<TT>key_type</TT> of the color map must be the
|
||||
<TT>vertex_descriptor</TT> from the graph, and the <TT>value_type</TT>
|
||||
must be some kind of integer. We also specify the interface for the
|
||||
<TT>order</TT> parameter as a property map, in this case a <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>. For
|
||||
order, the <TT>key_type</TT> is an integer offset and the
|
||||
<TT>value_type</TT> is a <TT>vertex_descriptor</TT>. Again we enforce
|
||||
these requirements with concept checks. The return value of this
|
||||
algorithm is the number of colors that were needed to color the graph,
|
||||
hence the return type of the function is the graph's
|
||||
<TT>vertices_size_type</TT>. The following code shows the interface for our
|
||||
graph algorithm as a template function, the concept checks, and some
|
||||
typedefs. The implementation is straightforward, the only step not
|
||||
discussed above is the color initialization step, where we set the
|
||||
color of all the vertices to ``uncolored''.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
namespace boost {
|
||||
template <class VertexListGraph, class Order, class Color>
|
||||
typename graph_traits<VertexListGraph>::vertices_size_type
|
||||
sequential_vertex_color_ting(const VertexListGraph& G,
|
||||
Order order, Color color)
|
||||
{
|
||||
typedef graph_traits<VertexListGraph> GraphTraits;
|
||||
typedef typename GraphTraits::vertex_descriptor vertex_descriptor;
|
||||
typedef typename GraphTraits::vertices_size_type size_type;
|
||||
typedef typename property_traits<Color>::value_type ColorType;
|
||||
typedef typename property_traits<Order>::value_type OrderType;
|
||||
|
||||
function_requires< VertexListGraphConcept<VertexListGraph> >();
|
||||
function_requires< ReadWritePropertyMapConcept<Color, vertex_descriptor> >();
|
||||
function_requires< IntegerConcept<ColorType> >();
|
||||
function_requires< size_type, ReadablePropertyMapConcept<Order> >();
|
||||
typedef typename same_type<OrderType, vertex_descriptor>::type req_same;
|
||||
|
||||
size_type max_color = 0;
|
||||
const size_type V = num_vertices(G);
|
||||
std::vector<size_type>
|
||||
mark(V, numeric_limits_max(max_color));
|
||||
|
||||
typename GraphTraits::vertex_iterator v, vend;
|
||||
for (tie(v, vend) = vertices(G); v != vend; ++v)
|
||||
color[*v] = V - 1; // which means "not colored"
|
||||
|
||||
for (size_type i = 0; i < V; i++) {
|
||||
vertex_descriptor current = order[i];
|
||||
|
||||
// mark all the colors of the adjacent vertices
|
||||
typename GraphTraits::adjacency_iterator ai, aend;
|
||||
for (tie(ai, aend) = adjacent_vertices(current, G); ai != aend; ++ai)
|
||||
mark[color[*ai]] = i;
|
||||
|
||||
// find the smallest color unused by the adjacent vertices
|
||||
size_type smallest_color = 0;
|
||||
while (smallest_color < max_color && mark[smallest_color] == i)
|
||||
++smallest_color;
|
||||
|
||||
// if all the colors are used up, increase the number of colors
|
||||
if (smallest_color == max_color)
|
||||
++max_color;
|
||||
|
||||
color[current] = smallest_color;
|
||||
}
|
||||
return max_color;
|
||||
}
|
||||
} // namespace boost
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
223
doc/depth_first_search.html
Normal file
@@ -0,0 +1,223 @@
|
||||
<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: Depth-First Search</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:depth-first-search"></A>
|
||||
<TT>depth_first_search</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(V + E)</i></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/depth_first_search.hpp"><TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>>
|
||||
void depth_first_search(VertexListGraph& G, DFSVisitor v);
|
||||
|
||||
(2)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void depth_first_search(VertexListGraph& G, DFSVisitor v, ColorMap c);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <TT>depth_first_search()</TT> algorithm performs a depth-first
|
||||
search (DFS) on a graph, invoking the methods of the graph search
|
||||
visitor at the appropriate event-points. A depth-first search visits
|
||||
all the vertices in a graph, starting with some arbitrary vertex and
|
||||
then always choosing the next adjacent unvisited vertex. Once the DFS
|
||||
reaches a vertex with no unvisited neighbors it backtracks to one of
|
||||
the previous vertices and continues from there. Once all of the
|
||||
vertices in the same connected component have been visited, another
|
||||
arbitrary unvisited vertex is choosen and the depth-first search
|
||||
resumes. A more detailed explanation of DFS is given in Section <A
|
||||
HREF="./graph_theory_review.html#sec:dfs-algorithm">Depth-First
|
||||
Search</A>. The depth-first exploration of each connected component is
|
||||
implemented by the function <a
|
||||
href="./depth_first_visit.html"><tt>depth_first_visit()</tt></a>.
|
||||
|
||||
|
||||
<p>
|
||||
The <tt>DFSVisitor</tt> supplied by the user determines what
|
||||
actions are taken at each event-point within the algorithm.
|
||||
|
||||
<p>
|
||||
The <tt>ColorMap</tt> is used by the algorithm to keep track
|
||||
of which vertices have been visited.
|
||||
|
||||
<P>
|
||||
DFS is used as the kernel for several other graph algorithms,
|
||||
including <a
|
||||
href="./topological_sort.html"><tt>topological_sort</tt></a> and two
|
||||
of the connected component algorithms.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>VertexListGraph</TT> must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
</LI>
|
||||
<LI>In version (1) of the algorithm the graph must be a model of <a
|
||||
href="./PropertyGraph.html">PropertyGraph</a> for
|
||||
<TT>vertex_color_t</TT> and the color property map for the graph
|
||||
must meet the same requirements as <TT>ColorMap</TT>.
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The key type of <tt>ColorMap</tt> must be the vertex descriptor type for the graph and the value type of <TT>ColorMap</TT> must be a model of
|
||||
<a href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
<LI>The <tt>DFSVisitor</tt> type must be a model of <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001340300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E + V)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
This example shows DFS applied to the graph in <A
|
||||
HREF="./graph_theory_review.html#fig:dfs-example">Figure 1</A>. The
|
||||
source code for this example is in <a
|
||||
href="../example/dfs_basics.cpp"><TT>examples/dfs_basics.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<p></p>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:dfs-example"></A></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
|
||||
Depth-first search spreading through a graph.
|
||||
</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/dfs_example.gif" width="166" height="91"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
<p></p>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
// Select the graph type we wish to use
|
||||
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> Graph;
|
||||
// Set up the vertex names
|
||||
enum { u, v, w, x, y, z, N };
|
||||
char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' };
|
||||
// Specify the edges in the graph
|
||||
typedef std::pair<int,int> E;
|
||||
E edge_array[] = { E(u,v), E(u,x), E(x,v), E(y,x),
|
||||
E(v,y), E(w,y), E(w,z), E(z,z) };
|
||||
Graph G(N, edge_array, edge_array + sizeof(edge_array)/sizeof(E));
|
||||
|
||||
// Some typedef's to save a little typing
|
||||
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef boost::graph_traits<Graph>::vertices_size_type size_type;
|
||||
typedef std::vector<Vertex>::iterator Piter;
|
||||
typedef std::vector<size_type>::iterator Iiter;
|
||||
|
||||
// color, discover time, and finish time properties
|
||||
std::vector<default_color_type> color(num_vertices(G));
|
||||
std::vector<size_type> dtime(num_vertices(G));
|
||||
std::vector<size_type> ftime(num_vertices(G));
|
||||
|
||||
boost::depth_first_search(G, boost::visit_timestamp(dtime.begin(), ftime.begin()),
|
||||
color.begin());
|
||||
|
||||
// use std::sort to order the vertices by their discover time
|
||||
std::vector<size_type> discover_order(N);
|
||||
boost::iota(discover_order.begin(), discover_order.end(), 0);
|
||||
std::sort(discover_order.begin(), discover_order.end(),
|
||||
boost::indirect_cmp<Iiter, std::less<size_type> >(dtime.begin()));
|
||||
|
||||
std::cout << "order of discovery: ";
|
||||
for (int i = 0; i < N; ++i)
|
||||
std::cout << name[ discover_order[i] ] << " ";
|
||||
|
||||
std::vector<size_type> finish_order(N);
|
||||
boost::iota(finish_order.begin(), finish_order.end(), 0);
|
||||
std::sort(finish_order.begin(), finish_order.end(),
|
||||
boost::indirect_cmp<Iiter, std::less<size_type> >(ftime.begin()));
|
||||
|
||||
std::cout << endl << "order of finish: ";
|
||||
for (size_type i = 0; i < N; ++i)
|
||||
std::cout << name[ finish_order[i] ] << " ";
|
||||
std::cout << std::endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
order of discovery: u v y x w z
|
||||
order of finish: x y v u z w
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./depth_first_visit.html"><tt>depth_first_visit</tt></a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
107
doc/depth_first_visit.html
Normal file
@@ -0,0 +1,107 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes 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: Depth-First Visit</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="sec:dfs"></A>
|
||||
<TT>depth_first_visit</TT>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="LEFT">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(E)</i></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/depth_first_search.hpp"><TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>, class <a href="#ColorMap">ColorMap</a>>
|
||||
void depth_first_visit(IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
DFSVisitor& vis, ColorMap color)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function visits all of the vertices in the same connected
|
||||
component as the source vertex <tt>s</tt>, using the <a
|
||||
href="./graph_theory_review.html#sec:dfs-algorithm">depth-first
|
||||
pattern</a>. The main purpose of the function is for the
|
||||
implementation of <TT>depth_first_search()</TT> though sometimes it is
|
||||
useful on its own.
|
||||
|
||||
<p>
|
||||
The <tt>DFSVisitor</tt> supplied by the user determines what
|
||||
actions are taken at each event-point within the algorithm.
|
||||
|
||||
<p>
|
||||
The <tt>ColorMap</tt> is used by the algorithm to keep track
|
||||
of which vertices have been visited.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>IncidenceGraph</TT> must be a model of
|
||||
<a href="./IncidenceGraph.html">IncidenceGraph</a>.
|
||||
</LI>
|
||||
<LI>The type <TT>DFSVisitor</TT> must be a model of <a
|
||||
href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The key type of <tt>ColorMap</tt> must be the vertex descriptor type for the graph and the value type of <TT>ColorMap</TT> must be a model of
|
||||
<a href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
115
doc/dfs_visitor.html
Normal file
@@ -0,0 +1,115 @@
|
||||
<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: dfs_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
dfs_visitor<EventVisitorList>
|
||||
</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="./DFSVisitor.html">DFSVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
See the example for <a href="./EventVisitor.html">EventVisitor</a>.
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./DFSVisitor.html">DFSVisitor</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/depth_first_search.hpp">
|
||||
<TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./DFSVisitor.html">DFSVisitor</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 <class EventVisitorList><br>
|
||||
dfs_visitor<EventVisitorList><br>
|
||||
make_dfs_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be a DFS 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 © 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>
|
||||
236
doc/dijkstra_shortest_paths.html
Normal file
@@ -0,0 +1,236 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Jeremy Siek makes 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: Dijkstra's Shortest Paths</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:dijkstra"></A>
|
||||
<TT>dijkstra_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed and undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">color, distance, weight, vertex index</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O((V + E) log V)</i>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/dijkstra_shortest_paths.hpp"><TT>boost/graph/dijkstra_shortest_paths.hpp</TT></a>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
(1)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s);
|
||||
|
||||
(2)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="#DistanceMap">DistanceMap</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap d);
|
||||
|
||||
(3)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="#DistanceMap">DistanceMap</a>, class <a href="./UniformCostVisitor.html">UniformCostVisitor</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap d, UniformCostVisitor visit);
|
||||
|
||||
(4)
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./UniformCostVisitor.html">UniformCostVisitor</a>,
|
||||
class <a href="#DistanceMap">DistanceMap</a>, class <a href="#WeightMap">WeightMap</a>, class <a href="#ColorMap">ColorMap</a>, class <a href="#VertexIndexMap">VertexIndexMap</a>>
|
||||
void
|
||||
dijkstra_shortest_paths(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap distance, WeightMap weight, ColorMap color, VertexIndexMap id,
|
||||
UniformCostVisitor vis);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This is the modified Dijkstra algorithm [<A
|
||||
HREF="bibliography.html#dijkstra59">10</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>] which solves the single-source
|
||||
shortest-paths problem on a weighted, directed graph for the case
|
||||
where all edge weights are nonnegative. See Section <A
|
||||
HREF="graph_theory_review.html#sec:shortest-path-algorithms">Shortest-Paths Algorithms</A>
|
||||
for some background to the shortest-path problem. The priority queue
|
||||
used inside the algorithm is implemented with a heap for efficiency.
|
||||
|
||||
<P>
|
||||
There are four versions of the algorithm to accommodate whether the
|
||||
necessary graph properties will be supplied by the graph object or
|
||||
externally via a argument to this function. The properties needed by
|
||||
the algorithm are distance, weight, color, and vertex index. Version 3
|
||||
and 4 of the algorithm also include a visitor argument for added
|
||||
extensibility.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The type <TT>VertexListGraph</TT> must be a model of <a href="./VertexListGraph.html">VertexListGraph</a>.
|
||||
</LI>
|
||||
<li>In version (1) of the algorithm, the graph must be a <a href="./PropertyGraph.html">PropertyGraph</a> with respect to <tt>vertex_color_t</tt>,
|
||||
<tt>vertex_distance_t</tt>, <tt>edge_weight_t</tt>, and <tt>vertex_index_t</tt></li>
|
||||
|
||||
<li>In version (2) of the algorithm, the graph must be a <a href="./PropertyGraph.html">PropertyGraph</a> with respect to <tt>vertex_color_t</tt>,
|
||||
<tt>edge_weight_t</tt>, and <tt>vertex_index_t</tt></li>
|
||||
|
||||
<li>In version (3) of the algorithm, the graph must be a <a href="./PropertyGraph.html">PropertyGraph</a> with respect to <tt>vertex_color_t</tt>,
|
||||
<tt>edge_weight_t</tt>, and <tt>vertex_index_t</tt></li>
|
||||
|
||||
<LI>The type <TT>UniformCostVisitor</TT> must be a model of <a href="./UniformCostVisitor.html">UniformCostVisitor</a>.
|
||||
</LI>
|
||||
<LI><a name="DistanceMap">The type <TT>DistanceMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the distance map. The value type of the distance
|
||||
map must be <a href="http://www.sgi.com/Technology/STL/LessThanComparable.html">LessThanComparable</a>.</a>
|
||||
</LI>
|
||||
<LI><a name="WeightMap">The type <TT>WeightMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>. The
|
||||
edge descriptor type of the graph needs to be usable as the key
|
||||
type for the weight map. The value type for the map
|
||||
must be <I>Addable</I> with the value type of the distance
|
||||
map.</a>
|
||||
</LI>
|
||||
<LI><a name="ColorMap">The type <TT>ColorMap</TT> must be a model of
|
||||
<a href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a>. A vertex descriptor must be
|
||||
usable as the key type of the map, and the value type of the
|
||||
map must be a model of <a href="./ColorValue.html">ColorValue</a>.</a>
|
||||
</LI>
|
||||
<LI><a name="VertexIndexMap">The type <TT>VertexIndexMap</TT> must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a>. The
|
||||
value type of <TT>VertexIndexMap</TT> must be an integer type. The
|
||||
integers must map vertex descriptors to the integers zero through
|
||||
<tt>num_vertices(g) - 1</tt>. The vertex
|
||||
descriptor type of the graph needs to be usable as the key type
|
||||
of the vertex index map.</a>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O((V + E) log V)</i>, or just <i>O(E log V)</i>
|
||||
if all vertices are reachable from the source.
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
The source code for this example is in <a
|
||||
href="../example/dijkstra.cpp"><TT>examples/dijkstra.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
int
|
||||
main(int , char* [])
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
typedef property<edge_weight_t, int> weightp;
|
||||
typedef adjacency_list< listS, vecS, directedS,
|
||||
property<vertex_color_t,default_color_type>, weightp > Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
typedef std::pair<int,int> E;
|
||||
|
||||
const int num_nodes = 5;
|
||||
E edges[] = { E(0,2),
|
||||
E(1,1), E(1,3), E(1,4),
|
||||
E(2,1), E(2,3),
|
||||
E(3,4),
|
||||
E(4,0), E(4,1) };
|
||||
int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1};
|
||||
|
||||
Graph G(num_nodes, edges, edges + sizeof(edges)/sizeof(E), weights);
|
||||
|
||||
std::vector<Vertex> p(num_vertices(G));
|
||||
std::vector<int> d(num_vertices(G));
|
||||
|
||||
Vertex s = *(vertices(G).first);
|
||||
p[s] = s;
|
||||
dijkstra_shortest_paths(G, s, &d[0],
|
||||
make_ucs_visitor(record_predecessors(&p[0], on_edge_relaxed())));
|
||||
|
||||
std::cout << "distances from start vertex:" << std::endl;
|
||||
graph_traits<Graph>::vertex_iterator vi, vend;
|
||||
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
|
||||
std::cout << "distance(" << *vi << ") = " << d[*vi] << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "shortest paths tree" << std::endl;
|
||||
adjacency_list<> tree(num_nodes);
|
||||
|
||||
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
|
||||
if (*vi != p[*vi])
|
||||
add_edge(p[*vi], *vi, tree);
|
||||
|
||||
print_graph(tree);
|
||||
|
||||
return 0;
|
||||
}
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
distances from start vertex:
|
||||
distance(0) = 0
|
||||
distance(1) = 6
|
||||
distance(2) = 1
|
||||
distance(3) = 4
|
||||
distance(4) = 5
|
||||
|
||||
shortest paths tree
|
||||
0 --> 2
|
||||
1 -->
|
||||
2 --> 3
|
||||
3 --> 4
|
||||
4 --> 1
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
186
doc/distance_recorder.html
Normal file
@@ -0,0 +1,186 @@
|
||||
<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: distance_recorder</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
distance_recorder<DistanceMap, EventTag>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This is an <a href="./EventVisitor.html">EventVisitor</a> that records
|
||||
the distance of a vertex (using a <a
|
||||
href="property_map.html">property map</a>) from some
|
||||
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
|
||||
cannot be used with vertex events.
|
||||
|
||||
<p>
|
||||
<tt>distance_recorder</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>
|
||||
|
||||
See the example for <a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>.
|
||||
|
||||
<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>DistanceMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/WritablePropertyMap.html">WritablePropertyMap</a>,
|
||||
where the key type and the value type are the vertex descriptor type
|
||||
of the graph.
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>EventTag</TT></TD>
|
||||
<TD>
|
||||
The tag to specify when the <tt>distance_recorder</tt> should be
|
||||
applied during the graph algorithm. <tt>EventTag</tt> must be an
|
||||
edge event.
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H2>Associated Types</H2>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>distance_recorder::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>
|
||||
distance_recorder(DistanceMap pa);
|
||||
</tt></td>
|
||||
<td>
|
||||
Construct a distance recorder object with distance property map
|
||||
<tt>pa</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
template <class Edge, class Graph><br>
|
||||
void operator()(Edge e, const Graph& g);
|
||||
</tt></td>
|
||||
<td>
|
||||
Given edge <i>e = (u,v)</i>, this records the distance of <i>v</i> as
|
||||
one plus the distance of <i>u</i>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
template <class DistanceMap, class Tag><br>
|
||||
distance_recorder<DistanceMap, Tag> <br>
|
||||
record_distances(DistanceMap pa, Tag);
|
||||
</tt></td><td>
|
||||
A convenient way to create a <tt>distance_recorder</tt>.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
<p>
|
||||
The following are other event visitors: <a
|
||||
href="./distance_recorder.html"><tt>predecessor_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 © 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: DistanceMap EventTag EventVisitor map bfs dfs const Siek
|
||||
-->
|
||||
<!-- LocalWords: EventVisitorList WritablePropertyMap Univ Quan
|
||||
-->
|
||||
<!-- LocalWords: Lumsdaine
|
||||
-->
|
||||
422
doc/dynamic_components.html
Normal file
@@ -0,0 +1,422 @@
|
||||
<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: Dynamic Connected Components</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>Dynamic Connected Components</H1>
|
||||
|
||||
<P>
|
||||
This section describes a family of functions and classes that
|
||||
calculate the connected components of an undirected graph. The
|
||||
algorithm used here is based on the disjoint-sets data
|
||||
structure [<A
|
||||
HREF="bibliography.html#clr90">8</A>,<A
|
||||
HREF="bibliography.html#tarjan83:_data_struct_network_algo">27</A>] which is
|
||||
the best method for situations where the graph is growing (edges are
|
||||
being added) and the connected components information needs to be
|
||||
updated repeatedly. The disjoint-sets class is described in
|
||||
Section <A HREF="../../disjoint_sets/disjoint_sets.html">Disjoint Sets</A>.
|
||||
|
||||
<P>
|
||||
The following five operations are the primary functions that you will
|
||||
use to calculate and maintain the connected components. The objects
|
||||
used here are a graph <TT>g</TT>, a disjoint-sets structure <TT>ds</TT>,
|
||||
and vertices <TT>u</TT> and <TT>v</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI><TT>initialize_dynamic_components(g, ds)</TT>
|
||||
<BR>
|
||||
Basic initialization of the disjoint-sets structure. Each
|
||||
vertex in the graph <TT>g</TT> is in its own set.
|
||||
</LI>
|
||||
<LI><TT>dynamic_connected_components(g, ds)</TT>
|
||||
<BR>
|
||||
The connected components are calculated based on the edges in the graph
|
||||
<TT>g</TT> and the information is embedded in <TT>ds</TT>.
|
||||
</LI>
|
||||
<LI><TT>ds.find_set(v)</TT>
|
||||
<BR>
|
||||
Extracts the component information for vertex <TT>v</TT> from the
|
||||
disjoint-sets.
|
||||
</LI>
|
||||
<LI><TT>ds.union_set(u, v)</TT>
|
||||
<BR>
|
||||
Update the disjoint-sets structure when edge <i>(u,v)</i> is added to the graph.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity for the whole process is <i>O(V + E
|
||||
alpha(E,V))</i> where <i>E</i> is the total number of edges in the
|
||||
graph (by the end of the process) and <i>V</i> is the number of
|
||||
vertices. <i>alpha</i> is the inverse of Ackermann's function which
|
||||
has explosive recursively exponential growth. Therefore its inverse
|
||||
function grows <I>very</I> slowly. For all practical purposes
|
||||
<i>alpha(m,n) <= 4</i> which means the time complexity is only
|
||||
slightly larger than <i>O(V + E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Maintain the connected components of a graph while adding edges using
|
||||
the disjoint-sets data structure. The full source code for this
|
||||
example can be found in <a
|
||||
href="../example/dynamic_components.cpp"><TT>examples/dynamic_components.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
// Create a graph
|
||||
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
|
||||
typedef Graph::vertex_descriptor Vertex;
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
add_edge(0, 1, G);
|
||||
add_edge(1, 4, G);
|
||||
|
||||
// create the disjoint-sets structure, which requires
|
||||
// rank and parent vertex properties
|
||||
std::vector<Vertex> rank(num_vertices(G));
|
||||
std::vector<Vertex> parent(num_vertices(G));
|
||||
typedef std::vector<Graph::size_type>::iterator Rank;
|
||||
typedef std::vector<Vertex>::iterator Parent;
|
||||
disjoint_sets<Rank, Parent> ds(rank.begin(), parent.begin());
|
||||
|
||||
// determine the connected components
|
||||
// the results are embedded in the disjoint-sets structure
|
||||
initialize_dynamic_components(G, ds);
|
||||
dynamic_connected_components(G, ds);
|
||||
|
||||
Graph::edge_descriptor e;
|
||||
bool flag;
|
||||
|
||||
// Add a couple more edges and update the disjoint-sets
|
||||
tie(e,flag) = add_edge(4, 0, G);
|
||||
ds.union_set(4,0);
|
||||
|
||||
tie(e,flag) = add_edge(2, 5, G);
|
||||
ds.union_set(2,5);
|
||||
|
||||
cout << "An undirected graph:" << endl;
|
||||
print_graph(G, get(vertex_index, G));
|
||||
cout << endl;
|
||||
|
||||
Graph::vertex_iterator i,end;
|
||||
for (tie(i,end) = vertices(G); i != end; ++i)
|
||||
cout << "representative[" << *i << "] = " <<
|
||||
ds.find_set(*i) << endl;;
|
||||
cout << endl;
|
||||
|
||||
typedef component_index<int> Components;
|
||||
Components components(parent.begin(), parent.end());
|
||||
|
||||
for (Components::size_type i = 0; i < components.size(); ++i) {
|
||||
cout << "component " << i << " contains: ";
|
||||
Components::value_type::iterator
|
||||
j = components[i].begin(),
|
||||
jend = components[i].end();
|
||||
for ( ; j != jend; ++j)
|
||||
cout << *j << " ";
|
||||
cout << endl;
|
||||
}
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<H2><A NAME="sec:initialize-dynamic-components"></A>
|
||||
<TT>initialize_dynamic_components</TT>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">rank, parent (in disjoint-sets)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class VertexListGraph, class DisjointSets>
|
||||
void initialize_dynamic_components(VertexListGraph& G, DisjointSets& ds)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This prepares the disjoint-sets data structure for the dynamic
|
||||
connected components algorithm by making each vertex in the graph a
|
||||
member of its own component (or set).
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<p>
|
||||
<hr>
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:dynamic-connected-components"></A>
|
||||
<TT>dynamic_connected_components</TT>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">rank, parent (in disjoint-sets)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(E)</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<p>
|
||||
<PRE>
|
||||
template <class EdgeListGraph, class DisjointSets>
|
||||
void dynamic_connected_components(EdgeListGraph& g, DisjointSets& ds)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function calculates the connected components of the graph,
|
||||
embedding the results in the disjoint-sets data structure.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>The graph type must be a model of <a href="./EdgeListGraph.html">EdgeListGraph</a>.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<H2><A NAME="sec:same-component">
|
||||
<TT>same_component</TT></A>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">rank, parent (in disjoint-sets)</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(alpha(E,V))</i></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class Vertex, class DisjointSet>
|
||||
bool same_component(Vertex u, Vertex v, DisjointSet& ds)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This function determines whether <TT>u</TT> and <TT>v</TT> are in the same
|
||||
component.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Requirements on Types</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI><TT>Vertex</TT> must be compatible with the rank and parent
|
||||
property maps of the <TT>DisjointSets</TT> data structure.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
<H2><A NAME="sec:component-index"></A>
|
||||
<TT>component_index</TT>
|
||||
</H2>
|
||||
|
||||
<p>
|
||||
<PRE>
|
||||
component_index<Index>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The is a class that provides an STL container-like view for the
|
||||
components of the graph. Each component is a container-like object,
|
||||
and the <TT>component_index</TT> object provides access to the
|
||||
component objects via <TT>operator[]</TT>. A <TT>component_index</TT>
|
||||
object is initialized with the parents property in the disjoint-sets
|
||||
calculated from the <TT>dynamic_connected_components()</TT> function.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Members</H3>
|
||||
|
||||
<P>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Member</th> <th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type</tt></td>
|
||||
<td>The type used for representing the number of components.</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type</tt></td>
|
||||
<td>
|
||||
The type for a component object. The component type has the following members.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::value_type</tt></td>
|
||||
<td>
|
||||
The value type of a component object is a vertex ID.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator</tt></td>
|
||||
<td>
|
||||
This iterator can be used to traverse all of the vertices
|
||||
in the component. This iterator dereferences to give a vertex ID.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::const_iterator</tt></td>
|
||||
<td>
|
||||
The const iterator.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator value_type::begin() const</tt></td>
|
||||
<td>
|
||||
Return an iterator pointing to the first vertex in the component.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator value_type::end() const</tt></td>
|
||||
<td>
|
||||
Return an iterator pointing past the end of the last vertex in the
|
||||
component.
|
||||
</td>
|
||||
<tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<tt>
|
||||
template <class ComponentsContainer>
|
||||
component_index(const ComponentsContainer& c)
|
||||
</tt>
|
||||
</td>
|
||||
<td>
|
||||
Construct the <TT>component_index</TT> using the information
|
||||
from the components container <TT>c</TT> which was the result
|
||||
of executing <TT>connected_components_on_edgelist</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type operator[](size_type i)</tt></td>
|
||||
<td>
|
||||
Returns the <TT>i</TT>th component in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type component_index::size()</tt></td>
|
||||
<td>
|
||||
Returns the number of components in the graph.
|
||||
</td>
|
||||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
225
doc/edge_list.html
Normal file
@@ -0,0 +1,225 @@
|
||||
<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. Silicon Graphics makes 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: Edge List Class</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="sec:edge-list-class"></A>
|
||||
<PRE>
|
||||
edge_list<EdgeIterator, ValueType, DiffType>
|
||||
</PRE>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
The <TT>edge_list</TT> class is an adaptor that turns a pair of edge
|
||||
iterators into a class that models <TT>EdgeListGraph</TT>. The
|
||||
<TT>value_type</TT> of the edge iterator must be a <TT>std::pair</TT> (or
|
||||
at least have <TT>first</TT> and <TT>second</TT> members). The
|
||||
<TT>first_type</TT> and <TT>second_type</TT> of the pair must be the
|
||||
same and they will be used for the graph's <TT>vertex_descriptor</TT>.
|
||||
The <TT>ValueType</TT> and <TT>DiffType</TT> template parameters are only
|
||||
needed if your compiler does not support partial
|
||||
specialization. Otherwise they default to the correct types.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Applying the Bellman-Ford shortest paths algorithm to an
|
||||
<TT>edge_list</TT>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
enum { u, v, x, y, z, N };
|
||||
char name[] = { 'u', 'v', 'x', 'y', 'z' };
|
||||
|
||||
typedef std::pair<int,int> E;
|
||||
E edges[] = { E(u,y), E(u,x), E(u,v),
|
||||
E(v,u),
|
||||
E(x,y), E(x,v),
|
||||
E(y,v), E(y,z),
|
||||
E(z,u), E(z,x) };
|
||||
|
||||
int weight[] = { -4, 8, 5,
|
||||
-2,
|
||||
9, -3,
|
||||
7, 2,
|
||||
6, 7 };
|
||||
|
||||
typedef boost::edge_list<E*> Graph;
|
||||
Graph g(edges, edges + sizeof(edges) / sizeof(E));
|
||||
|
||||
std::vector<int> distance(N, std::numeric_limits<short>::max());
|
||||
std::vector<int> parent(N,-1);
|
||||
|
||||
distance[z] = 0;
|
||||
parent[z] = z;
|
||||
bool r = boost::bellman_ford_shortest_paths(g, int(N), weight,
|
||||
distance.begin(),
|
||||
parent.begin());
|
||||
if (r)
|
||||
for (int i = 0; i < N; ++i)
|
||||
std::cout << name[i] << ": " << distance[i]
|
||||
<< " " << name[parent[i]] << std::endl;
|
||||
else
|
||||
std::cout << "negative cycle" << std::endl;
|
||||
</PRE>
|
||||
The output is the distance from the root and the parent
|
||||
of each vertex in the shortest paths tree.
|
||||
<PRE>
|
||||
u: 2 v
|
||||
v: 4 x
|
||||
x: 7 z
|
||||
y: -2 u
|
||||
z: 0 z
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<p>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<a href="../../../boost/graph/edge_list.hpp"><TT>boost/graph/edge_list.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>EdgeIterator</TT></TD> <TD>Must be model of <a
|
||||
href="http://www.sgi.com/Technology/STL/InputIterator.html">InputIterator</a>
|
||||
who's <TT>value_type</TT> must be a pair of vertex descriptors.</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>ValueType</TT></TD>
|
||||
<TD>The <TT>value_type</TT> of the <TT>EdgeIterator</TT>.<br>
|
||||
Default: <TT>std::iterator_traits<EdgeIterator>::value_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>DiffType</TT></TD>
|
||||
<TD>The <TT>difference_type</TT> of the <TT>EdgeIterator</TT>.<br>
|
||||
Default: <TT>std::iterator_traits<EdgeIterator>::difference_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
<P>
|
||||
|
||||
<H3>Model of</H3>
|
||||
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a>
|
||||
|
||||
<P>
|
||||
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>boost::graph_traits<edge_list>::vertex_descriptor</tt>
|
||||
<br><br>
|
||||
The type for the vertex descriptors associated with the
|
||||
<TT>edge_list</TT>. This will be the same type as
|
||||
<TT>std::iterator_traits<EdgeIterator>::value_type::first_type</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
boost::graph_traits<edge_list>::edge_descriptor
|
||||
</tt>
|
||||
<br><br>
|
||||
The type for the edge descriptors associated with the
|
||||
<TT>edge_list</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
boost::graph_traits<edge_list>::edge_iterator
|
||||
</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <TT>edges()</TT>. The iterator
|
||||
category of the <TT>edge_iterator</TT> will be the same as that of the
|
||||
<TT>EdgeIterator</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
edge_list(EdgeIterator first, EdgeIterator last)
|
||||
</tt>
|
||||
<br><br>
|
||||
Creates a graph object with <TT>n</TT> vertices and with the
|
||||
edges specified in the edge list given by the range <TT>[first,last)</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<H3>Non-Member Functions</H3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
std::pair<edge_iterator, edge_iterator><br>
|
||||
edges(const edge_list& g)
|
||||
</tt>
|
||||
<br><br>
|
||||
Returns an iterator-range providing access to the edge set of graph <TT>g</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
vertex_descriptor<br>
|
||||
source(edge_descriptor e, const edge_list& g)
|
||||
</tt>
|
||||
<br><br>
|
||||
Returns the source vertex of edge <TT>e</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>
|
||||
vertex_descriptor<br>
|
||||
target(edge_descriptor e, const edge_list& g)
|
||||
</tt>
|
||||
<br><br>
|
||||
Returns the target vertex of edge <TT>e</TT>.
|
||||
|
||||
<hr>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
78
doc/faq.html
Normal file
@@ -0,0 +1,78 @@
|
||||
<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: FAQ</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1>Frequently Asked Questions</h1>
|
||||
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Why does the algorithm X work with <tt>adjacency_list</tt> where
|
||||
<tt>VertexList=vecS</tt> but not when <tt>VertexList=listS</tt>? <br><br>
|
||||
Often the reason is that the algorithm expects to find the
|
||||
<tt>vertex_index</tt> property stored in the graph. When
|
||||
<tt>VertexList=vecS</tt>, the <tt>adjacency_list</tt> automatically
|
||||
has a <tt>vertex_index</tt> property. However, when <tt>VertexList=listS</tt>
|
||||
this is not the case, and the <tt>vertex_index</tt> property must be
|
||||
explicitly added, and initialized. For example,
|
||||
<pre>
|
||||
// specify the graph type
|
||||
typedef adjacency_list<listS, listS, undirectedS,
|
||||
property<vertex_index_t, std::size_t>,
|
||||
no_property
|
||||
> graph_t;
|
||||
|
||||
// construct a graph object
|
||||
graph_t G(num_nodes);
|
||||
// obtain a property map for the vertex_index property
|
||||
property_map<graph_t, vertex_index_t>::type
|
||||
index = get(vertex_index, G);
|
||||
// initialize the vertex_index property values
|
||||
graph_traits<graph_t>::vertex_iterator vi, vend;
|
||||
graph_traits<graph_t>::vertices_size_type cnt = 0;
|
||||
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
|
||||
put(index, *vi, cnt++);
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>When using algorithm X, why do I get an error about a property
|
||||
not being found, such as:
|
||||
<pre>
|
||||
../../../boost/pending/concept_checks.hpp:209: no match for
|
||||
`boost::detail::error_property_not_found & ==
|
||||
boost::detail::error_property_not_found &'
|
||||
</pre>
|
||||
or a message such as:
|
||||
<pre>
|
||||
../../..\boost/graph/depth_first_search.hpp(78) : error C2664: 'white'
|
||||
: cannot convert parameter 1 from
|
||||
'struct boost::detail::error_property_not_found'
|
||||
to 'enum boost::default_color_type'
|
||||
</pre>
|
||||
|
||||
The reason is that the algorithm expected to find some property (like color or
|
||||
weight) attached to the vertices or edges of the graph, but didn't
|
||||
find it. You need to either add an interior property to the graph, or
|
||||
create an exterior property map for the property and pass it as an
|
||||
argument to the algorithm.</li>
|
||||
|
||||
|
||||
|
||||
</ol>
|
||||
40
doc/figs/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
.SUFFIXES: .fig .gif .tif .jpeg
|
||||
|
||||
.fig.gif:
|
||||
fig2dev -L gif $*.fig > $*.gif
|
||||
|
||||
.fig.tif:
|
||||
fig2dev -L tiff $*.fig > $*.tif
|
||||
|
||||
.fig.jpeg:
|
||||
fig2dev -L jpeg $*.fig > $*.jpg
|
||||
|
||||
|
||||
|
||||
FIG = \
|
||||
analogy.fig dfs_example.fig quick_start.fig \
|
||||
back_edges.fig dfs_family.fig stl_iter.fig \
|
||||
bfs_example.fig dfs_visitor.fig tree_edges.fig \
|
||||
bfs_family.fig disjoint_set_family.fig visitor.fig \
|
||||
bfs_visitor.fig file_dep.fig \
|
||||
concepts.fig forward_or_cross_edges.fig digraph.fig \
|
||||
undigraph.fig adj_matrix.fig adj_list.fig \
|
||||
edge_list.fig dfs.fig knights_tour.fig \
|
||||
search_states.fig graph_search.fig
|
||||
|
||||
|
||||
GIF = $(FIG:.fig=.gif)
|
||||
TIFF = $(FIG:.fig=.tif)
|
||||
JPEG = $(FIG:.fig=.jpg)
|
||||
|
||||
gifs: $(GIF)
|
||||
tiffs: $(TIFF)
|
||||
jpegs: $(JPEG)
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.gif *.tif *.jpg
|
||||
|
||||
|
||||
|
||||
59
doc/figs/adj_list.fig
Normal file
@@ -0,0 +1,59 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1156 2519 150 150 1156 2519 1306 2519
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1598 2541 150 150 1598 2541 1748 2541
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1148 2841 150 150 1148 2841 1298 2841
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1148 3141 150 150 1148 3141 1298 3141
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1150 3442 150 150 1150 3442 1300 3442
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1143 3746 150 150 1143 3746 1293 3746
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1592 2844 150 150 1592 2844 1742 2844
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2048 2541 150 150 2048 2541 2198 2541
|
||||
2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
|
||||
600 2100 900 2100 900 3900 600 3900 600 2100
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
600 2400 900 2400
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
600 2700 900 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
600 3000 900 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
600 3300 900 3300
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
600 3600 900 3600
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
900 2550 975 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1350 2550 1425 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
900 2850 975 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1275 2850 1425 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
900 3150 975 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
900 3450 975 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
900 3750 975 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1770 2565 1890 2565
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 675 2325 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 675 2625 b\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 675 2925 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 75 675 3225 z\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 75 675 3525 a\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 675 3825 y\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1125 2625 y\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1575 2625 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1125 2925 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1575 2925 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 75 1125 3525 z\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 75 1125 3225 a\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1125 3825 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2025 2625 y\001
|
||||
BIN
doc/figs/adj_list.gif
Normal file
|
After Width: | Height: | Size: 800 B |
31
doc/figs/adj_matrix.fig
Normal file
@@ -0,0 +1,31 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
|
||||
900 2100 2700 2100 2700 3900 900 3900 900 2100
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 675 2325 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 675 2625 b\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 675 2925 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 675 3225 z\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 675 3525 a\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 675 3825 y\001
|
||||
4 0 0 100 0 0 12 0.0000 4 180 1620 975 2025 v b x z a y\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2475 2625 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 975 3825 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2175 3225 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2925 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2625 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 975 2925 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1875 3525 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 1575 975 2325 0 0 0 0 0 0\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 1350 975 2625 0 0 0 0\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 1305 1275 2925 0 0 0 0\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 1575 975 3225 0 0 0 0 0\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 1575 975 3525 0 0 0 0 0\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 1305 1275 3825 0 0 0 0 0\001
|
||||
BIN
doc/figs/adj_matrix.gif
Normal file
|
After Width: | Height: | Size: 947 B |
35
doc/figs/analogy.fig
Normal file
@@ -0,0 +1,35 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 1 0 1 0 7 0 0 -1 0.000 1 0.0000 2400 1200 1200 675 2400 1200 1200 1875
|
||||
1 1 0 1 0 7 0 0 -1 0.000 1 0.0000 2320 4269 1200 675 2320 4269 1120 4944
|
||||
1 1 0 1 0 7 0 0 -1 0.000 1 0.0000 6000 1200 1200 675 6000 1200 4800 1875
|
||||
1 1 0 1 0 7 0 0 -1 0.000 1 0.0000 6000 4350 1200 675 6000 4350 4800 5025
|
||||
2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 1 2
|
||||
0 0 1.00 60.00 120.00
|
||||
0 0 1.00 60.00 120.00
|
||||
2325 1875 2325 3600
|
||||
2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 1 2
|
||||
0 0 1.00 60.00 120.00
|
||||
0 0 1.00 60.00 120.00
|
||||
5700 1875 5700 3675
|
||||
2 1 2 1 0 7 0 0 -1 3.000 0 0 -1 0 0 2
|
||||
4200 600 4200 4875
|
||||
4 0 0 0 0 0 18 0.0000 4 240 1770 1575 4350 STL Algorithms\001
|
||||
4 0 0 0 0 0 18 0.0000 4 210 1710 1650 1275 STL Containers\001
|
||||
4 0 0 0 0 0 18 0.0000 4 225 300 2025 5475 (a)\001
|
||||
4 0 0 0 0 0 18 0.0000 4 225 315 5700 5550 (b)\001
|
||||
4 0 0 0 0 0 18 0.0000 4 240 1965 5100 4425 Graph Algorithms\001
|
||||
4 0 0 0 0 0 18 0.0000 4 240 675 5700 1050 Graph\001
|
||||
4 0 0 0 0 0 18 0.0000 4 210 1665 5175 1350 Data Structures\001
|
||||
4 0 0 0 0 0 18 0.0000 4 180 795 2475 2700 Iterator\001
|
||||
4 0 0 0 0 0 18 0.0000 4 180 840 2475 3000 Functor\001
|
||||
4 0 0 0 0 0 18 0.0000 4 210 1590 5850 2475 Vertex Iterator\001
|
||||
4 0 0 100 0 0 18 0.0000 4 240 2010 5850 2850 Adjacency Iterator\001
|
||||
4 0 0 0 0 0 18 0.0000 4 240 2355 5850 3225 Visitor, Property Map\001
|
||||
BIN
doc/figs/analogy.gif
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
45
doc/figs/back_edges.fig
Normal file
@@ -0,0 +1,45 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1725 3525 2175 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3732 168 168 1950 3732 2100 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1875 3825 2\001
|
||||
-6
|
||||
6 2925 3525 3375 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3150 3732 168 168 3150 3732 3300 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3075 3825 3\001
|
||||
-6
|
||||
6 2325 1875 2775 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2100 168 168 2550 2100 2700 2175
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2475 2175 0\001
|
||||
-6
|
||||
6 1575 2625 2025 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2832 168 168 1800 2832 1950 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1725 2925 1\001
|
||||
-6
|
||||
6 3075 2625 3525 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 2832 168 168 3300 2832 3450 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3225 2925 4\001
|
||||
-6
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 6
|
||||
1 1 1.00 60.00 120.00
|
||||
1650 2925 1575 3150 1275 3225 1200 2775 1425 2550 1650 2775
|
||||
0.000 1.000 1.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3750 2550 3600 2100 3300 1950 2925
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3300 2700 3300 2400 3000 2100 2700 2100
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 2700 2775 2550 2175 2550 1875 2700
|
||||
0.000 1.000 1.000 0.000
|
||||
BIN
doc/figs/back_edges.gif
Normal file
|
After Width: | Height: | Size: 744 B |
72
doc/figs/bfs_example.fig
Normal file
@@ -0,0 +1,72 @@
|
||||
#FIG 3.2
|
||||
Portrait
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1057 3147 168 168 1057 3147 1207 3222
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1057 4046 168 168 1057 4046 1207 4121
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1963 3144 168 168 1963 3144 2113 3219
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1964 4033 168 168 1964 4033 2114 4108
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2850 3150 168 168 2850 3150 3000 3225
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2850 4050 168 168 2850 4050 3000 4125
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3750 3150 168 168 3750 3150 3900 3225
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3750 4050 168 168 3750 4050 3900 4125
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1050 3300 1050 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1200 3150 1800 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1950 3300 1950 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2700 3300 2100 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2175 4050 2700 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2850 3900 2850 3300
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3000 3150 3600 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3750 3300 3750 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3600 4050 3000 4050
|
||||
3 1 1 1 0 7 100 0 -1 4.000 0 0 0 13
|
||||
2250 3000 2100 2775 1950 2925 1725 2775 1725 3000 1500 3075
|
||||
1725 3300 1725 3525 2250 3450 2175 3375 2625 3300 2175 3150
|
||||
2325 3075
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000 1.000 1.000
|
||||
3 1 1 1 0 7 100 0 -1 4.000 0 0 0 18
|
||||
1875 2625 1500 2850 1050 2700 750 2925 750 3450 975 3450
|
||||
1275 3750 1500 3525 1650 3900 1650 4200 1950 4425 2475 4650
|
||||
2325 4125 2550 3975 2325 3675 2700 3450 2550 2925 2250 2700
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000
|
||||
3 1 1 1 0 7 100 0 -1 4.000 0 0 0 20
|
||||
2325 2625 1500 2625 900 2700 675 3000 675 3525 825 3750
|
||||
675 4050 900 4500 1125 4275 1500 4650 1725 4500 2400 4650
|
||||
2925 4350 3300 4350 3075 3900 3225 3600 3000 3450 3150 3000
|
||||
2625 2850 2625 2625
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000 1.000
|
||||
3 1 1 1 0 7 100 0 -1 4.000 0 0 0 19
|
||||
1800 2550 900 2625 675 2925 525 3525 675 4275 1050 4575
|
||||
1800 4725 3375 4500 4050 4275 4275 3900 3900 3675 4050 3450
|
||||
4050 3075 4050 2700 3600 2775 3300 2925 3075 2775 3000 2550
|
||||
2175 2550
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000
|
||||
4 0 0 100 0 0 12 0.0000 4 90 105 975 3225 r\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 135 975 4125 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 135 1875 3225 s\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 225 1875 4125 w \001
|
||||
4 0 0 100 0 0 12 0.0000 4 105 105 2775 3225 t\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 135 2775 4125 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 135 3675 3225 u\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3675 4125 y\001
|
||||
BIN
doc/figs/bfs_example.gif
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
50
doc/figs/bfs_family.fig
Normal file
@@ -0,0 +1,50 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3600 2550 4500 2100
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4800 3750 3750 3300
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4950 3750 3450 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4800 1950 4800 1500
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6000 2550 5100 2100
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3900 1425 2025 1425
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3975 2025 3000 2025
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3975 2025 3000 1800
|
||||
4 0 0 100 0 14 12 0.0000 4 165 2100 3900 1500 breadth_first_search\001
|
||||
4 0 0 100 0 14 12 0.0000 4 165 1785 4050 2100 best_first_search\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 2730 5100 2700 prim_minimum_spanning_tree\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 2415 2400 2700 dijkstra_shortest_paths\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 2835 900 3300 bellman_ford_shortest_paths\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 1470 1500 2100 fibonacci_heap\001
|
||||
4 0 0 100 0 14 12 0.0000 4 135 525 1500 1500 queue\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 3360 3300 3900 johnson_all_pairs_shortest_paths\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 4350 3225 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 3600 3600 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 5700 2400 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 4875 1800 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 3000 1350 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 3450 1875 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 3975 2475 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 3225 2250 <<uses>>\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 1365 1650 1800 mutable_queue\001
|
||||
BIN
doc/figs/bfs_family.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
73
doc/figs/bfs_visitor.fig
Normal file
@@ -0,0 +1,73 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1725 3525 2175 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3732 168 168 1950 3732 2100 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1875 3825 2\001
|
||||
-6
|
||||
6 2925 3525 3375 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3150 3732 168 168 3150 3732 3300 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3075 3825 3\001
|
||||
-6
|
||||
6 2325 1875 2775 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2100 168 168 2550 2100 2700 2175
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2475 2175 0\001
|
||||
-6
|
||||
6 1575 2625 2025 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2832 168 168 1800 2832 1950 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1725 2925 1\001
|
||||
-6
|
||||
6 3075 2625 3525 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 2832 168 168 3300 2832 3450 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3225 2925 4\001
|
||||
-6
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1500 4425 2025 4425
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1500 4650 2025 4650
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2250 2550 2850 2400 3375 2100 3675
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 6
|
||||
1 1 1.00 60.00 120.00
|
||||
1650 2925 1575 3150 1275 3225 1200 2775 1425 2550 1650 2775
|
||||
0.000 1.000 1.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 2775 2400 2850 2925 3225 3150 3600
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1875 3600 1650 3450 1650 3225 1725 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2100 3825 2400 4050 2850 4050 3075 3900
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3750 2550 3600 2100 3300 1950 2925
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 3600 3450 3450 3525 3225 3375 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3300 2700 3300 2400 3000 2100 2700 2100
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 2700 2775 2550 2175 2550 1875 2700
|
||||
0.000 1.000 1.000 0.000
|
||||
4 0 0 100 0 0 12 0.0000 4 180 780 2100 4500 Tree Edge\001
|
||||
4 0 0 100 0 0 12 0.0000 4 180 1515 2100 4725 Back or Cross Edge\001
|
||||
BIN
doc/figs/bfs_visitor.gif
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
44
doc/figs/concepts.fig
Normal file
@@ -0,0 +1,44 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6975 3150 7500 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6525 3825 7650 3075
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6975 2175 7575 2775
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3300 2025 5100 2025
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6975 2625 7575 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4350 2625 4800 2625
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4350 2550 5175 2100
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 3075 2850 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3900 3225 4875 3225
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2070 4350 3900 AdacencyMatrix\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2040 5175 2100 IncidenceGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2430 900 2100 BidirectionalGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 1935 4950 3300 EdgeListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 795 7575 3000 Graph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2145 4800 2700 AdjacencyGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 2100 2175 2700 VertexListGraph\001
|
||||
4 0 0 100 0 19 18 0.0000 4 255 3285 600 3300 VertexAndEdgeListGraph\001
|
||||
BIN
doc/figs/concepts.gif
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
77
doc/figs/dfs.fig
Normal file
@@ -0,0 +1,77 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2100 150 150 1800 2100 1800 2250
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2700 2100 150 150 2700 2100 2700 2250
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 3000 150 150 1800 3000 1800 3150
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2700 3000 150 150 2700 3000 2700 3150
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3600 2100 150 150 3600 2100 3600 2250
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3600 3000 150 150 3600 3000 3600 3150
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 3900 150 150 1800 3900 1800 4050
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2700 3900 150 150 2700 3900 2700 4050
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2700 4800 150 150 2700 4800 2700 4950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1950 2100 2550 2100
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1875 2250 2625 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1800 2250 1800 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1950 3000 2550 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2700 2250 2700 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2775 2850 3450 2175
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3600 2250 3600 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3450 3000 2850 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1950 3900 2550 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2625 4650 1950 3975
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2700 4050 2700 4650
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
1950 2100 2550 2100
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
2700 2250 2700 2850
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
2550 3000 1950 3000
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
2775 2850 3450 2175
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
3600 2250 3600 2850
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
1950 3900 2550 3900
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 3.00 90.00 150.00
|
||||
2700 4050 2700 4650
|
||||
4 0 0 100 0 0 12 0.0000 4 90 120 1725 2175 a\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2625 2175 b\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 120 3525 2175 c\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1725 3075 d\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 75 2625 3075 e\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 105 3525 3075 f\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1800 3975 g\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2625 3975 h\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2625 4875 i\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2100 2025 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2550 2550 2\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2250 2925 3\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2925 2550 4\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 3375 2625 5\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2100 3825 6\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2775 4275 7\001
|
||||
BIN
doc/figs/dfs.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
46
doc/figs/dfs_example.fig
Normal file
@@ -0,0 +1,46 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3150 168 168 1950 3150 2025 3300
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2850 3132 168 168 2850 3132 2925 3282
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3750 3132 168 168 3750 3132 3825 3282
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1932 4050 168 168 1932 4050 2007 4200
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2832 4050 168 168 2832 4050 2907 4200
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3732 4050 168 168 3732 4050 3807 4200
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 3300 1950 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2025 3975 2775 3225
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 90.00 120.00
|
||||
2700 4050 2100 4050
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 90.00 120.00
|
||||
2850 3300 2850 3900
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3600 3225 2925 3900
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 90.00 120.00
|
||||
3750 3300 3750 3900
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 90.00 120.00
|
||||
2100 3150 2700 3150
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 5
|
||||
1 1 1.00 60.00 120.00
|
||||
3825 4200 4050 4350 4275 4275 4200 3975 3900 4050
|
||||
0.000 1.000 1.000 1.000 0.000
|
||||
4 0 0 100 0 0 12 0.0000 4 90 180 1800 3225 u\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 180 2700 3225 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 225 3600 3225 w\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1875 4125 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2775 4125 y\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 3675 4125 z\001
|
||||
BIN
doc/figs/dfs_example.gif
Normal file
|
After Width: | Height: | Size: 813 B |
30
doc/figs/dfs_family.fig
Normal file
@@ -0,0 +1,30 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 2250 4050 1800
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6000 2250 4950 1800
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2400 2700 3300 1875
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2400 2700 2100 2325
|
||||
4 0 0 100 0 14 12 0.0000 4 180 1890 3000 1800 depth_first_search\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 3255 1500 2925 connected_components (strongly)\001
|
||||
4 0 0 100 0 14 12 0.0000 4 165 945 1500 2325 transpose\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 2100 3075 2400 connected_components\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 1680 5400 2400 topological_sort\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 1725 2625 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 2625 2625 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 4125 2100 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 5550 2025 <<uses>>\001
|
||||
BIN
doc/figs/dfs_family.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
77
doc/figs/dfs_visitor.fig
Normal file
@@ -0,0 +1,77 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1725 3525 2175 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3732 168 168 1950 3732 2100 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1875 3825 2\001
|
||||
-6
|
||||
6 2925 3525 3375 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3150 3732 168 168 3150 3732 3300 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3075 3825 3\001
|
||||
-6
|
||||
6 2325 1875 2775 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2100 168 168 2550 2100 2700 2175
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2475 2175 0\001
|
||||
-6
|
||||
6 1575 2625 2025 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2832 168 168 1800 2832 1950 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1725 2925 1\001
|
||||
-6
|
||||
6 3075 2625 3525 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 2832 168 168 3300 2832 3450 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3225 2925 4\001
|
||||
-6
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1350 4500 1800 4500
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1350 4725 1800 4725
|
||||
2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1350 4950 1800 4950
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 6
|
||||
1 1 1.00 60.00 120.00
|
||||
1650 2925 1575 3150 1275 3225 1200 2775 1425 2550 1650 2775
|
||||
0.000 1.000 1.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 2775 2400 2850 2925 3225 3150 3600
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1875 3600 1650 3450 1650 3225 1725 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3750 2550 3600 2100 3300 1950 2925
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 3600 3450 3450 3525 3225 3375 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3300 2700 3300 2400 3000 2100 2700 2100
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 2700 2775 2550 2175 2550 1875 2700
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2250 2550 2850 2400 3375 2100 3675
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 1 1 0 7 100 0 -1 4.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2100 3825 2400 4050 2850 4050 3075 3900
|
||||
0.000 1.000 1.000 0.000
|
||||
4 0 0 100 0 0 12 0.0000 4 180 780 2025 4575 Tree Edge\001
|
||||
4 0 0 100 0 0 12 0.0000 4 180 825 2025 4800 Back Edge\001
|
||||
4 0 0 100 0 0 12 0.0000 4 180 1755 2025 5025 Forward or Cross Edge\001
|
||||
BIN
doc/figs/dfs_visitor.gif
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
53
doc/figs/digraph.fig
Normal file
@@ -0,0 +1,53 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1650 2250 168 168 1650 2250 1800 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2232 1650 168 168 2232 1650 2382 1725
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2832 2250 168 168 2832 2250 2982 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2832 3150 168 168 2832 3150 2982 3225
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1632 3150 168 168 1632 3150 1782 3225
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2232 3750 168 168 2232 3750 2382 3825
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2700 3075 2325 2475 2250 1800
|
||||
0.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2700 2175 2250 2100 1800 2175
|
||||
0.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
1650 2100 1725 1725 2100 1725
|
||||
0.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 5
|
||||
1 1 1.00 60.00 120.00
|
||||
2925 3000 3225 2925 3300 3225 3150 3375 2925 3300
|
||||
0.000 -1.000 -1.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 3600 2100 3225 1800 3150
|
||||
0.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2775 2400 2700 2700 2775 3000
|
||||
0.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
1650 3300 1725 3600 2100 3750
|
||||
0.000 -1.000 0.000
|
||||
3 2 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2700 2325 2250 2250 1800 2325
|
||||
0.000 -1.000 0.000
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 2175 1725 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2775 2325 b\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 2775 3225 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 2175 3825 z\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1575 3225 a\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2325 y\001
|
||||
BIN
doc/figs/digraph.gif
Normal file
|
After Width: | Height: | Size: 880 B |
20
doc/figs/disjoint_set_family.fig
Normal file
@@ -0,0 +1,20 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2925 2250 4275 1575
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6150 2250 4875 1575
|
||||
4 0 0 100 0 14 12 0.0000 4 180 2940 1500 2400 dynamic_connected_components\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 3045 4800 2400 kruskal_minimum_spanning_tree\001
|
||||
4 0 0 100 0 14 12 0.0000 4 180 1365 3975 1500 disjoint_sets\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 2925 1950 <<uses>>\001
|
||||
4 0 0 100 0 -1 10 0.0000 4 75 555 5700 1950 <<uses>>\001
|
||||
BIN
doc/figs/disjoint_set_family.gif
Normal file
|
After Width: | Height: | Size: 988 B |
26
doc/figs/edge_list.fig
Normal file
@@ -0,0 +1,26 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
|
||||
600 2400 4800 2400 4800 2700 600 2700 600 2400
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1200 2400 1200 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1800 2400 1800 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2400 2400 2400 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3000 2400 3000 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
3600 2400 3600 2700
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
4200 2400 4200 2700
|
||||
2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
|
||||
4800 2400 5400 2400 5400 2700 4800 2700 4800 2400
|
||||
4 0 0 100 0 0 12 0.0000 4 180 4545 720 2625 (b, y) (b, y) (y, v) (z, a) (x, x) (b, x) (x, v) (a, z)\001
|
||||
BIN
doc/figs/edge_list.gif
Normal file
|
After Width: | Height: | Size: 562 B |
130
doc/figs/file_dep.fig
Normal file
@@ -0,0 +1,130 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 2100 3450 3000 3900
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 3675 450 225 2550 3675 3000 3900
|
||||
4 0 0 100 0 0 12 0.0000 4 180 555 2250 3750 foo.cpp\001
|
||||
-6
|
||||
6 2100 4200 3075 4725
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 2551 4428 450 225 2551 4428 3001 4653
|
||||
4 0 0 100 0 0 12 0.0000 4 135 375 2400 4500 foo.o\001
|
||||
-6
|
||||
6 3600 3450 4575 3975
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 4051 3678 450 225 4051 3678 4501 3903
|
||||
4 0 0 100 0 0 12 0.0000 4 180 555 3750 3750 bar.cpp\001
|
||||
-6
|
||||
6 3600 4200 4575 4650
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 4051 4425 450 225 4051 4425 4501 4650
|
||||
4 0 0 100 0 0 12 0.0000 4 135 375 3825 4500 bar.o\001
|
||||
-6
|
||||
6 2700 4950 3900 5400
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 5175 600 225 3300 5175 3900 5400
|
||||
4 0 0 100 0 0 12 0.0000 4 135 795 2925 5250 libfoobar.a\001
|
||||
-6
|
||||
6 4500 2250 5250 2700
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 4875 2475 375 225 4875 2475 5250 2700
|
||||
4 0 0 100 0 0 12 0.0000 4 180 450 4650 2550 yow.h\001
|
||||
-6
|
||||
6 2175 2250 2925 2700
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2475 375 225 2550 2475 2925 2700
|
||||
4 0 0 100 0 0 12 0.0000 4 135 450 2325 2550 zow.h\001
|
||||
-6
|
||||
6 3300 1650 4050 2100
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 3675 1875 375 225 3675 1875 4050 2100
|
||||
4 0 0 100 0 0 12 0.0000 4 135 405 3450 1950 dax.h\001
|
||||
-6
|
||||
6 4800 4200 5700 4650
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 5250 4425 450 225 5250 4425 5700 4650
|
||||
4 0 0 100 0 0 12 0.0000 4 180 540 5025 4500 zig.cpp\001
|
||||
-6
|
||||
6 4800 4950 5700 5400
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 5250 5175 450 225 5250 5175 5700 5400
|
||||
4 0 0 100 0 0 12 0.0000 4 180 360 5025 5250 zig.o\001
|
||||
-6
|
||||
6 6150 4200 7050 4650
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 6600 4425 450 225 6600 4425 7050 4650
|
||||
4 0 0 100 0 0 12 0.0000 4 135 585 6375 4500 zag.cpp\001
|
||||
-6
|
||||
6 6150 4950 7050 5400
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 6600 5175 450 225 6600 5175 7050 5400
|
||||
4 0 0 100 0 0 12 0.0000 4 135 405 6375 5250 zag.o\001
|
||||
-6
|
||||
6 4500 5850 5550 6300
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 5025 6075 525 225 5025 6075 5550 6300
|
||||
4 0 0 100 0 0 12 0.0000 4 180 810 4650 6150 libzigzag.a\001
|
||||
-6
|
||||
6 3000 6450 3900 6900
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 3450 6675 450 225 3450 6675 3900 6900
|
||||
4 0 0 100 0 0 12 0.0000 4 180 645 3150 6750 killerapp\001
|
||||
-6
|
||||
6 6000 2550 6750 3000
|
||||
1 1 0 1 0 7 100 0 -1 0.000 1 0.0000 6375 2775 375 225 6375 2775 6750 3000
|
||||
4 0 0 100 0 0 12 0.0000 4 135 405 6150 2850 boz.h\001
|
||||
-6
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2700 2550 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 3900 2550 4200
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 3900 4050 4200
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2700 4650 3000 4950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3975 4650 3675 4950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3825 5325 4650 5925
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4575 6150 3825 6525
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
5250 5400 5100 5850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6525 5400 5400 5925
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6600 4650 6600 4950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
5250 4650 5250 4950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 2025 2775 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3975 2025 4575 2400
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6075 2850 4425 3525
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6225 3000 5400 4200
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
6450 3000 6600 4200
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4725 2700 4200 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
5025 2700 6375 4275
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 2100 3975 3450
|
||||
3 0 1 1 0 7 100 0 -1 4.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3825 3450 3675 3150 3525 2550 3600 2100
|
||||
0.000 1.000 1.000 0.000
|
||||
BIN
doc/figs/file_dep.gif
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
33
doc/figs/forward_or_cross_edges.fig
Normal file
@@ -0,0 +1,33 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1725 3525 2175 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3732 168 168 1950 3732 2100 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1875 3825 2\001
|
||||
-6
|
||||
6 2925 3525 3375 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3150 3732 168 168 3150 3732 3300 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3075 3825 3\001
|
||||
-6
|
||||
6 2325 1875 2775 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2100 168 168 2550 2100 2700 2175
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2475 2175 0\001
|
||||
-6
|
||||
6 1575 2625 2025 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2832 168 168 1800 2832 1950 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1725 2925 1\001
|
||||
-6
|
||||
6 3075 2625 3525 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 2832 168 168 3300 2832 3450 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3225 2925 4\001
|
||||
-6
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2100 3825 2400 4050 2850 4050 3075 3900
|
||||
0.000 1.000 1.000 0.000
|
||||
BIN
doc/figs/forward_or_cross_edges.gif
Normal file
|
After Width: | Height: | Size: 537 B |
32
doc/figs/graph_search.fig
Normal file
@@ -0,0 +1,32 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3675 5100 3675 6150
|
||||
2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 3450 3750 4350
|
||||
2 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
|
||||
1800 4500 5700 4500
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
1800 2700 5700 2700 5700 6900 1800 6900 1800 2700
|
||||
3 3 2 1 0 7 50 0 -1 4.000 0 0 0 24
|
||||
2625 4350 3075 4125 3375 4275 3825 4050 4200 4200 4425 4425
|
||||
4725 4200 5100 4125 5475 4350 5625 4725 5475 5100 4725 5400
|
||||
4125 5400 3975 5175 3525 5475 3075 5475 3000 5175 2625 5250
|
||||
2250 5475 1950 5175 1950 4350 2175 4425 2325 4200 2550 4125
|
||||
-1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000
|
||||
-1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000
|
||||
-1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000 -1.000
|
||||
4 0 0 50 0 19 18 0.0000 4 195 1275 3075 6600 Examined\001
|
||||
4 0 0 50 0 19 18 0.0000 4 255 3225 2175 4800 Target-To-Be-Examined\001
|
||||
4 0 0 50 0 14 14 0.0000 4 195 2970 2400 5775 p.examine_vertex(u, g)\001
|
||||
4 0 0 50 0 14 14 0.0000 4 195 2700 2475 3900 p.examine_edge(e, g)\001
|
||||
4 0 0 50 0 19 18 0.0000 4 195 1605 2925 3225 Unexamined\001
|
||||
BIN
doc/figs/graph_search.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
211
doc/figs/knights_tour.fig
Normal file
@@ -0,0 +1,211 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 0 0.000 1 0.0000 1950 1950 75 75 1950 1950 1950 2025
|
||||
1 3 0 1 0 7 100 0 0 0.000 1 0.0000 2850 3150 75 75 2850 3150 2850 3225
|
||||
2 2 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 5
|
||||
1800 1800 4200 1800 4200 4200 1800 4200 1800 1800
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 1950 2250 2625
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 2625 1950 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 3150 2250 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 3750 2850 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 4050 3450 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 3750 4050 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 4050 3750 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 3450 4050 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 2850 3750 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 2250 3150 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 1950 2550 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2250 1950 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 2550 2250 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 1950 2850 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 2250 3450 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 1950 4050 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 2250 3450 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 2550 3750 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 1950 4050 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 2550 3750 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 3150 4050 3825
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 3825 3450 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 4050 3150 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 3450 3825 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3825 3750 4050 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 3150 3450 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 2850 3150 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 2250 2550 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 1950 1950 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2025 2250 2250 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 2850 1950 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 3450 2250 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 4050 2850 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 3750 2550 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 3150 1950 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 2850 2250 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 2325 2850 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 2550 3150 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 3150 2550 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 3450 1950 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 3750 2550 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 4050 3225 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 3750 3750 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 4050 4050 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 3525 3750 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 2850 3450 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3525 2325 4050 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
4050 1950 3750 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3750 2550 3150 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 2850 3450 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 3450 3150 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 4050 2775 3375
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 3375 3450 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3450 3150 2850 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 2850 2250 3150
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 3150 2550 3750
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 3675 1950 4050
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 3975 2250 3450
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 3525 2550 2850
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2925 3150 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3150 2625 2850 1950
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2850 1950 2550 2550
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2550 2850 3150
|
||||
4 0 0 100 0 0 12 0.0000 4 135 2205 1875 1725 0 1 2 3 4 5 6 7\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2025 0\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2325 1\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2700 2\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2925 3\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 3225 4\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 3525 5\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 3825 6\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 4125 7\001
|
||||
BIN
doc/figs/knights_tour.gif
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
72
doc/figs/quick_start.fig
Normal file
@@ -0,0 +1,72 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1932 2832 2268 3168
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2100 3000 168 168 2100 3000 2250 3075
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2070 3075 0\001
|
||||
-6
|
||||
6 1350 4314 1686 4650
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1518 4482 168 168 1518 4482 1668 4557
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1473 4557 4\001
|
||||
-6
|
||||
6 1350 3414 1686 3750
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1518 3582 168 168 1518 3582 1668 3657
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1503 3657 1\001
|
||||
-6
|
||||
6 2550 3414 2886 3750
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2718 3582 168 168 2718 3582 2868 3657
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2718 3657 2\001
|
||||
-6
|
||||
6 2550 4314 2886 4650
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2718 4482 168 168 2718 4482 2868 4557
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2703 4557 3\001
|
||||
-6
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 3150 1650 3450
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2145 3180 2205 3900 2550 4365
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2640 4335 2520 3705 2220 3180
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2250 3090 2430 3420 2580 3450
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2670 3420 2580 3120 2280 3030
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2610 3690 2235 4140 1680 4455
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2535 4455 1905 4125 1635 3780
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2595 4560 2115 4710 1635 4635
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
1515 4290 1320 4020 1485 3765
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
2010 3150 1725 3705 1545 4335
|
||||
0.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 3
|
||||
1 1 1.00 60.00 120.00
|
||||
1635 4365 2055 3765 2070 3135
|
||||
0.000 1.000 0.000
|
||||
BIN
doc/figs/quick_start.gif
Normal file
|
After Width: | Height: | Size: 923 B |
60
doc/figs/search_states.fig
Normal file
@@ -0,0 +1,60 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3300 3300 3300
|
||||
2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3600 3300 3600
|
||||
2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3900 3300 3900
|
||||
2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 4200 3300 4200
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
3300 2700 5400 2700 5400 3600 3300 3600 3300 2700
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
5400 2700 7800 2700 7800 3300 5400 3300 5400 2700
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
5400 3300 7800 3300 7800 3900 5400 3900 5400 3300
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
7800 2700 10200 2700 10200 3600 7800 3600 7800 2700
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
7800 3600 10200 3600 10200 4200 7800 4200 7800 3600
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
7800 4200 10200 4200 10200 4800 7800 4800 7800 4200
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
5400 3900 7800 3900 7800 4800 5400 4800 5400 3900
|
||||
2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5
|
||||
3300 3600 5400 3600 5400 4800 3300 4800 3300 3600
|
||||
3 0 2 1 0 7 50 0 -1 3.000 0 0 0 18
|
||||
3495 3705 3390 3510 3495 3315 3735 3390 3855 3240 4485 3360
|
||||
4845 3315 5160 3210 5340 3480 5295 4080 5070 4095 4785 3930
|
||||
4545 4110 3990 4185 3885 4035 3630 4200 3495 4140 3510 3705
|
||||
0.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
|
||||
1.000 0.000
|
||||
4 0 0 50 0 14 14 0.0000 4 195 2295 690 3345 examine_edge(u,v)\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 585 6270 3075 White\001
|
||||
4 0 0 50 0 19 14 0.0000 4 210 480 6315 3675 Gray\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 570 6300 4425 Black\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 585 8760 3240 White\001
|
||||
4 0 0 50 0 19 14 0.0000 4 210 480 8760 3975 Gray\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 570 8730 4560 Black\001
|
||||
4 0 0 50 0 14 14 0.0000 4 180 2295 690 3645 examine_vertex(v)\001
|
||||
4 0 0 50 0 14 14 0.0000 4 195 2835 150 3960 out_edges_examined(v)\001
|
||||
4 0 0 50 0 14 14 0.0000 4 195 2970 30 4260 previously_examined(v)\001
|
||||
4 0 0 50 0 18 14 0.0000 4 210 1395 3615 2505 Graph Search\001
|
||||
4 0 0 50 0 18 14 0.0000 4 165 1395 5880 2490 Breadth-First\001
|
||||
4 0 0 50 0 18 14 0.0000 4 210 1200 8370 2475 Depth-First\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 1275 3750 3075 Unexamined\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 1005 3825 4425 Examined\001
|
||||
4 0 0 50 0 19 14 0.0000 4 165 1740 3525 3675 To Be Processed\001
|
||||
BIN
doc/figs/search_states.gif
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
14
doc/figs/stl_iter.fig
Normal file
@@ -0,0 +1,14 @@
|
||||
#FIG 3.1
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
1200 2
|
||||
1 3 0 3 -1 -1 0 0 0 0.000 1 0.0000 2250 1350 1045 1045 2250 1350 3295 2395
|
||||
1 3 0 3 -1 -1 0 0 0 0.000 1 0.0000 6179 1370 1045 1045 6179 1370 7224 2415
|
||||
2 1 0 3 -1 7 0 0 0 0.000 0 0 -1 1 1 2
|
||||
1 1 3.00 180.00 360.00
|
||||
1 1 3.00 180.00 360.00
|
||||
3375 1350 5025 1350
|
||||
4 0 -1 0 0 18 24 0.0000 4 255 1875 1275 1500 Containers\001
|
||||
4 0 -1 0 0 18 24 0.0000 4 255 1425 3450 825 Iterators\001
|
||||
4 0 -1 0 0 18 24 0.0000 4 330 1905 5250 1425 Algorithms\001
|
||||
BIN
doc/figs/stl_iter.gif
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
45
doc/figs/tree_edges.fig
Normal file
@@ -0,0 +1,45 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1725 3525 2175 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3732 168 168 1950 3732 2100 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1875 3825 2\001
|
||||
-6
|
||||
6 2925 3525 3375 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3150 3732 168 168 3150 3732 3300 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3075 3825 3\001
|
||||
-6
|
||||
6 2325 1875 2775 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2100 168 168 2550 2100 2700 2175
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2475 2175 0\001
|
||||
-6
|
||||
6 1575 2625 2025 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2832 168 168 1800 2832 1950 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1725 2925 1\001
|
||||
-6
|
||||
6 3075 2625 3525 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 2832 168 168 3300 2832 3450 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3225 2925 4\001
|
||||
-6
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2250 2550 2850 2400 3375 2100 3675
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 2775 2400 2850 2925 3225 3150 3600
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1875 3600 1650 3450 1650 3225 1725 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 3600 3450 3450 3525 3225 3375 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
BIN
doc/figs/tree_edges.gif
Normal file
|
After Width: | Height: | Size: 733 B |
31
doc/figs/undigraph.fig
Normal file
@@ -0,0 +1,31 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1650 2250 168 168 1650 2250 1800 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2232 1650 168 168 2232 1650 2382 1725
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2832 2250 168 168 2832 2250 2982 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2832 3150 168 168 2832 3150 2982 3225
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1632 3150 168 168 1632 3150 1782 3225
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2232 3750 168 168 2232 3750 2382 3825
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
1725 3300 2100 3675
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2325 1800 2775 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2850 2400 2850 3000
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2700 2250 1800 2250
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 0 0 2
|
||||
2100 1725 1800 2100
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 2175 1725 v\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 2775 2325 b\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 2775 3225 x\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 2175 3825 z\001
|
||||
4 0 0 100 0 0 12 0.0000 4 90 90 1575 3225 a\001
|
||||
4 0 0 100 0 0 12 0.0000 4 135 90 1575 2325 y\001
|
||||
BIN
doc/figs/undigraph.gif
Normal file
|
After Width: | Height: | Size: 697 B |
77
doc/figs/visitor.fig
Normal file
@@ -0,0 +1,77 @@
|
||||
#FIG 3.2
|
||||
Landscape
|
||||
Center
|
||||
Inches
|
||||
Letter
|
||||
100.00
|
||||
Single
|
||||
-2
|
||||
1200 2
|
||||
6 1725 3525 2175 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1950 3732 168 168 1950 3732 2100 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1875 3825 2\001
|
||||
-6
|
||||
6 2925 3525 3375 3900
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3150 3732 168 168 3150 3732 3300 3807
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3075 3825 3\001
|
||||
-6
|
||||
6 2325 1875 2775 2325
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2550 2100 168 168 2550 2100 2700 2175
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 2475 2175 0\001
|
||||
-6
|
||||
6 1575 2625 2025 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 1800 2832 168 168 1800 2832 1950 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 1725 2925 1\001
|
||||
-6
|
||||
6 3075 2625 3525 3000
|
||||
1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 3300 2832 168 168 3300 2832 3450 2907
|
||||
4 0 0 100 0 0 12 0.0000 4 135 135 3225 2925 4\001
|
||||
-6
|
||||
2 1 0 3 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1350 4500 1800 4500
|
||||
2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1350 4725 1800 4725
|
||||
2 1 1 1 0 7 100 0 -1 4.000 0 0 -1 1 0 2
|
||||
1 1 1.00 60.00 120.00
|
||||
1350 4950 1800 4950
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 6
|
||||
1 1 1.00 60.00 120.00
|
||||
1650 2925 1575 3150 1275 3225 1200 2775 1425 2550 1650 2775
|
||||
0.000 1.000 1.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1950 2775 2400 2850 2925 3225 3150 3600
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
1875 3600 1650 3450 1650 3225 1725 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3000 3750 2550 3600 2100 3300 1950 2925
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 3600 3450 3450 3525 3225 3375 3000
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3300 2700 3300 2400 3000 2100 2700 2100
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 1 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
3225 2700 2775 2550 2175 2550 1875 2700
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 0 3 0 7 100 0 -1 0.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2550 2250 2550 2850 2400 3375 2100 3675
|
||||
0.000 1.000 1.000 0.000
|
||||
3 0 1 1 0 7 100 0 -1 4.000 0 1 0 4
|
||||
1 1 1.00 60.00 120.00
|
||||
2100 3825 2400 4050 2850 4050 3075 3900
|
||||
0.000 1.000 1.000 0.000
|
||||
4 0 0 100 0 0 12 0.0000 4 180 780 2025 4575 Tree Edge\001
|
||||
4 0 0 100 0 0 12 0.0000 4 180 825 2025 4800 Back Edge\001
|
||||
4 0 0 100 0 0 12 0.0000 4 180 1755 2025 5025 Forward or Cross Edge\001
|
||||
BIN
doc/figs/visitor.gif
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
402
doc/file_dependency_example.html
Normal file
@@ -0,0 +1,402 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>File Dependency Example</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="sec:file-depend-eg"></A>
|
||||
File Dependency Example
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
One of the most common uses of the graph abstraction in computer
|
||||
science is to track dependencies. An example of dependency tracking
|
||||
that we deal with on a day to day basis is the compilation
|
||||
dependencies for files in programs that we write. These dependencies
|
||||
are used inside programs such as <TT>make</TT> or in an IDE such as
|
||||
Visual C++ to minimize the number of files that must be recompiled
|
||||
after some changes have been made.
|
||||
|
||||
<P>
|
||||
<A HREF="#fig:file-dep">Figure 1</A> shows a graph that has a vertex
|
||||
for each source file, object file, and library that is used in the
|
||||
<TT>killerapp</TT> program. The edges in the graph show which files
|
||||
are used in creating other files. The choice of which direction to
|
||||
point the arrows is somewhat arbitrary. As long as we are consistent
|
||||
in remembering that the arrows mean ``used by'' then things will work
|
||||
out. The opposite direction would mean ``depends on''.
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:file-dep"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
|
||||
A graph representing file dependencies.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/file_dep.gif" width="331" height="351"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
A compilation system such as <TT>make</TT> has to be able to answer a
|
||||
number of questions:
|
||||
|
||||
<P>
|
||||
|
||||
<OL>
|
||||
<LI>If we need to compile (or recompile) all of the files, what order
|
||||
should that be done it?
|
||||
</LI>
|
||||
<LI>What files can be compiled in parallel?
|
||||
</LI>
|
||||
<LI>If a file is changed, which files must be recompiled?
|
||||
</LI>
|
||||
<LI>Are there any cycles in the dependencies? (which means the user
|
||||
has made a mistake and an error should be emitted)
|
||||
</LI>
|
||||
</OL>
|
||||
|
||||
<P>
|
||||
In the following examples we will formulate each of these questions in
|
||||
terms of the dependency graph, and then find a graph algorithm to
|
||||
provide the solution. The graph in <A HREF="#fig:file-dep">Figure
|
||||
1</A> will be used in all of the following examples. The source code
|
||||
for this example can be found in the file <a
|
||||
href="../example/file_dependencies.cpp"><TT>examples/file_dependencies.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Graph Setup</H2>
|
||||
|
||||
<P>
|
||||
Here we show the construction of the graph. For simplicity we have
|
||||
constructed the graph "by-hand". A compilation system such
|
||||
as <TT>make</TT> would instead parse a <TT>Makefile</TT> to get the
|
||||
list of files and to set-up the dependencies. We use the
|
||||
<TT>adjacency_list</TT> class to represent the graph. The
|
||||
<TT>vecS</TT> selector means that a <TT>std::vector</TT> will be used
|
||||
to represent each edge-list, which provides efficient traversal. The
|
||||
<TT>directedS</TT> selector means we want a directed graph, and the
|
||||
<TT>color_property</TT> attaches a color property to each vertex of the
|
||||
graph. The color property will be used in several of the algorithms in
|
||||
the following sections.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
enum files_e { dax_h, yow_h, boz_h, zow_h, foo_cpp,
|
||||
foo_o, bar_cpp, bar_o, libfoobar_a,
|
||||
zig_cpp, zig_o, zag_cpp, zag_o,
|
||||
libzigzag_a, killerapp, N };
|
||||
const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp",
|
||||
"foo.o", "bar.cpp", "bar.o", "libfoobar.a",
|
||||
"zig.cpp", "zig.o", "zag.cpp", "zag.o",
|
||||
"libzigzag.a", "killerapp" };
|
||||
|
||||
typedef std::pair<int, int> Edge;
|
||||
Edge used_by[] = {
|
||||
Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h),
|
||||
Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp),
|
||||
Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp),
|
||||
Edge(zow_h, foo_cpp),
|
||||
Edge(foo_cpp, foo_o),
|
||||
Edge(foo_o, libfoobar_a),
|
||||
Edge(bar_cpp, bar_o),
|
||||
Edge(bar_o, libfoobar_a),
|
||||
Edge(libfoobar_a, libzigzag_a),
|
||||
Edge(zig_cpp, zig_o),
|
||||
Edge(zig_o, libzigzag_a),
|
||||
Edge(zag_cpp, zag_o),
|
||||
Edge(zag_o, libzigzag_a),
|
||||
Edge(libzigzag_a, killerapp)
|
||||
};
|
||||
|
||||
using namespace boost;
|
||||
typedef adjacency_list<vecS, vecS, directedS,
|
||||
property<vertex_color_t, default_color_type>,
|
||||
property<edge_weight_t, int>
|
||||
> Graph;
|
||||
Graph g(N, used_by, used_by + sizeof(used_by) / sizeof(Edge));
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Compilation Order (All Files)</H2>
|
||||
|
||||
<P>
|
||||
On the first invocation of <TT>make</TT> for a particular project, all
|
||||
of the files must be compiled. Given the dependencies between the
|
||||
various files, what is the correct order in which to compile and link
|
||||
them? First we need to formulate this in terms of a graph. Finding a
|
||||
compilation order is the same as ordering the vertices in the graph.
|
||||
The constraint on the ordering is the file dependencies which we have
|
||||
represented as edges. So if there is an edge <i>(u,v)</i> in the graph
|
||||
then <i>v</i> better not come before <i>u</i> in the ordering. It
|
||||
turns out that this kind of constrained ordering is called a
|
||||
<I>topological sort</I>. Therefore, answering the question of
|
||||
compilation order is as easy as calling the BGL algorithm <a
|
||||
href="./topological_sort.html"><TT>topological_sort()</TT></a>. The
|
||||
traditional form of the output for topological sort is a linked-list
|
||||
of the sorted vertices. The BGL algorithm instead puts the sorted
|
||||
vertices into any <a
|
||||
href="http://www.sgi.com/Technology/STL/OutputIterator.html">OutputIterator</a>,
|
||||
which allows for much more flexibility. Here we use the
|
||||
<TT>std::front_insert_iterator</TT> to create an output iterator that
|
||||
inserts the vertices on the front of a linked list. Other possible
|
||||
options are writing the output to a file or inserting into a different
|
||||
STL or custom-made container.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
typedef std::list<Vertex> MakeOrder;
|
||||
MakeOrder make_order;
|
||||
boost::topological_sort(g, std::front_inserter(make_order));
|
||||
|
||||
std::cout << "make ordering: ";
|
||||
for (MakeOrder::iterator i = make_order.begin();
|
||||
i != make_order.end(); ++i)
|
||||
std::cout << name[*i] << " ";
|
||||
std::cout << std::endl;
|
||||
</PRE>
|
||||
The output of this is:
|
||||
<PRE>
|
||||
make ordering: zow.h boz.h zig.cpp zig.o dax.h yow.h zag.cpp \
|
||||
zag.o bar.cpp bar.o foo.cpp foo.o libfoobar.a libzigzag.a killerapp
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:parallel-compilation"></A>
|
||||
Parallel Compilation
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
Another question the compilation system might need to answer is: what
|
||||
files can be compiled simultaneously? This would allow the system to
|
||||
spawn threads and utilize multiple processors to speed up the build.
|
||||
This question can also be put in a slightly different way: what is the
|
||||
earliest time that a file can be built assuming that an unlimited
|
||||
number of files can be built at the same time? The main criteria for
|
||||
when a file can be built is that all of the files it depends on must
|
||||
already be built. To simplify things for this example, we'll assume
|
||||
that each file takes 1 time unit to build (even header files). The
|
||||
main observation for determining the ``time slot'' for a file is that
|
||||
the time slot must be one more than the maximum time-slot of the files
|
||||
it depends on.
|
||||
|
||||
<P>
|
||||
This idea of calculating a value based on the previously computed
|
||||
values of neighboring vertices is the same idea behind Dijkstra's
|
||||
single-source shortest paths algorithm (see <a
|
||||
href="./dijkstra_shortest_paths.html"><tt>dijkstra_shortest_paths()</tt></a>). The
|
||||
main difference between this situation and a shortest-path algorithm
|
||||
is that we want to use the maximum of the neighbors' values instead of
|
||||
the minimum. In addition, we do not have a single source
|
||||
vertex. Instead we will want to treat all vertices with in-degree of
|
||||
zero as sources (i.e., vertices with no edges coming into them). So we
|
||||
can not use Dijkstra's algorithm, but we can use a generalized version
|
||||
of Dijkstra's algorithm which is called <a
|
||||
href="./uniform_cost_search.html"><TT>uniform_cost_search()</TT></a>.
|
||||
|
||||
<P>
|
||||
To use <TT>uniform_cost_search()</TT>, we must first set up the vertex
|
||||
and edge properties that will be used in the algorithm. We will need
|
||||
a time property (replacing the distance property of Dijkstra's
|
||||
algorithm) and an edge weight property. We will use a
|
||||
<TT>std::vector</TT> to store the time. The weight property has already
|
||||
been attached to the graph via a plug-in so here we just declare an
|
||||
map for the internal weight property.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
std::vector<int> time(N, 0);
|
||||
typedef std::vector<int>::iterator Time;
|
||||
using boost::edge_weight_t;
|
||||
typedef boost::property_map<Graph, edge_weight_t>::type Weight;
|
||||
Weight weight = get(edge_weight, g);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The next step is to identify the vertices with zero in-degree which
|
||||
will be our ``source'' vertices from which to start the uniform cost
|
||||
searches. The in-degrees can be calculated with the following loop.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
std::vector<int> in_degree(N, 0);
|
||||
Graph::vertex_iterator i, iend;
|
||||
Graph::out_edge_iterator j, jend;
|
||||
for (boost::tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
for (boost::tie(j, jend) = out_edges(*i, g); j != jend; ++j)
|
||||
in_degree[target(*j, g)] += 1;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Next we need to define comparison of the "cost". In this
|
||||
case we want each file to have a time stamp greater than any of its
|
||||
predecessors. Therefore we define comparison with the
|
||||
<TT>std::greater<int></TT> function object. We also need to
|
||||
tell the algorithm that we want to use addition to combine time
|
||||
values, so we use <TT>std::plus<int></TT>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
std::greater<int> compare;
|
||||
std::plus<int> combine;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
We are now ready to call <TT>uniform_cost_search()</TT>. We just
|
||||
loop through all the vertices in the graph, and invoke the algorithm
|
||||
if the vertex has zero in-degree.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
for (boost::tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
if (in_degree[*i] == 0)
|
||||
boost::uniform_cost_search(g, *i, time.begin(),
|
||||
weight, compare, combine);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Last, we output the time-slot that we've calculated for each vertex.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
std::cout << "parallel make ordering, " << std::endl
|
||||
<< " vertices with same group number" << std::endl
|
||||
<< " can be made in parallel" << std::endl << std::endl;
|
||||
for (boost::tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
std::cout << "time_slot[" << name[*i] << "] = " << time[*i] << std::endl;
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
parallel make ordering,
|
||||
vertices with same group number
|
||||
can be made in parallel
|
||||
time_slot[dax.h] = 0
|
||||
time_slot[yow.h] = 1
|
||||
time_slot[boz.h] = 0
|
||||
time_slot[zow.h] = 0
|
||||
time_slot[foo.cpp] = 1
|
||||
time_slot[foo.o] = 2
|
||||
time_slot[bar.cpp] = 2
|
||||
time_slot[bar.o] = 3
|
||||
time_slot[libfoobar.a] = 4
|
||||
time_slot[zig.cpp] = 1
|
||||
time_slot[zig.o] = 2
|
||||
time_slot[zag.cpp] = 2
|
||||
time_slot[zag.o] = 3
|
||||
time_slot[libzigzag.a] = 5
|
||||
time_slot[killerapp] = 6
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<H2><A NAME="SECTION001014000000000000000"></A>
|
||||
<A NAME="sec:cycles"></A>
|
||||
<BR>
|
||||
Cyclic Dependencies
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
Another question the compilation system needs to be able to answer is
|
||||
whether there are any cycles in the dependencies. If there are cycles,
|
||||
the system will need to report an error to the user so that the cycles
|
||||
can be removed. One easy way to detect a cycle is to run a <a
|
||||
href="./depth_first_search.html">depth-first search</a>, and if the
|
||||
search runs into an already discovered vertex (of the current search
|
||||
tree), then there is a cycle. An already discovered vertex will have
|
||||
been colored gray, so we can insert a check for this color in the
|
||||
depth-first search. The BGL graph search algorithms (which includes
|
||||
<TT>depth_first_search()</TT>) are all extensible via the
|
||||
<I>visitor</I> mechanism. A visitor is similar to a function object,
|
||||
but it has several methods instead of just the one
|
||||
<TT>operator()</TT>. The visitor's methods are called at certain
|
||||
points within the algorithm, thereby giving the user a way to extend
|
||||
the functionality of the graph search algorithms. See Section <A
|
||||
HREF="visitor_concepts.html">Visitor Concepts</A>
|
||||
for a detailed description of visitors.
|
||||
|
||||
<P>
|
||||
We will create a visitor class and fill in the <TT>back_edge()</TT>
|
||||
method, which is the <a href="./DFSVisitor.html">DFSVisitor</a> method
|
||||
that is called when DFS explores a new edge. This is the place where
|
||||
we want to place the color check which will determine whether there
|
||||
are cyclic dependencies. Inheriting from <TT>dfs_visitor<></TT>
|
||||
provides the visitor with empty versions of the other visitor methods.
|
||||
Once our visitor is created, we can construct and object and pass it
|
||||
to the BGL algorithm. Visitor objects are passed by value inside of
|
||||
the BGL algorithms, so the <TT>has_cycle</TT> flag is stored by
|
||||
reference in this visitor.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class Color>
|
||||
struct cycle_detector : public dfs_visitor<>
|
||||
{
|
||||
typedef typename boost::property_traits<Color>::value_type C;
|
||||
|
||||
cycle_detector(Color c, bool& has_cycle)
|
||||
: _has_cycle(has_cycle), color(c) { }
|
||||
|
||||
template <class Edge, class Graph>
|
||||
void back_edge(Edge e, Graph& g) {
|
||||
_has_cycle = true;
|
||||
}
|
||||
protected:
|
||||
bool& _has_cycle;
|
||||
Color color;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
We can now invoke the BGL <TT>depth_first_search()</TT>
|
||||
algorithm and pass in the cycle detector visitor.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
bool has_cycle = false;
|
||||
cycle_detector<Color> vis(color, has_cycle);
|
||||
boost::depth_first_search(g, vis);
|
||||
std::cout << "The graph has a cycle? " << has_cycle << std::endl;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The graph in <A HREF="#fig:file-dep">Figure 1</A> (ignoring the dotted
|
||||
line) did not have any cycles, but if we add a dependency between
|
||||
<TT>bar.cpp</TT> and <TT>dax.h</TT> there there will be. Such a
|
||||
dependency would be flagged as a user error.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
add_edge(bar_cpp, dax_h, g);
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
195
doc/graph_coloring.html
Normal file
@@ -0,0 +1,195 @@
|
||||
<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>Graph Coloring Example</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>Graph Coloring</H1>
|
||||
|
||||
The graph (or vertex) coloring problem, which involves assigning
|
||||
colors to vertices in a graph such that adjacenct vertices have
|
||||
distinct colors, arises in a number of scientific and engineering
|
||||
applications such as scheduling , register allocation ,
|
||||
optimization and parallel numerical computation.
|
||||
|
||||
<P>
|
||||
Mathmatically, a proper vertex coloring of an undirected graph
|
||||
<i>G=(V,E)</i> is a map <i>c: V -> S</i> such that <i>c(u) != c(v)</i>
|
||||
whenever there exists an edge <i>(u,v)</i> in <i>G</i>. The elements
|
||||
of set <i>S</i> are called the available colors. The problem is often
|
||||
to determine the minimum cardinality (the number of colors) of
|
||||
<i>S</i> for a given graph <i>G</i> or to ask whether it is able to
|
||||
color graph <i>G</i> with a certain number of colors. For example, how
|
||||
many color do we need to color the United States on a map in such a
|
||||
way that adjacent states have different color? A compiler needs to
|
||||
decide whether variables and temporaries could be allocated in fixed
|
||||
number of registers at some point. If a target machine has <i>K</i>
|
||||
registers, can a particular interference graph be colored with
|
||||
<i>K</i> colors? (Each vertex in the interference graph represents a
|
||||
temporary value; each edge indicates a pair of temporaries that cannot
|
||||
be assigned to the same register.)
|
||||
|
||||
<P>
|
||||
Another example is in the estimation of sparse Jacobian matrix by
|
||||
differences in large scale nonlinear problems in optimization and
|
||||
differential equations. Given a nonlinear function <i>F</i>, the
|
||||
estimation of Jacobian matrix <i>J</i> can be obtained by estimating
|
||||
<i>Jd</i> for suitable choices of vector <i>d</i>. Curtis, Powell and
|
||||
Reid [<a href="bibliography.html#curtis74:_jacob">9</a>] observed that a group of columns of <i>J</i> can be
|
||||
determined by one evaluation of <i>Jd</i> if no two columns in this
|
||||
group have a nonzero in the same row position. Therefore, a question
|
||||
is emerged: what is the number of function evaluations need to compute
|
||||
approximate Jacobian matrix? As a matter of fact this question is the
|
||||
same as to compute the minimum numbers of colors for coloring a graph
|
||||
if we construct the graph in the following matter: A vertex represents
|
||||
a column of <i>J</i> and there is an edge if and only if the two
|
||||
column have a nonzero in the same row position.
|
||||
|
||||
<P>
|
||||
However, coloring a general graph with the minimum number of colors
|
||||
(the cardinality of set <i>S</i>) is known to be an NP-complete
|
||||
problem [<a
|
||||
href="bibliography.html#garey79:computers-and-intractability">30</a>].
|
||||
One often relies on heuristics to find a solution. A widely-used
|
||||
general greedy based approach is starting from an ordered vertex
|
||||
enumeration <i>v<sub>1</sub>, ..., v<sub>n</sub></i> of <i>G</i>, to
|
||||
assign <i>v<sub>i</sub></i> to the smallest possible color for
|
||||
<i>i</i> from <i>1</i> to <i>n</i>. In section <a
|
||||
href="constructing_algorithms.html">Constructing graph
|
||||
algorithms with BGL</a> we have shown how to write this algorithm in
|
||||
the generic programming paradigm. However, the ordering of the
|
||||
vertices dramatically affects the coloring. The arbitrary order may
|
||||
perform very poorly while another ordering may produces an optimal
|
||||
coloring. Several ordering algorithms have been studied to help the
|
||||
greedy coloring heuristics including largest-first ordering,
|
||||
smallest-last ordering and incidence degree ordering.
|
||||
|
||||
<P>
|
||||
In the BGL framework, the process of constructing/prototyping such a
|
||||
ordering is fairly easy because writing such a ordering follows the
|
||||
algorithm description closely. As an example, we present the
|
||||
smallest-last ordering algorithm.
|
||||
|
||||
<P>
|
||||
The basic idea of the smallest-last ordering [<a
|
||||
href="bibliography.html#matula72:_graph_theory_computing">29</a>] is
|
||||
as follows: Assuming that the vertices <i>v<sub>k+1</sub>, ...,
|
||||
v<sub>n</sub></i> have been selected, choose <i>v<sub>k</sub></i> so
|
||||
that the degree of <i>v<sub>k</sub></i> in the subgraph induced by
|
||||
<i>V - {v<sub>k+1</sub>, ..., v<sub>n</sub>}</i> is minimal.
|
||||
|
||||
<P>
|
||||
The algorithm uses a bucket sorter for the vertices in the graph where
|
||||
bucket is the degree. Two vertex property maps, <TT>degree</TT> and
|
||||
<TT>marker</TT>, are used in the algorithm. The former is to store
|
||||
degree of every vertex while the latter is to mark whether a vertex
|
||||
has been ordered or processed during traversing adjacent vertices. The
|
||||
ordering is stored in the <TT>order</TT>. The algorithm is as follows:
|
||||
|
||||
<UL>
|
||||
<LI>put all vertices in the bucket sorter
|
||||
</LI>
|
||||
<LI>find the vertex <tt>node</tt> with smallest degree in the bucket sorter
|
||||
</LI>
|
||||
<LI>number <tt>node</tt> and traverse through its adjacent vertices to
|
||||
update its degree and the position in the bucket sorter.
|
||||
</LI>
|
||||
<LI>go to the step 2 until all vertices are numbered.
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
namespace boost {
|
||||
template <class VertexListGraph, class Order, class Degree,
|
||||
class Marker, class BucketSorter>
|
||||
void
|
||||
smallest_last_ordering(const VertexListGraph& G, Order order,
|
||||
Degree degree, Marker marker,
|
||||
BucketSorter& bucket_sorter) {
|
||||
typedef typename graph_traits<VertexListGraph> GraphTraits;
|
||||
|
||||
typedef typename GraphTraits::vertex_descriptor Vertex;
|
||||
//typedef typename GraphTraits::size_type size_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
const size_type num = num_vertices(G);
|
||||
|
||||
typename GraphTraits::vertex_iterator v, vend;
|
||||
for (tie(v, vend) = vertices(G); v != vend; ++v) {
|
||||
put(marker, *v, num);
|
||||
put(degree, *v, out_degree(*v, G));
|
||||
degree_buckets.push(*v);
|
||||
}
|
||||
|
||||
size_type minimum_degree = 1;
|
||||
size_type current_order = num - 1;
|
||||
|
||||
while ( 1 ) {
|
||||
typedef typename BucketSorter::stack MDStack;
|
||||
MDStack minimum_degree_stack = degree_buckets[minimum_degree];
|
||||
while (minimum_degree_stack.empty())
|
||||
minimum_degree_stack = degree_buckets[++minimum_degree];
|
||||
|
||||
Vertex node = minimum_degree_stack.top();
|
||||
put(order, current_order, node);
|
||||
|
||||
if ( current_order == 0 ) //find all vertices
|
||||
break;
|
||||
|
||||
minimum_degree_stack.pop();
|
||||
put(marker, node, 0); //node has been ordered.
|
||||
|
||||
typename GraphTraits::adjacency_iterator v, vend;
|
||||
for (tie(v,vend) = adjacent_vertices(node, G); v != vend; ++v)
|
||||
|
||||
if ( get(marker, *v) > current_order ) { //*v is unordered vertex
|
||||
put(marker, *v, current_order); //mark the columns adjacent to node
|
||||
|
||||
//It is possible minimum degree goes down
|
||||
//Here we keep tracking it.
|
||||
put(degree, *v, get(degree, *v) - 1);
|
||||
minimum_degree = std::min(minimum_degree, get(degree, *v));
|
||||
|
||||
//update the position of *v in the bucket sorter
|
||||
degree_buckets.update(*v);
|
||||
}
|
||||
|
||||
current_order--;
|
||||
}
|
||||
//at this point, get(order, i) == vertex(i, g);
|
||||
}
|
||||
} // namespace boost
|
||||
</PRE>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
494
doc/graph_concepts.html
Normal file
@@ -0,0 +1,494 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes 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 Concepts</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="chapter:graph-concepts"></A>
|
||||
Graph Concepts
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
The heart of the Boost Graph Library (BGL) is the interface, or
|
||||
concepts (in the parlance of generic programming), that define how a
|
||||
graph can be examined and manipulated in a data-structure neutral
|
||||
fashion. In fact, the BGL interface need not even be implemented using
|
||||
a data-structure, as for some problems it is easier or more efficient
|
||||
to define a graph implicitly based on some functions.
|
||||
|
||||
<P>
|
||||
The BGL interface does not appear as a single graph concept. Instead
|
||||
it is factored into much smaller peices. The reason for this is that
|
||||
the purpose of a concept is to summarize the requirements for
|
||||
<i>particular</i> algorithms. Any one algorithm does not need every
|
||||
kind of graph operation, typically only a small subset. Furthermore,
|
||||
there are many graph data-structures that can not provide efficient
|
||||
implementations of all the operations, but provide highly efficient
|
||||
implementations of the operations necessary for a particular algorithm
|
||||
. By factoring the graph interface into many smaller concepts we
|
||||
provide the graph algorithm writer with a good selection from which to
|
||||
choose the concept that is the closest match for their algorithm.
|
||||
|
||||
<H2>Graph Structure Concepts Overview</H2>
|
||||
|
||||
<P>
|
||||
<A HREF="#fig:graph-concepts">Figure 1</A> shows the refinements
|
||||
relations between the graph concepts. The reason for factoring the
|
||||
graph interface into so many concepts is to encourage algorithm
|
||||
interfaces to require and use only the minimum interface of a graph,
|
||||
thereby increasing the reusability of the algorithm.
|
||||
|
||||
|
||||
<p></p>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:graph-concepts"></A></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
|
||||
The graph concepts and refinement relationships.
|
||||
</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/concepts.gif" width="519" height="139"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
<p></p>
|
||||
|
||||
Table <A HREF="#tab:graph-concept-reqs"><IMG ALIGN="BOTTOM"
|
||||
BORDER="1" ALT="[*]"
|
||||
SRC="file:/usr/local/src/teTeX00/lib/latex2html/icons/crossref.gif"></A>
|
||||
gives a summary of the valid expressions and associated types for the
|
||||
graph concepts and provides links to the detailed descriptions of
|
||||
each of the concepts. The notation used in the table is as follows.
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>G</tt></TD>
|
||||
<TD>A type that is a model of Graph.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::edge_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>e_iter</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::out_edge_iterator</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>u,v</tt></TD>
|
||||
<TD>Are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><TT>ep</TT></TD><TD>is an object of type <TT>G::edge_property_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><TT>vp</TT></TD><TD>is an object of type <TT>G::vertex_property_type</TT></TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>Property</tt></TD>
|
||||
<TD>A type used to specify a vertex or edge property.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>property</tt></TD>
|
||||
<TD>An object of type <tt>Property</tt>.</td>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<P>
|
||||
<BR><P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="7932"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Table:</STRONG>
|
||||
Summary of the graph concepts.
|
||||
</CAPTION>
|
||||
<TR><TD>
|
||||
<TABLE border>
|
||||
<TR><TH ALIGN="LEFT">
|
||||
<B>Expression</B> </TH>
|
||||
<TH ALIGN="LEFT" VALIGN="TOP"> <B>Return Type or Description</B> </TH>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./Graph.html">Graph</a> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::vertex_descriptor</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> The type for
|
||||
vertex representative objects. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::edge_descriptor</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> The type for
|
||||
edge representative objects. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::directed_category</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Directed or undirected? </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::edge_parallel_category</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Allow parallel edges? </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./IncidenceGraph.html">IncidenceGraph</a> refines Graph </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::out_edge_iterator</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Iterate through
|
||||
the out-edges. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::degree_size_type</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> The integer type for
|
||||
vertex degee. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>out_edges(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>std::pair<out_edge_iterator, out_edge_iterator></TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>source(e, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertex_descriptor</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>target(e, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertex_descriptor</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>out_degree(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>degree_size_type</TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./BidirectionalGraph.html">BidirectionalGraph</a> refines
|
||||
IncidenceGraph </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::in_edge_iterator</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Iterate through the in-edges. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>in_edges(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>std::pair<in_edge_iterator, in_edge_iterator></TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>in_degree(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>degree_size_type</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>degree(e, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>degree_size_type</TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./AdjacencyGraph.html">AdjacencyGraph</a> refines Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::adjacency_iterator</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Iterate through
|
||||
adjacent vertices. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>adjacent_vertices(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"><TT>std::pair<adjacency_iterator, adjacency_iterator></TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./VertexListGraph.html">VertexListGraph</a> refines
|
||||
IncidenceGraph and AdjacencyGraph </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::vertex_iterator</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Iterate through the
|
||||
graph's vertex set. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::vertices_size_type</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> The unsigned integer type for
|
||||
number of vertices in the graph. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>vertices(g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"><TT>std::pair<vertex_iterator, vertex_iterator></TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>num_vertices(g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertices_size_type</TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./EdgeListGraph.html">EdgeListGraph</a> refines Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::edge_iterator</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Iterate through the graph's
|
||||
edge set. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::edges_size_type</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> The unsigned integer type for
|
||||
number of edges in the graph. </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>edges(g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>std::pair<edge_iterator, edge_iterator></TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>num_edges(g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>edges_size_type</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>source(e, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertex_descriptor</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>target(e, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertex_descriptor</TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./AdjacencyMatrix.html">AdjacencyMatrix</a> refines Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>edge(u, v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>std::pair<edge_descriptor, bool></TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./MutableGraph.html">MutableGraph</a> refines
|
||||
Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>add_vertex(g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertex_descriptor</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>clear_vertex(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>void</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>remove_vertex(v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>void</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>add_edge(u, v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>std::pair<edge_descriptor, bool></TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>remove_edge(u, v, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>void</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>remove_edge(e, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>void</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>remove_edge(e_iter, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>void</TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./MutablePropertyGraph.html">MutablePropertyGraph</a> refines
|
||||
Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>add_vertex(vp, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>vertex_descriptor</TT> </TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>add_edge(u, v, ep, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> <TT>std::pair<edge_descriptor,
|
||||
bool></TT> </TD>
|
||||
</TR>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR>
|
||||
<TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./PropertyGraph.html">PropertyGraph</a> refines Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::property_map<G, Property>::type</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP">Type for a mutable property map.</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::property_map<G, Property>::const_type</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP">Type for a non-mutable property map.</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>get(property, g)</TT> </TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP"> Function to get a property map. </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>get(property, g, x)</TT>
|
||||
</TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP">Get property value for vertex or edge <tt>x</tt>. </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>put(property, g, x, v)</TT>
|
||||
</TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP">Set property value for vertex or edge
|
||||
<tt>x</tt> to <tt>v</tt>. </TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
</table>
|
||||
</DIV><P></P>
|
||||
<BR>
|
||||
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:undirected-graphs"></A>
|
||||
Undirected Graphs
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
The interface that the BGL provides for accessing and manipulating an
|
||||
undirected graph is the same as the interface for directed graphs
|
||||
described in the following sections, however there are some
|
||||
differences in the behaviour and semantics. For example, in a
|
||||
directed graph we can talk about out-edges and in-edges of a vertex.
|
||||
In an undirected graph there is no ``in'' and ``out'', there are just
|
||||
edges incident to a vertex. Nevertheless, in the BGL we still use the
|
||||
<TT>out_edges()</TT> function (or <TT>in_edges()</TT>) to access the
|
||||
incident edges in an undirected graph. Similarly, an undirected edge
|
||||
has no ``source'' and ``target'' but merely an unordered pair of
|
||||
vertices, but in the BGL we still use <TT>source()</TT> and
|
||||
<TT>target()</TT> to access these vertices. The reason the BGL does
|
||||
not provide a separate interface for undirected graphs is that many
|
||||
algorithms on directed graphs also work on undirected graphs, and it
|
||||
would be inconvenient to have to duplicate the algorithms just because
|
||||
of an interface difference. When using undirected graphs just mentally
|
||||
disregard the directionality in the function names. The example below
|
||||
demonstrates using the <TT>out_edges()</TT>, <TT>source()</TT>, and
|
||||
<TT>target()</TT> with an undirected graph. The source code for this
|
||||
example and the following one can be found in <a
|
||||
href="../example/undirected.cpp"><TT>examples/undirected.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
const int V = 2;
|
||||
typedef ... UndirectedGraph;
|
||||
UndirectedGraph undigraph(V);
|
||||
|
||||
std::cout << "the edges incident to v: ";
|
||||
boost::graph_traits<UndirectedGraph>::out_edge_iterator e, e_end;
|
||||
boost::graph_traits<UndirectedGraph>::vertex_descriptor
|
||||
s = vertex(0, undigraph);
|
||||
for (tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e)
|
||||
std::cout << "(" << source(*e, undigraph)
|
||||
<< "," << target(*e, undigraph) << ")" << endl;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Even though the interface is the same for undirected graphs, there are
|
||||
some behavioral differences because edge equality is defined
|
||||
differently. In a directed graph, edge <i>(u,v)</i> is never equal to edge
|
||||
<i>(v,u)</i>, but in an undirected graph they may be equal. If the
|
||||
undirected graph is a multigraph then <i>(u,v)</i> and <i>(v,u)</i> might be
|
||||
parallel edges. If the graph is not a multigraph then <i>(u,v)</i> and
|
||||
<i>(v,u)</i> must be the same edge.
|
||||
|
||||
<P>
|
||||
In the example below the edge equality test will return <TT>false</TT>
|
||||
for the directed graph and <TT>true</TT> for the undirected graph. The
|
||||
difference also affects the meaning of <TT>add_edge()</TT>. In the
|
||||
example below, if we had also written <TT>add_add(v, u,
|
||||
undigraph)</TT>, this would have added a parallel edge between
|
||||
<i>u</i> and <i>v</i> (provided the graph type allows parallel
|
||||
edges). The difference in edge equality also affects the association
|
||||
of edge properties. In the directed graph, the edges <i>(u,v)</i> and
|
||||
<i>(v,u)</i> can have distinct weight values, whereas in the
|
||||
undirected graph the weight of <i>(u,v)</i> is the same as the weight
|
||||
of <i>(v,u)</i> since they are the same edge.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
typedef ... DirectedGraph;
|
||||
DirectedGraph digraph(V);
|
||||
{
|
||||
boost::graph_traits<DirectedGraph>::vertex_descriptor u, v;
|
||||
u = vertex(0, digraph);
|
||||
v = vertex(1, digraph);
|
||||
add_edge(digraph, u, v, Weight(1.2));
|
||||
add_edge(digraph, v, u, Weight(2.4));
|
||||
boost::graph_traits<DirectedGraph>::edge_descriptor e1, e2;
|
||||
bool found;
|
||||
tie(e1, found) = edge(u, v, digraph);
|
||||
tie(e2, found) = edge(v, u, digraph);
|
||||
std::cout << "in a directed graph is ";
|
||||
std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl;
|
||||
|
||||
property_map<DirectedGraph, edge_weight_t>::type
|
||||
weight = get(edge_weight, digraph);
|
||||
cout << "weight[(u,v)] = " << get(weight, e1) << endl;
|
||||
cout << "weight[(v,u)] = " << get(weight, e2) << endl;
|
||||
}
|
||||
{
|
||||
boost::graph_traits<UndirectedGraph>::vertex_descriptor u, v;
|
||||
u = vertex(0, undigraph);
|
||||
v = vertex(1, undigraph);
|
||||
add_edge(undigraph, u, v, Weight(3.1));
|
||||
boost::graph_traits<UndirectedGraph>::edge_descriptor e1, e2;
|
||||
bool found;
|
||||
tie(e1, found) = edge(u, v, undigraph);
|
||||
tie(e2, found) = edge(v, u, undigraph);
|
||||
std::cout << "in an undirected graph is ";
|
||||
std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl;
|
||||
|
||||
property_map<UndirectedGraph, edge_weight_t>::type
|
||||
weight = get(edge_weight, undigraph);
|
||||
cout << "weight[(u,v)] = " << get(weight, e1) << endl;
|
||||
cout << "weight[(v,u)] = " << get(weight, e2) << endl;
|
||||
}
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
in a directed graph is (u,v) == (v,u) ? 0
|
||||
weight[(u,v)] = 1.2
|
||||
weight[(v,u)] = 2.4
|
||||
in an undirected graph is (u,v) == (v,u) ? 1
|
||||
weight[(u,v)] = 3.1
|
||||
weight[(v,u)] = 3.1
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
523
doc/graph_theory_review.html
Normal file
@@ -0,0 +1,523 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes 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: Graph Theory Review</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>Review of Elementary Graph Theory</H1>
|
||||
|
||||
<P>
|
||||
|
||||
<P>
|
||||
This chapter is meant as a refresher on elementary graph theory. If
|
||||
the reader has some previous acquaintance with graph algorithms, this
|
||||
chapter should be enough to get started. If the reader has no
|
||||
previous background in graph algorithms we suggest a more thorough
|
||||
introduction such as <a
|
||||
href="http://www.toc.lcs.mit.edu/~clr/">Introduction to Algorithms</a>
|
||||
by Cormen, Leiserson, and Rivest.
|
||||
|
||||
<P>
|
||||
|
||||
<H1>The Graph Abstraction</H1>
|
||||
|
||||
<P>
|
||||
A graph is a mathematical abstraction that is useful for solving many
|
||||
kinds of problems. Fundamentally, a graph consists of a set of
|
||||
vertices, and a set of edges, where an edge is something that connects
|
||||
two vertices in the graph. More precisely, a <I>graph</I> is a pair
|
||||
<i>(V,E)</i>, where <i>V</i> is a finite set and <i>E</i> is a binary
|
||||
relation on <i>V</i>. <i>V</i> is called a <I>vertex set</I> whose
|
||||
elements are called <I>vertices</I>. <iE</i> is a collection of
|
||||
edges, where an <I>edge</I> is a pair <i>(u,v)</i> with <i>u,v</i> in
|
||||
V. In a <I>directed graph</I>, edges are ordered pairs,
|
||||
connecting a <I>source</I> vertex to a <I>target</I> vertex. In an
|
||||
<I>undirected graph</I> edges are unordered pairs and connect the two
|
||||
vertices in both directions, hence in an undirected graph <i>(u,v)</i>
|
||||
and <i>(v,u)</i> are two ways of writing the same edge.
|
||||
|
||||
<P>
|
||||
This definition of a graph is vague in certain respects; it does not
|
||||
say what a vertex or edge represents. They could be cities with
|
||||
connecting roads, or web-pages with hyperlinks. These details are left
|
||||
out of the definition of a graph for an important reason; they are not
|
||||
a necessary part of the graph <I>abstraction</I>. By leaving out the
|
||||
details we can construct a theory that is reusable, that can help us
|
||||
solve lots of different kinds of problems.
|
||||
|
||||
<P>
|
||||
Back to the definition: a graph is a set of vertices and edges. For
|
||||
purposes of demonstration, let us consider a graph where we have labeled the vertices with letters, and we write an edge simply as a
|
||||
pair of letters. Now we can write down an example of a directed graph
|
||||
as follows:
|
||||
|
||||
<P>
|
||||
<BR>
|
||||
<DIV ALIGN="center">
|
||||
<table><tr><td><tt>
|
||||
V = {v, b, x, z, a, y } <br>
|
||||
E = { (b,y), (b,y), (y,v), (z,a), (x,x), (b,x), (x,v), (a,z) } <br>
|
||||
G = (V, E)
|
||||
</tt></td></tr></table>
|
||||
</DIV>
|
||||
<BR CLEAR="ALL"><P></P>
|
||||
|
||||
|
||||
<P>
|
||||
<A HREF="#fig:directed-graph">Figure 1</A>
|
||||
gives a pictorial view of this graph. The edge <i>(x,x)</i> is called
|
||||
a <I>self-loop</I>. Edges <i>(b,y)</i> and <i>(b,y)</i> are
|
||||
<I>parallel edges</I>, which are allowed in a <I>multigraph</I> (but
|
||||
are normally not allowed in a directed or undirected graph).
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:directed-graph"></A><A NAME="1509"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
|
||||
Example of a directed graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/digraph.gif" width="124" height="163"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
Next we have a similar graph, though this time it is undirected. <A
|
||||
HREF="#fig:undirected-graph">Figure 2</A>
|
||||
gives the pictorial view. Self loops are not allowed in undirected
|
||||
graphs. This graph is the <I>undirected</I> version of the the
|
||||
previous graph (minus the parallel edge <i>(b,y)</i>), meaning it has
|
||||
the same vertices and the same edges with their directions removed.
|
||||
Also the self edge has been removed, and edges such as <i>(a,z)</i>
|
||||
and <i>(z,a)</i> are collapsed into one edge. One can go the other
|
||||
way, and make a <I>directed</I> version of an undirected graph be
|
||||
replacing each edge by two edges, one pointing in each direction.
|
||||
|
||||
<P>
|
||||
<BR>
|
||||
<DIV ALIGN="CENTER">
|
||||
<table><tr><td><tt>
|
||||
V = {v, b, x, z, a, y }<br>
|
||||
E = { (b,y), (y,v), (z,a), (b,x), (x,v) }<br>
|
||||
G = (V, E)
|
||||
</tt></td></tr></table>
|
||||
</DIV>
|
||||
<BR CLEAR="ALL"><P></P>
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:undirected-graph"></A><A NAME="1524"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 2:</STRONG>
|
||||
Example of an undirected graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/undigraph.gif" width="103" height="163"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
Now for some more graph terminology. If some edge <i>(u,v)</i> is in
|
||||
graph , then vertex <i>v</i> is <I>adjacent</I> to vertex <i>u</i>.
|
||||
In a directed graph, edge <i>(u,v)</i> is an <I>out-edge</I> of vertex
|
||||
<i>u</i> and an <I>in-edge</I> of vertex <i>v</i>. In an undirected
|
||||
graph edge <i>(u,v)</i> is <I>incident on</I> vertices <i>u</i> and
|
||||
<i>v</i>.
|
||||
|
||||
<P>
|
||||
In <A HREF="#fig:directed-graph">Figure 1</A>,
|
||||
vertex <i>y</i> is adjacent to vertex <i>b</i> (but <i>b</i> is not
|
||||
adjacent to <i>y</i>). The edge <i>(b,y)</i> is an out-edge of
|
||||
<i>b</i> and an in-edge of <i>y</i>. In <A
|
||||
HREF="#fig:undirected-graph">Figure 2</A>,
|
||||
<i>y</i> is adjacent to <i>b</i> and vice-versa. The edge
|
||||
<i>(y,b)</i> is incident on vertices <i>y</i> and <i>b</i>.
|
||||
|
||||
<P>
|
||||
In a directed graph, the number of out-edges of a vertex is its
|
||||
<I>out-degree</I> and the number of in-edges is its <I>in-degree</I>.
|
||||
For an undirected graph, the number of edges incident to a vertex is
|
||||
its <I>degree</I>. In <A
|
||||
HREF="#fig:directed-graph">Figure 1</A>,
|
||||
vertex <i>b</i> has an out-degree of 3 and an in-degree of zero. In <A
|
||||
HREF="#fig:undirected-graph">Figure 2</A>,
|
||||
vertex <i>b</i> simply has a degree of 2.
|
||||
|
||||
<P>
|
||||
Now a <I>path</I> is a sequence of edges in a graph such that the
|
||||
target vertex of each edge is the source vertex of the next edge in
|
||||
the sequence. A path is <I>simple</I> if none of the vertices in the
|
||||
sequence are repeated. The path <(b,x), (x,v)> is simple, while
|
||||
the path <(a,z), (z,a)> is not. Also, the path <(a,z),
|
||||
(z,a)> is called a <I>cycle</I> because the first and last vertex
|
||||
in the path are the same. A graph with no cycles is <I>acyclic</I>.
|
||||
|
||||
<P>
|
||||
A <I>planar graph</I> is a graph that can be drawn on a plane without
|
||||
any of the edges crossing over each other. Such a drawing is called a
|
||||
<I>plane graph</I>. A <I>face</I> of a plane graph is a connected
|
||||
region of the plane surrounded by edges. An important property of
|
||||
planar graphs is that the number of faces, edges, and vertices are
|
||||
related through Euler's formula: <i>|F| - |E| + |V| = 2</i>. This
|
||||
means that a simple planar graph has at most <i>O(|V|)</i> edges.
|
||||
|
||||
<P>
|
||||
|
||||
<P>
|
||||
|
||||
<H1>Graph Data Structures</H1>
|
||||
|
||||
<P>
|
||||
The primary property of a graph to consider when deciding which data
|
||||
structure to use is <I>sparsity</I>, the number of edges relative to
|
||||
the number of vertices in the graph. A graph where <i>E</i> is close
|
||||
to </i>V<sup>2</sup></i> is a <I>dense</I> graph, whereas a graph
|
||||
where <i>E = alpha V</i> and <i>alpha</i> is much smaller than
|
||||
<i>V</i> is a <I>sparse</I> graph. For dense graphs, the
|
||||
<I>adjacency-matrix representation</I> is usually the best choice,
|
||||
whereas for sparse graphs the <I>adjacency-list representation</I> is
|
||||
a better choice. Also the <I>edge-list representation</I> is a space
|
||||
efficient choice for sparse graphs that is appropriate in some
|
||||
situations.
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Adjacency Matrix Representation</H2>
|
||||
|
||||
<P>
|
||||
An adjacency-matrix representation of a graph is a 2-dimensional <i>V
|
||||
x V</i> array. Each element in the array <i>a<sub>uv</sub></i> stores
|
||||
a Boolean value saying whether the edge <i>(u,v)</i> is in the graph.
|
||||
<A HREF="#fig:adj-matrix">Figure 3</A> depicts
|
||||
an adjacency matrix for the graph in <A
|
||||
HREF="#fig:directed-graph">Figure 1</A> (minus
|
||||
the parallel edge <i>(b,y)</i>). The ammount of space required to
|
||||
store an adjacency-matrix is <i>O(V<sup>2</sup>)</i>. Any edge can be
|
||||
accessed, added, or removed in <i>O(1)</i> time. To add or remove a
|
||||
vertex requires reallocating and copying the whole graph, an
|
||||
<i>O(V<sup>2</sup>)</i> operation. The BGL does not include a graph
|
||||
class that uses the adjacency matrix representation.
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:adj-matrix"></A><A NAME="1701"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 3:</STRONG>
|
||||
The Adjacency Matrix Graph Representation.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/adj_matrix.gif" width="136" height="135"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:adjacency-list-representation"></A>
|
||||
Adjacency List Representation
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
An adjacency-list representation of a graph stores an out-edge
|
||||
sequence for each vertex. For sparse graphs this saves space since
|
||||
only <i>O(V + E)</i> memory is required. In addition, the out-edges
|
||||
for each vertex can be accessed more efficiently. Edge insertion is
|
||||
<i>O(1)</i>, though accessing any given edge is <i>O(alpha)</i>, where
|
||||
<i>alpha</i> is the sparsity factor of the matrix (which is equal to
|
||||
the maximum number of out-edges for any vertex in the graph). <A
|
||||
HREF="#fig:adj-list">Figure 4</A> depicts an
|
||||
adjacency-list representation of the graph in <A
|
||||
HREF="#fig:directed-graph">Figure 1</A>. The
|
||||
<a href="./adjacency_list.html"><TT>adjacency_list</TT></a> class is
|
||||
an implementation of the adjacency-list representation.
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:adj-list"></A><A NAME="1713"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 4:</STRONG>
|
||||
The Adjacency List Graph Representation.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/adj_list.gif" width="108" height="122"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Edge List Representation</H2>
|
||||
|
||||
<P>
|
||||
An edge-list representation of a graph is simply a sequence of edges,
|
||||
where each edge is represented as a pair of vertex ID's. The memory
|
||||
required is only <i>O(E)</i>. Edge insertion is typically <i>O(1)</i>,
|
||||
though accessing a particular edge is <i>O(E)</i> (not efficient). <A
|
||||
HREF="#fig:edge-list">Figure 5</A> shows an
|
||||
edge-list representation of the graph in <A
|
||||
HREF="#fig:directed-graph">Figure 1</A>. The
|
||||
<a href="./edge_list.html"><TT>edge_list</TT></a> adaptor class can be
|
||||
used to create implementations of the edge-list representation.
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:edge-list"></A><A NAME="1724"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 5:</STRONG>
|
||||
The Edge List Graph Representation.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/edge_list.gif" width="322" height="22"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
|
||||
<P>
|
||||
|
||||
<H1>Graph Algorithms</H1>
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Graph Search Algorithms</H2>
|
||||
|
||||
<P>
|
||||
<I>Tree edges</I> are edges in the search tree (or forest) constructed
|
||||
(implicitly or explicitly) by running a graph search algorithm over a
|
||||
graph. An edge <i>(u,v)</i> is a tree edge if <i>v</i> was first
|
||||
discovered while exploring (corresponding to the <a
|
||||
href="./visitor_concepts.html">visitor</a> <TT>explore()</TT> method)
|
||||
edge <i>(u,v)</i>. <I>Back edges</I> connect vertices to their
|
||||
ancestors in a search tree. So for edge <i>(u,v)</i> the vertex
|
||||
<i>v</i> must be the ancestor of vertex <i>u</i>. Self loops are
|
||||
considered to be back edges. <I>Forward edges</I> are non-tree edges
|
||||
<i>(u,v)</i> that connect a vertex <i>u</i> to a descendant <i>v</i>
|
||||
in a search tree. <I>Cross edges</I> are edges that do not fall into
|
||||
the above three categories.
|
||||
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:bfs-algorithm"></A>
|
||||
Breadth-First Search
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
Breadth-first search is a traversal through a graph that touches all
|
||||
of the vertices reachable from a particular source vertex. In
|
||||
addition, the order of the traversal is such that the algorithm will
|
||||
explore all of the neighbors of a vertex before proceeding on to the
|
||||
neighbors of its neighbors. One way to think of breadth-first search
|
||||
is that it expands like a wave emanating from a stone dropped into a
|
||||
pool of water. Vertices in the same ``wave'' are the same distance
|
||||
from the source vertex. A vertex is <I>discovered</I> the first time
|
||||
it is encountered by the algorithm. A vertex is <I>finished</I> after
|
||||
all of its neighbors are explored. Here's an example to help make this
|
||||
clear. A graph is shown in <A
|
||||
HREF="#fig:bfs-example">Figure 6</A> and the
|
||||
BFS discovery and finish order for the vertices is shown below.
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:bfs-example"></A><A NAME="1826"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 6:</STRONG>
|
||||
Breadth-first search spreading through a graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/bfs_example.gif" width="242" height="143"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
order of discovery: s r w v t x u y
|
||||
order of finish: s r w v t x u y
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
We start at vertex , and first visit <i>r</i> and <i>w</i> (the two
|
||||
neighbors of ). Once both neighbors of are visited, we visit the
|
||||
neighbor of <i>r</i> (vertex <i>v</i>), then the neighbors of <i>w</i>
|
||||
(the discovery order between <i>r</i> and <i>w</i> does not matter)
|
||||
which are <i>t</i> and <i>x</i>. Finally we visit the neighbors of
|
||||
<i>t</i> and <i>x</i>, which are <i>u</i> and <i>y</i>.
|
||||
|
||||
<P>
|
||||
For the algorithm to keep track of where it is in the graph, and which
|
||||
vertex to visit next, BFS needs to color the vertices (see the section
|
||||
on <a href="./using_property_maps.html">Property Maps</a>
|
||||
for more details about attaching properties to graphs). The place to
|
||||
put the color can either be inside the graph, or it can be passed into
|
||||
the algorithm as an argument.
|
||||
|
||||
<P>
|
||||
|
||||
<H2><A NAME="sec:dfs-algorithm"></A>
|
||||
Depth-First Search
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
A depth first search (DFS) visits all the vertices in a graph. When
|
||||
choosing which edge to explore next, this algorithm always chooses to
|
||||
go ``deeper'' into the graph. That is, it will pick the next adjacent
|
||||
unvisited vertex until reaching a vertex that has no unvisited
|
||||
adjacent vertices. The algorithm will then backtrack to the previous
|
||||
vertex and continue along any as-yet unexplored edges from that
|
||||
vertex. After DFS has visited all the reachable vertices from a
|
||||
particular source vertex, it chooses one of the remaining undiscovered
|
||||
vertices and continues the search. This process creates a set of
|
||||
<I>depth-first trees</I> which together form the <I>depth-first
|
||||
forest</I>. A depth-first search categorizes the edges in the graph
|
||||
into three categories: tree-edges, back-edges, and forward or
|
||||
cross-edges (it does not specify which). There are typically many
|
||||
valid depth-first forests for a given graph, and therefore many
|
||||
different (and equally valid) ways to categorize the edges.
|
||||
|
||||
<P>
|
||||
One interesting property of depth-first search is that the discover
|
||||
and finish times for each vertex form a parenthesis structure. If we
|
||||
use an open-parenthesis when a vertex is discovered, and a
|
||||
close-parenthesis when a vertex is finished, then the result is a
|
||||
properly nested set of parenthesis. <A
|
||||
HREF="#fig:dfs-example">Figure 7</A> shows
|
||||
DFS applied to an undirected graph, with the edges labeled in the
|
||||
order they were explored. Below we list the vertices of the graph
|
||||
ordered by discover and finish time, as well as show the parenthesis structure. DFS is used as the kernel for several other graph
|
||||
algorithms, including topological sort and two of the connected
|
||||
component algorithms. It can also be used to detect cycles (see the <A
|
||||
HREF="file_dependency_example.html#sec:cycles">Cylic Dependencies </a>
|
||||
section of the File Dependency Example).
|
||||
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="CENTER"><A NAME="fig:dfs-example"></A><A NAME="1841"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7:</STRONG>
|
||||
Depth-first search on an undirected graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/dfs.gif" width="141" height="204"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
order of discovery: a b e d c f g h i
|
||||
order of finish: d f c e b a
|
||||
parenthesis: (a (b (e (d d) (c (f f) c) e) b) a) (g (h (i i) h) g)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
|
||||
<H2><a name="sec:minimum-spanning-tree">Minimum Spanning Tree
|
||||
Algorithms</a></H2>
|
||||
|
||||
<P>
|
||||
The <I>minimum-spanning-tree problem</I> is defined as follows: find
|
||||
an acyclic subset <i>T</i> of <i>E</i> that connects all of the vertices
|
||||
in the graph and whose total weight is minimized, where the
|
||||
total weight is given by
|
||||
<P></P>
|
||||
<DIV ALIGN="left">
|
||||
<i>w(T)</i> = sum of <i>w(u,v)</i> over all <i>(u,v)</i> in <i>T</i>,
|
||||
where <i>w(u,v)</i> is the weight on the edge <i>(u,v)</i>
|
||||
</DIV>
|
||||
<BR CLEAR="ALL">
|
||||
<P></P>
|
||||
<i>T</i> is called the <I>spanning tree</I>.
|
||||
|
||||
<!--
|
||||
<P>
|
||||
Kruskal's algorithm [<A
|
||||
HREF="bibliography.html#kruskal56">18</A>]
|
||||
for solving the minimum spanning tree problem. This is a greedy
|
||||
algorithm to calculate the minimum spanning tree for an undirected
|
||||
graph with weighted edges.
|
||||
|
||||
<P>
|
||||
This is Prim's algorithm [<A
|
||||
HREF="bibliography.html#prim57:_short">25</A>] for solving the
|
||||
minimum spanning tree problem for an undirected graph with weighted
|
||||
edges. The implementation is simply a call to <a
|
||||
href="./uniform_cost_search.html"><TT>uniform_cost_search()</TT></a>
|
||||
with the appropriate choice of comparison and combine functors.
|
||||
-->
|
||||
|
||||
<P>
|
||||
|
||||
<H2><a name="sec:shortest-paths-algorithms">Shortest-Paths Algorithms</a></H2>
|
||||
|
||||
<P>
|
||||
One of the classic problems in graph theory is to find the shortest
|
||||
path between two vertices in a graph. Formally, a <I>path</I> is a
|
||||
sequence of vertices <i><v<sub>0</sub>,v<sub>1</sub>,...,v<sub>k</sub>></i>
|
||||
in a graph <i>G = (V, E)</i> such that each vertex is connected to the
|
||||
next vertex in the sequence (the edges
|
||||
<i>(v<sub>i</sub>,v<sub>i+1</sub>)</i> for <i>i=0,1,...,k-1</i> are in
|
||||
the edge set <i>E</i>). In the shortest-path problem, each edge is
|
||||
given a real-valued weight. We can therefore talk about the <I>weight
|
||||
of a path</I><BR>
|
||||
|
||||
<p></p>
|
||||
<DIV ALIGN="left">
|
||||
<i>w(p) = sum from i=1..k of w(v<sub>i-1</sub>,v<sub>i</sub>)</i>
|
||||
</DIV>
|
||||
<BR CLEAR="ALL"><P></P>
|
||||
|
||||
The <I>shortest path weight</I> from vertex <i>u</i> to <i>v</i> is then
|
||||
|
||||
<BR>
|
||||
<p></p>
|
||||
<DIV ALIGN="left">
|
||||
<i>delta (u,v) = min { w(p) : u --> v }</i> if there is a path from
|
||||
<i>u</i> to <i>v</i> <br>
|
||||
<i>delta (u,v) = infinity</i> otherwise.
|
||||
</DIV>
|
||||
<BR CLEAR="ALL"><P></P>
|
||||
|
||||
A <I>shortest path</I> is any path who's path weight is equal to the
|
||||
<I>shortest path weight</I>.
|
||||
|
||||
<P>
|
||||
There are several variants of the shortest path problem. Above we
|
||||
defined the <I>single-pair</I> problem, but there is also the
|
||||
<I>single-source problem</I> (all shortest paths from one vertex to
|
||||
every other vertex in the graph), the equivalent
|
||||
<I>single-destination problem</I>, and the <I>all-pairs problem</I>.
|
||||
It turns out that there are no algorithms for solving the single-pair
|
||||
problem that are asymptotically faster than algorithms that solve the
|
||||
single-source problem.
|
||||
|
||||
<P>
|
||||
A <I>shortest-paths tree</I> rooted at vertex in graph <i>G=(V,E)</i>
|
||||
is a directed subgraph <G'> where <i>V'</i> is a subset
|
||||
of <i>V</i> and <i>E'</i> is a subset of <i>E</i>, <i>V'</i> is the
|
||||
set of vertices reachable from , <i>G'</i> forms a rooted tree with
|
||||
root , and for all <i>v</i> in <i>V'</i> the unique simple path from
|
||||
to <i>v</i> in <i>G'</i> is a shortest path from to <i>v</i> in . The
|
||||
result of a single-source algorithm is a shortest-paths tree.
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Network Algorithms</H2>
|
||||
|
||||
<P>
|
||||
Maximum flow.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
240
doc/graph_traits.html
Normal file
@@ -0,0 +1,240 @@
|
||||
<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: Graph Traits</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME=""></A>
|
||||
<pre>
|
||||
graph_traits<<a href="./Graph.html">Graph</a>>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
Just like the <a
|
||||
href="http://www.sgi.com/Technology/STL/iterator_traits.html">
|
||||
iterators</a> of STL, graphs have <b>associated types</b>. As stated
|
||||
in the various <a href="./graph_concepts.html">graph concepts</a>, a
|
||||
graph has quite a few associated types: <tt>vertex_descriptor</tt>,
|
||||
<tt>edge_descriptor</tt>, <tt>out_edge_iterator</tt>, etc.. Any
|
||||
particular graph concepts will not require that all of the following
|
||||
associated types be defined. When implementing a graph class that
|
||||
fullfils one or more graph concepts, for associated types that are not
|
||||
required by the concepts, it is ok to use <tt>void</tt> as the type
|
||||
(when using nested typedefs inside the graph class), or to leave the
|
||||
typedef out of the <tt>graph_traits</tt> specialization for the graph
|
||||
class.
|
||||
|
||||
<pre>
|
||||
template <typename Graph>
|
||||
struct graph_traits {
|
||||
typedef typename Graph::vertex_descriptor vertex_descriptor;
|
||||
typedef typename Graph::edge_descriptor edge_descriptor;
|
||||
typedef typename Graph::adjacency_iterator adjacency_iterator;
|
||||
typedef typename Graph::out_edge_iterator out_edge_iterator;
|
||||
typedef typename Graph::in_edge_iterator in_edge_iterator;
|
||||
typedef typename Graph::vertex_iterator vertex_iterator;
|
||||
typedef typename Graph::edge_iterator edge_iterator;
|
||||
|
||||
typedef typename Graph::directed_category directed_category;
|
||||
typedef typename Graph::edge_parallel_category edge_parallel_category;
|
||||
|
||||
typedef typename Graph::vertices_size_type vertices_size_type;
|
||||
typedef typename Graph::edges_size_type edges_size_type;
|
||||
typedef typename Graph::degree_size_type degree_size_type;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/graph_traits.hpp"><tt>boost/graph/graph_traits.hpp</tt></a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>Graph</TT></TD>
|
||||
<TD>
|
||||
The graph type whose associated types are being accessed.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a
|
||||
href="http://www.sgi.com/Technology/STL/DefaultConstructible.html">DefaultConstructible</a> and
|
||||
<a href="http://www.sgi.com/Technology/STL/Assignable.html">Assignable</a>
|
||||
|
||||
<h3>Type Requirements</h3>
|
||||
|
||||
<ul>
|
||||
<li><tt>Graph</tt> is a model of one of the <a
|
||||
href="./graph_concepts.html">graph concepts</a>.
|
||||
</ul>
|
||||
|
||||
<H2>Members</H2>
|
||||
|
||||
<p>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Member</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
vertex_descriptor
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the objects used to identity vertices in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_descriptor
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the objects used to identity edges in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
adjacency_iterator
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the iterators that traverse the vertices adjacent
|
||||
to a vertex.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
out_edge_iterator
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the iterators that traverse through the out-edges
|
||||
of a vertex.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
in_edge_iterator
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the iterators that traverse through the in-edges
|
||||
of a vertex.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
vertex_iterator
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the iterators that traverse through the complete vertex
|
||||
set of the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_iterator
|
||||
</tt></td>
|
||||
<td>
|
||||
The type for the iterators that traverse through the complete edge
|
||||
set of the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
directed_category
|
||||
</tt></td>
|
||||
<td>
|
||||
This says whether the graph is undirected (<tt>undirected_tag</tt>)
|
||||
or directed (<tt>directed_tag</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_parallel_category
|
||||
</tt></td>
|
||||
<td>
|
||||
This says whether the graph allows parallel edges to be inserted
|
||||
(<tt>allow_parallel_edge_tag</tt>) or if it automatically removes
|
||||
parallel edges (<tt>disallow_parallel_edge_tag</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
vertices_size_type
|
||||
</tt></td>
|
||||
<td>
|
||||
The unsigned integer type used for representing the number of
|
||||
vertices in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
edge_size_type
|
||||
</tt></td>
|
||||
<td>
|
||||
The unsigned integer type used for representing the number of
|
||||
edge in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
degree_size_type
|
||||
</tt></td>
|
||||
<td>
|
||||
The unsigned integer type used for representing the degree
|
||||
of vertices in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
102
doc/history.html
Normal file
@@ -0,0 +1,102 @@
|
||||
<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: History</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1>History of the Boost Graph Library</h1>
|
||||
|
||||
The Boost Graph Library began its life as the Generic Graph Component
|
||||
Library (GGCL), a software project at the <a
|
||||
href="http://www.lsc.nd.edu">Lab for Scientific Computing (LSC)</a> at
|
||||
the University of Notre Dame, under the direction of Professor <a
|
||||
href="http://www.lsc.nd.edu/~lums">Andrew Lumsdaine</a>. The Lab's
|
||||
research directions include numerical linear algebra, parallel
|
||||
computing, and software engineering (including generic programming).
|
||||
|
||||
<p>
|
||||
Soon after the Standard Template Library was released, work began at
|
||||
the LSC to apply generic programming to scientific computing. The <a
|
||||
href="http://www.lsc.nd.edu/research/mtl">Matrix Template Library</a>
|
||||
(Jeremy Siek's masters thesis) was one of the first projects. Many of
|
||||
the lessons learned during construction of the MTL were applied to the
|
||||
design and implementation of the GGCL.
|
||||
|
||||
<p>
|
||||
Graph algorithms play an important role in sparse matrix computations,
|
||||
so the LSC had a need for a good graph library. However, none of the
|
||||
available graph libraries (LEDA, GTL, Stanford GraphBase) were
|
||||
written using the generic programming style of the STL, and hence did
|
||||
not fulfill the flexibility and high-performance requirements of the
|
||||
LSC. Others were also expressing interest in a generic C++ graph
|
||||
library. During a meeting with Bjarne Stroustrup we were introduced to
|
||||
several people at AT\&T who needed such a library. There had also been
|
||||
earlier work in the area of generic graph algorithms, including some
|
||||
codes written by Alexander Stepanov, and Dietmar Kühl's masters
|
||||
thesis.
|
||||
|
||||
<p>
|
||||
With this in mind, and motivated by homework assignments in his
|
||||
algorithms class, Jeremy began prototyping an interface and some graph
|
||||
classes in the spring on 1998. Lie-Quan Lee then developed the first
|
||||
version of GGCL, which became his masters thesis project.
|
||||
|
||||
<p>
|
||||
The following year, Jeremy went to work for SGI with Alexander
|
||||
Stepanov and Matt Austern. During this time Alex's disjoint-sets based
|
||||
connected components algorithm was added to GGCL, and Jeremy began
|
||||
working on the concept documentation for GGCL similar to Matt's STL
|
||||
documentation.
|
||||
|
||||
<p>
|
||||
While working at SGI, Jeremy heard about Boost and was excited to find
|
||||
a group of people interested in creating high-quality C++
|
||||
libraries. At boost there were several people interested in generic
|
||||
graph algorithms, most notably Dietmar Kühl. Some discussions
|
||||
about generic interfaces for graph structures resulted in the a
|
||||
revision of GGCL which closely resembles the current Boost Graph
|
||||
Library interface.
|
||||
|
||||
<p>
|
||||
On September 4, 2000 GGCL passed the Boost formal review and became
|
||||
the Boost Graph Library (BGL). The first release of BGL was
|
||||
September 27, 2000.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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: gif ALT GGCL LSC Lumsdaine Siek's MTL LEDA GTL GraphBase STL
|
||||
-->
|
||||
<!-- LocalWords: Bjarne Stroustrup hl's Quan SGI Stepanov Austern Alex's hl
|
||||
-->
|
||||
<!-- LocalWords: Dietmar BGL siek htm Univ
|
||||
-->
|
||||
83
doc/incident.html
Normal file
@@ -0,0 +1,83 @@
|
||||
<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: incident</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:incident"></A>
|
||||
<TT>incident</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT"><i>O(1)</i>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TH ALIGN="LEFT"><B>Where Defined:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<a href="../../../boost/graph/graph_utility.hpp"><TT>boost/graph/graph_utility.hpp</TT></a>
|
||||
</TD>
|
||||
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class Graph>
|
||||
std::pair<typename graph_traits<Graph>::vertex_descriptor,
|
||||
typename graph_traits<Graph>::vertex_descriptor>
|
||||
incident(typename graph_traits<Graph>::edge_descriptor e, Graph& g)
|
||||
</pre>
|
||||
|
||||
This function takes and edge descriptor and returns the pair of
|
||||
vertices that are <i>incident</i> to the edge. For directed graphs,
|
||||
the <tt>first</tt> vertex is the source and the <tt>second</tt> vertex
|
||||
is the target. This function is equivalent to the expression
|
||||
<tt>std::make_pair(source(e, g), target(e, g))</tt>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<pre>
|
||||
edge_descriptor e;
|
||||
vertex_descriptor u, v;
|
||||
...
|
||||
tie(u, v) = incident(e, g);
|
||||
</pre>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
282
doc/index.html
Normal file
@@ -0,0 +1,282 @@
|
||||
<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>The Boost Graph Library</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1>The Boost Graph Library (BGL)</h1>
|
||||
|
||||
<P>
|
||||
Graphs are mathematical abstractions that are useful for solving many
|
||||
types of problems in computer science. Consequently, these
|
||||
abstractions must also be represented in computer programs. A
|
||||
standardized generic interface for traversing graphs is of utmost
|
||||
importance to encourage reuse of graph algorithms and data structures.
|
||||
Part of the Boost Graph Library is an interface for how the structure
|
||||
of a graph can be accessed using a generic interface that hides the
|
||||
details of the graph data structure implementation. This is an
|
||||
``open'' interface in the sense that any graph library that implements
|
||||
this interface will be interoperable with the BGL generic algorithms
|
||||
and with other algorithms that also use this interface. BGL provides
|
||||
some general purpose graph classes that conform to this interface, but
|
||||
they are not meant to be the ``only'' graph classes; there certainly
|
||||
will be other graph classes better for certain situations. We believe
|
||||
that the main contribution of the BGL is the formulation of this
|
||||
interface.
|
||||
|
||||
<P>
|
||||
The BGL graph interface and graph components are <I>generic</I> in the
|
||||
same sense as the the Standard Template Library (STL) [<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 compare that to how we applied generic
|
||||
programming in the context of graphs.
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Genericity in STL</H2>
|
||||
|
||||
<P>
|
||||
There are three ways in which the STL is generic.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Algorithm/Data-Structure Interoperability</H3>
|
||||
|
||||
<P>
|
||||
First, each algorithm is written in a data-structure neutral way,
|
||||
allowing a single template function to operate on many different
|
||||
classes of containers. The concept of an iterator is the key
|
||||
ingredient in this decoupling of algorithms and data-structures. The
|
||||
impact of this technique is a reduction in the STL's code size from
|
||||
<i>O(M*N)</i> to <i>O(M+N)</i>, where <i>M</i> is the number of
|
||||
algorithms and <i>N</i> is the number of containers. Considering a
|
||||
situation of 20 algorithms and 5 data-structures, this would be the
|
||||
difference between writing 100 functions versus only 25 functions! And
|
||||
the differences continues to grow faster and faster as the number of
|
||||
algorithms and data-structures increase.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Extension through Function Objects</H3>
|
||||
|
||||
<P>
|
||||
The second way STL is generic is that its algorithms and containers
|
||||
are extensible. The user can adapt and customize the STL through the
|
||||
use of function objects. This flexibility is what makes STL such a
|
||||
great tool for solving real-world problems. Each programming problem
|
||||
brings its own set of entities and interactions that must be
|
||||
modeled. Function objects provide a mechanism for extending the STL to
|
||||
handle the specifics of each problem domain.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Element Type Parameterization</H3>
|
||||
|
||||
<P>
|
||||
The third way that STL is generic is that its containers are
|
||||
parameterized on the element type. Though hugely important, this is
|
||||
perhaps the least ``interesting'' way in which STL is generic.
|
||||
Generic programming is often summarized by a brief description of
|
||||
parameterized lists such as <TT>std::list<T></TT>. This hardly scratches
|
||||
the surface!
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Genericity in the Boost Graph Library</A>
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
Like the STL, there are three ways in which the BGL is generic.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Algorithm/Data-Structure Interoperability</H3>
|
||||
|
||||
<P>
|
||||
First, the graph algorithms of BGL are written to an interface that
|
||||
abstracts away the details of the particular graph data-structure.
|
||||
Like the STL, the BGL uses iterators to define the interface for
|
||||
data-structure traversal. There are three distinct graph traversal
|
||||
patterns: traversal of all vertices in the graph, through all of the
|
||||
edges, and along the adjacency structure of the graph (from a vertex
|
||||
to each of its neighbors). There are separate iterators for each
|
||||
pattern of traversal.
|
||||
|
||||
<P>
|
||||
This generic interface allows template functions such as <a
|
||||
href="./breadth_first_search.html"><TT>breadth_first_search()</TT></a>
|
||||
to work on a large variety of graph data-structures, from graphs
|
||||
implemented with pointer-linked nodes to graphs encoded in
|
||||
arrays. This flexibility is especially important in the domain of
|
||||
graphs. Graph data-structures are often custom-made for a particular
|
||||
application. Traditionally, if a programmer wants to reuse an
|
||||
algorithm implementation they must convert/copy their graph data into
|
||||
the graph library's prescribed graph structure. This is the case with
|
||||
libraries such as LEDA, GTL, Stanford GraphBase, and especially true
|
||||
of graph algorithms written in Fortran. This severely limits the reuse
|
||||
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
|
||||
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
|
||||
designed to make this adaptation easy. To demonstrate this, we have
|
||||
built interfacing code for using LEDA graphs, Stanford GraphBase
|
||||
graphs, and even Fortran-style arrays in BGL graph algorithms.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Extension through Visitors</H3>
|
||||
|
||||
<P>
|
||||
Second, the graph algorithms of BGL are extensible. BGL introduces the
|
||||
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. 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>
|
||||
|
||||
<H3>Vertex and Edge Property Multi-Parameterization</H3>
|
||||
|
||||
<P>
|
||||
The third way that BGL is generic is analogous to the parameterization
|
||||
of the element-type in STL containers, though again the story is a bit
|
||||
more complicated for graphs. We need to associate values with both the
|
||||
vertices and the edges of the graph (we will call an associated value
|
||||
a property). In addition, it will often be necessary to associate
|
||||
multiple properties with each vertex and edge, which is what we mean
|
||||
by multi-parameterization. Similar to how the <TT>std::list<T></TT>
|
||||
class has the parameter <TT>T</TT> for its element type, BGL graph
|
||||
classes have template parameters for vertex and edge ``properties''. A
|
||||
property specifies the parameterized type of the property and also assigns
|
||||
an identifying tag to the property, which is used to distinguish
|
||||
between the multiple properties. The property value attached to a
|
||||
particular vertex or edge can be obtained via a <I>property
|
||||
map</I>, of which there is one for each property.
|
||||
|
||||
<P>
|
||||
Traditional graph libraries and graph structures fall down when it
|
||||
comes to the parameterization of graph properties. This is one of the
|
||||
primary reasons that graph data-structures must be custom-built for
|
||||
applications. The parameterization of properties in the BGL graph
|
||||
classes makes them well suited for re-use.
|
||||
|
||||
<p>
|
||||
|
||||
<H2>Algorithms</H2>
|
||||
|
||||
<P>
|
||||
The BGL algorithms consist of a core set of algorithm <I>patterns</I>
|
||||
(implemented as generic algorithms) and a larger set of graph
|
||||
algorithms. The core algorithm patterns are
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI>Breadth First Search
|
||||
</LI>
|
||||
<LI>Depth First Search
|
||||
</LI>
|
||||
<LI>Uniform Cost Search
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The algorithm patterns by themselves do not compute any meaningful
|
||||
quantities over graphs, they are merely building blocks for
|
||||
constructing graph algorithms. The graph algorithms in BGL currently
|
||||
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>Smallest Last Vertex Ordering</LI>
|
||||
<LI>Sequential Vertex Coloring</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Data Structures</H2>
|
||||
|
||||
<P>
|
||||
BGL currently provides two graph classes that implement a generalized
|
||||
adjacency list and an edge list adaptor.
|
||||
|
||||
<P>
|
||||
|
||||
<UL>
|
||||
<LI><TT>adjacency_list</TT>
|
||||
</LI>
|
||||
<LI><TT>edge_list</TT>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The <TT>adjacency_list</TT> class is the general purpose ``swiss army
|
||||
knife'' of graph classes. It is highly parameterized so that it can be
|
||||
optimized for different situations: the graph is directed or
|
||||
undirected, allow or disallow parallel edges, efficient access to just
|
||||
the out-edges or also to the in-edges, fast vertex insertion and
|
||||
removal at the cost of extra space overhead, etc.
|
||||
|
||||
<P>
|
||||
The <TT>edge_list</TT> class is an adaptor that takes any kind of edge
|
||||
iterator and implements an <a href="./EdgeListGraph.html">EdgeListGraph</a>.
|
||||
|
||||
|
||||
<p>
|
||||
<a href="./table_of_contents.html">Table of Contents<a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>
|
||||
BIN
doc/iscope99.pdf
Normal file
151
doc/johnson_all_pairs_shortest.html
Normal file
@@ -0,0 +1,151 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 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. Silicon Graphics makes no
|
||||
-- representations about the suitability of this software for any
|
||||
-- purpose. It is provided "as is" without express or implied warranty.
|
||||
-->
|
||||
<Head>
|
||||
<Title>Johnson All Pairs Shortest Paths</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../c++boost.gif"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:johnson">
|
||||
<TT>johnson_all_pairs_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<DIV ALIGN="left">
|
||||
<TABLE CELLPADDING=3 border>
|
||||
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
|
||||
<TD ALIGN="LEFT">directed or undirected</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
|
||||
<TD ALIGN="LEFT">distance matrix, distance, weight, color, vertex index</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">
|
||||
<i>O(V E log V) or <i>O(V<sup>2</sup> log V + V E)</i>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class <a href="./VertexAndEdgeListGraph.html">VertexAndEdgeListGraph</a>, class DistanceMatrix,
|
||||
class DistanceMap, class WeightMap, class ColorMap,
|
||||
class VertexIndexMap>
|
||||
bool
|
||||
johnson_all_pairs_shortest_paths(VertexAndEdgeListGraph& g,
|
||||
DistanceMatrix& D,
|
||||
DistanceMap d, DistanceMap h,
|
||||
WeightMap w, ColorMap c, VertexIndexMap id)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This algorithm finds the shortest distance between every pair of
|
||||
vertices in the graph. The algorithm returns false if there is a
|
||||
negative weight cycle in the graph and true otherwise. The distance
|
||||
between each pair of vertices is stored in the distance matrix
|
||||
<TT>D</TT>. This is one of the more time intensive graph algorithms,
|
||||
having a time complexity of <i>O(V E log V)</i> if a binary heap is
|
||||
used within Dijkstra's or <i>O(V<sup>2</sup> log V + V E)</i> if a fibonacci
|
||||
heap is used (the algorithm can be configured to use either). It is a
|
||||
wonder that London taxi-cab drivers are able to instantaneously
|
||||
compute this kind of information in their heads!
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/johnson_all_pairs_shortest.hpp"><TT>boost/graph/johnson_all_pairs_shortest.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
Johnson's algorithm for all-pairs shortest paths applied to the
|
||||
example graph from page 568 of the CLR [<A
|
||||
HREF="bibliography.html#clr90">8</A>]. The resulting distance matrix
|
||||
<TT>D[u][v]</TT> gives the shortest path from vertex <TT>u</TT> to
|
||||
<TT>v</TT>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
typedef adjacency_list<vecS,vecS,directedS,no_property,
|
||||
property<edge_weight_t,int> > Graph;
|
||||
const int V = 6;
|
||||
|
||||
typedef std::pair<int,int> Edge;
|
||||
Edge edge_array[] =
|
||||
{ Edge(0,1), Edge(0,2), Edge(0,3), Edge(0,4), Edge(0,5),
|
||||
Edge(1, 2), Edge(1,5), Edge(1,3),
|
||||
Edge(2, 4), Edge(2,5),
|
||||
Edge(3, 2),
|
||||
Edge(4, 3), Edge(4,1),
|
||||
Edge(5, 4)
|
||||
};
|
||||
const int E = sizeof(edge_array)/sizeof(Edge);
|
||||
|
||||
Graph g(V, edge_array, edge_array + E);
|
||||
|
||||
property_map<Graph,edge_weight_t>::type w = get(edge_weight, g);
|
||||
|
||||
int weights[] = { 0, 0, 0, 0, 0,
|
||||
3, -4, 8,
|
||||
1, 7,
|
||||
4,
|
||||
-5, 2,
|
||||
6 };
|
||||
int* wp = weights;
|
||||
|
||||
Graph::edge_iterator e,e_end;
|
||||
for (boost::tie(e,e_end) = edges(g); e != e_end; ++e)
|
||||
w[*e] = *wp++;
|
||||
|
||||
std::vector<int> d(V, std::numeric_limits<int>::max());
|
||||
std::vector<int> h(V);
|
||||
std::vector<default_color_type> c(V);
|
||||
|
||||
int D[V][V];
|
||||
|
||||
johnson_all_pairs_shortest_paths
|
||||
(g, D, d.begin(), h.begin(), w, c.begin(), get(vertex_index, g));
|
||||
|
||||
// output matrix D ...
|
||||
</PRE>
|
||||
The output is:
|
||||
<PRE>
|
||||
0 1 2 3 4 5
|
||||
0 -> 0 0 -1 -5 0 -4
|
||||
1 -> inf 0 1 -3 2 -4
|
||||
2 -> inf 3 0 -4 1 -1
|
||||
3 -> inf 7 4 0 5 3
|
||||
4 -> inf 2 -1 -5 0 -2
|
||||
5 -> inf 8 5 1 6 0
|
||||
</PRE>
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 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>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||