This commit was manufactured by cvs2svn to create branch
'thread_rewrite'. [SVN r30953]
100
LICENSE
@@ -1,100 +0,0 @@
|
||||
COPYRIGHT NOTICE:
|
||||
|
||||
Copyright 1997-2000, University of Notre Dame.
|
||||
Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
|
||||
|
||||
The Boost Graph Library "Artistic License"
|
||||
|
||||
Preamble
|
||||
|
||||
The intent of this document is to state the conditions under which a
|
||||
Package may be copied, such that the Copyright Holder maintains some
|
||||
semblance of artistic control over the development of the package,
|
||||
while giving the users of the package the right to use and distribute
|
||||
the Package in a more-or-less free fashion, plus the right to make
|
||||
reasonable modifications.
|
||||
|
||||
Definitions
|
||||
|
||||
"Package" refers to the collection of files distributed by the
|
||||
Copyright Holder, and derivatives of that collection of files created
|
||||
through textual modification.
|
||||
|
||||
"Standard Version" refers to such a Package if it has not been
|
||||
modified, or has been modified in accordance with the wishes of the
|
||||
Copyright Holder as specified below.
|
||||
|
||||
"Copyright Holder" is whoever is named in the copyright or copyrights for the package.
|
||||
|
||||
"You" is you, if you're thinking about copying or distributing this Package.
|
||||
|
||||
"Reasonable copying fee" is whatever you can justify on the basis of
|
||||
media cost, duplication charges, time of people involved, and so
|
||||
on. (You will not be required to justify it to the Copyright Holder,
|
||||
but only to the computing community at large as a market that must
|
||||
bear the fee.)
|
||||
|
||||
"Freely Available" means that no fee is charged for the item itself,
|
||||
though there may be fees involved in handling the item. It also means
|
||||
that recipients of the item may redistribute it under the same
|
||||
conditions they received it.
|
||||
|
||||
1. You may make and give away verbatim copies of the source form of
|
||||
the Standard Version of this Package without restriction, provided
|
||||
that you duplicate all of the original copyright notices and
|
||||
associated disclaimers.
|
||||
|
||||
2. You may apply bug fixes, portability fixes and other modifications
|
||||
derived from the Public Domain or from the Copyright Holder. A Package
|
||||
modified in such a way shall still be considered the Standard Version.
|
||||
|
||||
3. You may otherwise modify your copy of this Package in any way,
|
||||
provided that you insert a prominent notice in each changed file
|
||||
stating how and when you changed that file, and provided that you do
|
||||
at least ONE of the following:
|
||||
|
||||
a. place your modifications in the Public Domain or otherwise make
|
||||
them Freely Available, such as by posting said modifications to Usenet
|
||||
or an equivalent medium, or placing the modifications on a major
|
||||
archive site such as uunet.uu.net, or by allowing the Copyright Holder
|
||||
to include your modifications in the Standard Version of the Package.
|
||||
b. use the modified Package only within your corporation or organization.
|
||||
c. rename any non-standard types and functions so the names do not
|
||||
conflict with Standard Vibrary, which must also be provided, and
|
||||
provide a separate documentation for each non-standard type of function
|
||||
that clearly documents how it differs from the Standard Version.
|
||||
d. make other distribution arrangements with the Copyright Holder.
|
||||
|
||||
4. You may charge a reasonable copying fee for any distribution of this
|
||||
Package. You may charge any fee you choose for support of this
|
||||
Package. You may not charge a fee for this Package itself. However,
|
||||
you may distribute this Package in aggregate with other (possibly
|
||||
commercial) programs as part of a larger (possibly commercial)
|
||||
software distribution provided that you do not advertise this Package
|
||||
as a product of your own.
|
||||
|
||||
5. The name of the Copyright Holder may not be used to endorse or
|
||||
promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
DISCLAIMER:
|
||||
|
||||
LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
|
||||
By way of example, but not limitation, Licensor MAKES NO
|
||||
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
|
||||
PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
|
||||
OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
|
||||
OR OTHER RIGHTS.
|
||||
|
||||
The Authors and the University of Notre Dame du Lac shall not be held
|
||||
liable for any liability nor for any direct, indirect or consequential
|
||||
damages with respect to any claim by LICENSEE or any third party on
|
||||
account of or arising from this Agreement or use of this software.
|
||||
|
||||
Any disputes arising out of this Agreement or LICENSEE'S use of the
|
||||
software at any time shall be resolved by the courts of the state of
|
||||
Indiana. LICENSEE hereby consents to the jurisdiction of the Indiana
|
||||
courts and waives the right to challenge the jurisdiction thereof in
|
||||
any dispute arising out of this Agreement or Licensee's use of the
|
||||
software.
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
subproject libs/graph/build ;
|
||||
|
||||
SOURCES = graphviz_graph_lex graphviz_digraph_lex
|
||||
graphviz_graph_parser graphviz_digraph_parser
|
||||
read_graphviz_spirit
|
||||
;
|
||||
|
||||
GRAPHVIZ_DEFS(graphviz_graph_lex) =
|
||||
GRAPHVIZ_DIRECTED=0
|
||||
;
|
||||
GRAPHVIZ_DEFS(graphviz_digraph_lex) =
|
||||
GRAPHVIZ_DIRECTED=1
|
||||
;
|
||||
GRAPHVIZ_DEFS(graphviz_graph_parser) =
|
||||
GRAPHVIZ_DIRECTED=0
|
||||
;
|
||||
GRAPHVIZ_DEFS(graphviz_digraph_parser) =
|
||||
GRAPHVIZ_DIRECTED=1
|
||||
;
|
||||
|
||||
{
|
||||
|
||||
rule bgl-lib-file
|
||||
{
|
||||
local objects source defs ;
|
||||
defs = $(DEFINES) ;
|
||||
for source in $(>)
|
||||
{
|
||||
DEFINES = $(defs) $(GRAPHVIZ_DEFS($(source:B))) ;
|
||||
objects += [ Objects $(source) ] ;
|
||||
}
|
||||
LibraryFromObjects $(<) : $(objects) ;
|
||||
}
|
||||
local gGENERATOR_FUNCTION(LIB) = bgl-lib-file ;
|
||||
|
||||
lib bgl-viz
|
||||
: ../src/$(SOURCES).cpp
|
||||
: <sysinclude>$(BOOST_ROOT) <define>YY_NO_UNISTD_H
|
||||
# Darwin compiler ICEs if we turn optimization on
|
||||
<darwin><*><debug-symbols>off
|
||||
<darwin><*><optimization>off
|
||||
# Intel compiler ICEs if we turn optimization on
|
||||
<intel-win32><*><optimization>off
|
||||
<vc-7_1><*><cxxflags>-GR-
|
||||
: debug <inlining>on #inlining prevents linker name clashes due to truncation!
|
||||
<debug-symbols>off # Debugging symbols become HUGE
|
||||
|
||||
;
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
project boost/graph
|
||||
: requirements <include>../src
|
||||
: source-location ../src
|
||||
;
|
||||
|
||||
lib bgl-viz
|
||||
: graphviz_graph_lex
|
||||
graphviz_digraph_lex
|
||||
graphviz_graph_parser
|
||||
graphviz_digraph_parser
|
||||
: <define>YY_NO_UNISTD_H
|
||||
;
|
||||
|
||||
obj graphviz_graph_lex : graphviz_lex.ll
|
||||
: <flex.prefix>bgl_undir_ <define>GRAPHVIZ_DIRECTED=0
|
||||
<implicit-dependency>graphviz_graph_parser ;
|
||||
obj graphviz_graph_parser : graphviz_parser.yy
|
||||
: <bison.prefix>bgl_undir_ <define>GRAPHVIZ_DIRECTED=0 ;
|
||||
|
||||
|
||||
obj graphviz_digraph_lex : graphviz_lex.ll
|
||||
: <flex.prefix>bgl_dir_ <define>GRAPHVIZ_DIRECTED=1
|
||||
<implicit-dependency>graphviz_digraph_parser ;
|
||||
obj graphviz_digraph_parser : graphviz_parser.yy
|
||||
: <bison.prefix>bgl_dir_ <define>GRAPHVIZ_DIRECTED=1 ;
|
||||
@@ -1,61 +0,0 @@
|
||||
# Copyright 2005 The Trustees of Indiana University.
|
||||
|
||||
# Use, modification and distribution is subject to the Boost Software
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# Authors: Douglas Gregor
|
||||
# Andrew Lumsdaine
|
||||
|
||||
subproject libs/graph/build/python ;
|
||||
|
||||
SEARCH on python.jam = $(BOOST_BUILD_PATH) ;
|
||||
include python.jam ;
|
||||
|
||||
extension bgl
|
||||
: # Sources
|
||||
../../src/python/module.cpp
|
||||
# Graph types
|
||||
../../src/python/graph.cpp
|
||||
../../src/python/digraph.cpp
|
||||
# Graph I/O
|
||||
../../src/python/graphviz.cpp
|
||||
# Graph algorithms
|
||||
# Core Algorithm Patterns
|
||||
../../src/python/breadth_first_search.cpp
|
||||
../../src/python/depth_first_search.cpp
|
||||
# Shortest Paths Algorithms
|
||||
../../src/python/dijkstra_shortest_paths.cpp
|
||||
../../src/python/bellman_ford_shortest_paths.cpp
|
||||
../../src/python/dag_shortest_paths.cpp
|
||||
# Minimum Spanning Tree Algorithms
|
||||
../../src/python/kruskal_min_spanning_tree.cpp
|
||||
../../src/python/prim_minimum_spanning_tree.cpp
|
||||
# Connected Components Algorithms
|
||||
../../src/python/connected_components.cpp
|
||||
../../src/python/strong_components.cpp
|
||||
../../src/python/biconnected_components.cpp
|
||||
../../src/python/incremental_components.cpp
|
||||
# ...
|
||||
# Other algorithms
|
||||
../../src/python/topological_sort.cpp
|
||||
../../src/python/transitive_closure.cpp
|
||||
# ../../src/python/transpose_graph.cpp Need copy_graph to work, first
|
||||
../../src/python/isomorphism.cpp
|
||||
../../src/python/betweenness_centrality.cpp
|
||||
../../src/python/sequential_vertex_coloring.cpp
|
||||
# Sparse Matrix Ordering
|
||||
../../src/python/cuthill_mckee_ordering.cpp
|
||||
../../src/python/king_ordering.cpp
|
||||
# ../../src/python/minimum_degree_ordering.cpp
|
||||
../../src/python/circle_layout.cpp
|
||||
../../src/python/fruchterman_reingold.cpp
|
||||
../../src/python/kamada_kawai_spring_layout.cpp
|
||||
../../src/python/page_rank.cpp
|
||||
# Pickling support
|
||||
../../src/python/pickle.cpp
|
||||
<dll>../../../python/build/boost_python
|
||||
<lib>../bgl-viz
|
||||
: # Default build
|
||||
<debug-symbols>off
|
||||
;
|
||||
@@ -1,142 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) 2004 Kris Beevers
|
||||
--
|
||||
-- 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: AStarHeuristic</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>AStar Heuristic Concept</H1>
|
||||
|
||||
This concept defines the interface for the heuristic function of an A*
|
||||
search, which is responsible for estimating the remaining cost from
|
||||
some vertex to a goal. The user can create a class that matches this
|
||||
interface, and then pass objects of the class into <a
|
||||
href="./astar_search.html"><tt>astar_search()</tt></a> to guide the
|
||||
order of vertex examination of the search. The heuristic instance
|
||||
must incorporate any necessary information about goal vertices in the
|
||||
graph.
|
||||
|
||||
For further discussion of the use of heuristics in an A* search, see
|
||||
the documentation of <a
|
||||
href="./astar_search.html">astar_search()</a>.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary
|
||||
Function</a> (must take a single argument -- a graph vertex -- and
|
||||
return a cost value) and <a
|
||||
href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a heuristic should be a lightweight operation).
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>H</tt></TD>
|
||||
<TD>A type that is a model of AStar Heuristic.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>h</tt></TD>
|
||||
<TD>An object of type <tt>H</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>u</tt></TD>
|
||||
<TD>An object of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>CostType</tt></TD>
|
||||
<TD>A type that can be used with the <tt>compare</tt> and
|
||||
<tt>combine</tt> functions passed to A*.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>c</tt></TD>
|
||||
<TD>An object of type <tt>CostType</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>Call Heuristic</td>
|
||||
<td><tt>CostType c = h(u)</tt></td>
|
||||
<td><tt>CostType</tt></td>
|
||||
<td>
|
||||
Called for the target of every out edge of a vertex being examined.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./astar_heuristic.html"><tt>astar_heuristic</tt></a>
|
||||
</ul>
|
||||
|
||||
<h3>Concept Checking Class</h3>
|
||||
|
||||
<pre>
|
||||
template <class Heuristic, class Graph>
|
||||
struct AStarHeuristicConcept {
|
||||
void constraints()
|
||||
{
|
||||
function_requires< CopyConstructibleConcept<Heuristic> >();
|
||||
h(u);
|
||||
}
|
||||
Heuristic h;
|
||||
typename graph_traits<Graph>::vertex_descriptor u;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<A HREF="http://www.cs.rpi.edu/~beevek/">Kristopher Beevers</A>,
|
||||
Rensselaer Polytechnic Institute (<A
|
||||
HREF="mailto:beevek@cs.rpi.edu">beevek@cs.rpi.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,217 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) 2004 Kris Beevers
|
||||
--
|
||||
-- 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: AStarVisitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>AStar Visitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./astar_search.html"><tt>astar_search()</tt></a>. Users can
|
||||
define a class with the AStar Visitor interface and pass an object of
|
||||
the class to <tt>astar_search()</tt>, thereby augmenting the actions
|
||||
taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a visitor should be a lightweight operation).
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of AStar Visitor.</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>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/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>w</tt></TD>
|
||||
<TD>An object of type <tt>WeightMap</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 on each vertex of the graph when it is first
|
||||
initialized (i.e., when its property maps are initialized).
|
||||
</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 first discovered and is added to the
|
||||
OPEN list.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Examine Vertex</td>
|
||||
<td><tt>vis.examine_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on a vertex as it is popped from the queue (i.e. it
|
||||
has the lowest cost on the OPEN list). This happens immediately before
|
||||
<tt>examine_edge()</tt> is invoked on each of the out-edges of vertex
|
||||
<tt>u</tt>.
|
||||
</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
|
||||
examined.
|
||||
</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 (the distance of its target vertex is reduced) and this method
|
||||
is invoked:
|
||||
<blockquote>
|
||||
<pre>
|
||||
tie(u, s) = incident(e, g);
|
||||
D d_u = get(d, u), d_v = get(d, s);
|
||||
W w_e = get(w, e);
|
||||
assert(compare(combine(d_u, w_e), d_s));
|
||||
</pre>
|
||||
</blockquote>
|
||||
</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 an edge is not relaxed (see above), then this
|
||||
method is invoked.
|
||||
</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 when a vertex that is on the CLOSED list is
|
||||
``rediscovered'' via a more efficient path, and is re-added to the
|
||||
OPEN list.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Finish Vertex</td>
|
||||
<td><tt>vis.finish_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on a vertex when it is added to the CLOSED list, which
|
||||
happens after all of its out edges have been examined.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./astar_visitor.html"><tt>astar_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 © 2004</TD><TD>
|
||||
<A HREF="http://www.cs.rpi.edu/~beevek/">Kristopher Beevers</A>,
|
||||
Rensselaer Polytechnic Institute (<A
|
||||
HREF="mailto:beevek@cs.rpi.edu">beevek@cs.rpi.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,172 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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><tt>boost::graph_traits<G>::traversal_category</tt><br><br>
|
||||
This tag type must be convertible to <tt>adjacency_graph_tag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<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="#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>,
|
||||
<a href="./adjacency_iterator.html"><tt>adjacency_iterator</tt></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>Design Rationale</h3>
|
||||
|
||||
The AdjacencyGraph concept is somewhat frivolous since <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a> really covers the same
|
||||
functionality (and more). The AdjacencyGraph concept exists because
|
||||
there are situations when <tt>adjacent_vertices()</tt> is more
|
||||
convenient to use than <tt>out_edges()</tt>. If you are constructing a
|
||||
graph class and do not want to put in the extra work of creating an
|
||||
adjacency iterator, have no fear. There is an adaptor class named <a
|
||||
href="./adjacency_iterator.html"> <tt>adjacency_iterator</tt></a> that
|
||||
you can use to create an adjacency iterator out of an out-edge
|
||||
iterator.
|
||||
|
||||
<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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,107 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><tt>boost::graph_traits<G>::traversal_category</tt><br><br>
|
||||
This tag type must be convertible to <tt>adjacency_matrix_tag</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>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>Complexity guarantees</H3>
|
||||
|
||||
The <TT>edge()</TT> function must return in constant time.
|
||||
|
||||
|
||||
<H3>Models</H3>
|
||||
|
||||
<a href="./adjacency_matrix.html"><tt>adjacency_matrix</tt></a>
|
||||
|
||||
<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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,224 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><img src="figs/python.gif" alt="(Python)"/>BFS Visitor 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 BFS Visitor 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>
|
||||
|
||||
<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a visitor should be a lightweight operation).
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of BFS Visitor.</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>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 Vertex</td>
|
||||
<td><tt>vis.examine_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on a vertex as it is popped from the queue. This
|
||||
happens immediately before <tt>examine_edge()</tt> is invoked
|
||||
on each of the out-edges of vertex <tt>u</tt>.
|
||||
</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>Non-Tree Edge</td>
|
||||
<td><tt>vis.non_tree_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 non-tree 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 non-tree 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 the out-edges of the adjacent vertices have been examined).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<a name="python"></a><h3>Python</h3>
|
||||
To implement a model of the <tt>BFSVisitor</tt> concept in Python,
|
||||
create a new class that derives from the <tt>BFSVisitor</tt> type of
|
||||
the graph, which will be
|
||||
named <tt><i>GraphType</i>.BFSVisitor</tt>. The events and syntax are
|
||||
the same as with visitors in C++. Here is an example for the
|
||||
Python <tt>bgl.Graph</tt> graph type:
|
||||
|
||||
<pre>
|
||||
class count_tree_edges_bfs_visitor(bgl.Graph.BFSVisitor):
|
||||
def __init__(self, name_map):
|
||||
bgl.Graph.BFSVisitor.__init__(self)
|
||||
self.name_map = name_map
|
||||
|
||||
def tree_edge(self, e, g):
|
||||
(u, v) = (g.source(e), g.target(e))
|
||||
print "Tree edge ",
|
||||
print self.name_map[u],
|
||||
print " -> ",
|
||||
print self.name_map[v]
|
||||
</pre>
|
||||
|
||||
<h3>See also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,107 +0,0 @@
|
||||
<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>BasicMatrix</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="concept:BasicMatrix"></A>
|
||||
BasicMatrix
|
||||
</H1>
|
||||
|
||||
The BasicMatrix concept provides a minimalist interface for
|
||||
accessing elements from a 2 dimensional table of values.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
none
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD>{<tt>M,I,V</tt>}</TD>
|
||||
<TD>The matrix, index, and values types that together model the BasicMatrix concept.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>A</tt></TD>
|
||||
<TD>An object of type <tt>M</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>i, j</tt></TD>
|
||||
<TD>Objects of type <tt>I</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
none
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:elt-access"><TT>A[i][j]</TT></a></TD>
|
||||
<TD>Returns a reference to the element object stored at index <tt>(i,j)</tt><br>
|
||||
Return type: <TT>V&</TT> for mutable <tt>A</tt> or <TT>const V&</TT>
|
||||
for constant <tt>A</tt>.
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
Element access is constant time.
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<pre>
|
||||
template <class M, class I, class V>
|
||||
struct BasicMatrixConcept
|
||||
{
|
||||
void constraints() {
|
||||
V& elt = A[i][j];
|
||||
const_constraints(A);
|
||||
ignore_unused_variable_warning(elt);
|
||||
}
|
||||
void const_constraints(const M& A) {
|
||||
const V& elt = A[i][j];
|
||||
ignore_unused_variable_warning(elt);
|
||||
}
|
||||
M A;
|
||||
I i, j;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,198 +0,0 @@
|
||||
<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 Ford Visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><img src="figs/python.gif" alt="(Python)"/>Bellman Ford Visitor 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 Bellman Ford Visitor 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>
|
||||
|
||||
<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a visitor should be a lightweight operation).
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of Bellman Ford Visitor.</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>
|
||||
|
||||
<a name="python"></a>
|
||||
<h3>Python</h3>
|
||||
|
||||
To implement a model of the <tt>BellmanFordVisitor</tt> concept in Python,
|
||||
create a new class that derives from the <tt>BellmanFordVisitor</tt> type of
|
||||
the graph, which will be
|
||||
named <tt><i>GraphType</i>.BellmanFordVisitor</tt>. The events and syntax are
|
||||
the same as with visitors in C++. Here is an example for the
|
||||
Python <tt>bgl.Graph</tt> graph type:
|
||||
|
||||
<pre>
|
||||
class count_tree_edges_bellman_ford_visitor(bgl.Graph.BellmanFordVisitor):
|
||||
def __init__(self, name_map):
|
||||
bgl.Graph.BellmanFordVisitor.__init__(self)
|
||||
self.name_map = name_map
|
||||
|
||||
def edge_relaxed(self, e, g):
|
||||
(u, v) = (g.source(e), g.target(e))
|
||||
print "Relaxed edge ",
|
||||
print self.name_map[u],
|
||||
print " -> ",
|
||||
print self.name_map[v]
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,179 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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><tt>boost::graph_traits<G>::traversal_category</tt><br><br>
|
||||
This tag type must be convertible to <tt>bidirectional_graph_tag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<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>.
|
||||
For both directed and undirected graphs, the target of
|
||||
an out-edge is required to be vertex <tt>v</tt> and the
|
||||
source is required to be a vertex that is adjacent to <tt>v</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 BidirectionalGraphConcept
|
||||
{
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
122
doc/Buffer.html
@@ -1,122 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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/tech/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>size_type 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/tech/stl/stack.html"><tt>std::stack</tt></a>
|
||||
<LI><a href="../../../boost/pending/mutable_queue.hpp"><tt>boost::mutable_queue</tt></a>
|
||||
</UL>
|
||||
|
||||
<p>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University and C++ Library & Compiler Group/SGI (<A HREF="mailto:jsiek@engr.sgi.com">jsiek@engr.sgi.com</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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/tech/stl/EqualityComparable.html">EqualityComparable</a>
|
||||
and <a
|
||||
href="http://www.sgi.com/tech/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>color_traits<T>::white()</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>color_traits<T>::gray()</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>color_traits<T>::black()</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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,216 +0,0 @@
|
||||
<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>DFS Visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><img src="figs/python.gif" alt="(Python)"/>DFS Visitor 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 DFS Visitor interface and pass an
|
||||
object of the class to <tt>depth_first_search()</tt>, thereby
|
||||
augmenting the actions taken during the graph search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a visitor should be a lightweight operation).
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of DFS Visitor.</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. For an undirected
|
||||
graph there is some ambiguity between tree edges and back edges since
|
||||
the edge <i>(u,v)</i> and <i>(v,u)</i> are the same edge, but both the
|
||||
<tt>tree_edge()</tt> and <tt>back_edge()</tt> functions will be
|
||||
invoked. One way to resolve this ambiguity is to record the tree
|
||||
edges, and then disregard the back-edges that are already marked as
|
||||
tree edges. An easy way to record tree edges is to record
|
||||
predecessors at the <tt>tree_edge</tt> event point.
|
||||
</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 is invoked on vertex <tt>u</tt> after <tt>finish_vertex</tt> has
|
||||
been called for all the vertices in the DFS-tree rooted at vertex
|
||||
<tt>u</tt>. If vertex <tt>u</tt> is a leaf in the DFS-tree, then
|
||||
the <tt>finish_vertex</tt> function is call on <tt>u</tt> after
|
||||
all the out-edges of <tt>u</tt> have been examined.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="./dfs_visitor.html"><tt>dfs_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<a name="python"></a>
|
||||
<h3>Python</h3>
|
||||
|
||||
To implement a model of the <tt>DFSVisitor</tt> concept in Python,
|
||||
create a new class that derives from the <tt>DFSVisitor</tt> type of
|
||||
the graph, which will be
|
||||
named <tt><i>GraphType</i>.DFSVisitor</tt>. The events and syntax are
|
||||
the same as with visitors in C++. Here is an example for the
|
||||
Python <tt>bgl.Graph</tt> graph type:
|
||||
|
||||
<pre>
|
||||
class count_tree_edges_dfs_visitor(bgl.Graph.DFSVisitor):
|
||||
def __init__(self, name_map):
|
||||
bgl.Graph.DFSVisitor.__init__(self)
|
||||
self.name_map = name_map
|
||||
|
||||
def tree_edge(self, e, g):
|
||||
(u, v) = (g.source(e), g.target(e))
|
||||
print "Tree edge ",
|
||||
print self.name_map[u],
|
||||
print " -> ",
|
||||
print self.name_map[v]
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,226 +0,0 @@
|
||||
<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: Dijkstra Visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><img src="figs/python.gif" alt="(Python)"/>Dijkstra Visitor Concept</H1>
|
||||
|
||||
This concept defines the visitor interface for <a
|
||||
href="./dijkstra_shortest_paths.html"><tt>dijkstra_shortest_paths()</tt></a>
|
||||
and related algorithms. The user can create a class that matches this
|
||||
interface, and then pass objects of the class into
|
||||
<tt>dijkstra_shortest_paths()</tt> to augment the actions taken during
|
||||
the search.
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a visitor should be a lightweight operation).
|
||||
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>V</tt></TD>
|
||||
<TD>A type that is a model of Dijkstra Visitor.</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">Read/Write Property Map</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">Readable Property Map</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>Examine Vertex</td>
|
||||
<td><tt>vis.examine_vertex(u, g)</tt></td>
|
||||
<td><tt>void</tt></td>
|
||||
<td>
|
||||
This is invoked on a vertex as it is popped from the queue. This
|
||||
happens immediately before <tt>examine_edge()</tt> is invoked
|
||||
on each of the out-edges of vertex <tt>u</tt>.
|
||||
</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>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>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="./dijkstra_visitor.html"><tt>dijkstra_visitor</tt></a>
|
||||
</ul>
|
||||
|
||||
<a name="python"></a>
|
||||
<h3>Python</h3>
|
||||
|
||||
To implement a model of the <tt>DijkstraVisitor</tt> concept in Python,
|
||||
create a new class that derives from the <tt>DijkstraVisitor</tt> type of
|
||||
the graph, which will be
|
||||
named <tt><i>GraphType</i>.DijkstraVisitor</tt>. The events and syntax are
|
||||
the same as with visitors in C++. Here is an example for the
|
||||
Python <tt>bgl.Graph</tt> graph type:
|
||||
|
||||
<pre>
|
||||
class count_tree_edges_dijkstra_visitor(bgl.Graph.DijkstraVisitor):
|
||||
def __init__(self, name_map):
|
||||
bgl.Graph.DijkstraVisitor.__init__(self)
|
||||
self.name_map = name_map
|
||||
|
||||
def edge_relaxed(self, e, g):
|
||||
(u, v) = (g.source(e), g.target(e))
|
||||
print "Relaxed edge ",
|
||||
print self.name_map[u],
|
||||
print " -> ",
|
||||
print self.name_map[v]
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,188 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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><tt>boost::graph_traits<G>::traversal_category</tt><br><br>
|
||||
This tag type must be convertible to <tt>edge_list_graph_tag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,112 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2001
|
||||
--
|
||||
-- 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>Edge Mutable Graph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:EdgeMutableGraph">
|
||||
Edge Mutable Graph
|
||||
</H2>
|
||||
|
||||
The <I>Edge Mutable Graph</I> concept defines the interface for a
|
||||
graph that supports the addition and removal of edges.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
No additional associated types.
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><a name="sec:add_edge"><TT>add_edge(u, v, g)</TT></a>
|
||||
<b>returns</b> <TT>std::pair<edge_descriptor, bool></TT>
|
||||
<br><br>
|
||||
|
||||
<b>Semantics:</b> Try to insert the edge <i>(u,v)</i> into the graph,
|
||||
returning the inserted edge or a parallel edge and a flag that
|
||||
specifies whether an edge was inserted. This operation must not
|
||||
invalidate vertex descriptors or vertex iterators of the graph, though
|
||||
it may invalidate edge descriptors or edge iterators.<br>
|
||||
|
||||
<b>Preconditions:</b> <i>u</i> and <i>v</i> are vertices in the
|
||||
graph. <br>
|
||||
|
||||
<b>Postconditions:</b> <i>(u,v)</i> is in the edge set of
|
||||
the graph. The returned edge descriptor will have <i>u</i> in the
|
||||
source position and <i>v</i> in the target position. If the graph
|
||||
allows parallel edges, then the returned flag is always
|
||||
<tt>true</tt>. If the graph does not allow parallel edges, if
|
||||
<i>(u,v)</i> was already in the graph then the returned flag is
|
||||
<tt>false</tt>. If <i>(u,v)</i> was not in the graph then the returned
|
||||
flag is <tt>true</tt>.<br>
|
||||
</li><br>
|
||||
|
||||
<li><a name="sec:remove_edge_by_pair"><tt>remove_edge(u, v, g)</tt></a>
|
||||
<b>returns</b> <tt>void</tt><br><br>
|
||||
<b>Semantics:</b> Remove the edge <i>(u,v)</i> from the graph. If the
|
||||
graph allows parallel edges this removes all occurrences of <i>(u,v)</i>. <br>
|
||||
<b>Precondition:</b> <i>(u,v)</i> is in the edge set of the graph. <br>
|
||||
<b>Postcondition:</b> <i>(u,v)</i> is no longer in the edge set of the graph. <br>
|
||||
</li><br>
|
||||
|
||||
<li>
|
||||
<a name="sec:remove_edge"><tt>remove_edge(e, g)</tt></a>
|
||||
<b>returns</b> <tt>void</tt><br><br>
|
||||
<b>Semantics:</b> Remove the edge <i>e</i> from the graph.<br>
|
||||
<b>Precondition:</b> <i>e</i> is an edge in the graph. <br>
|
||||
<b>Postcondition:</b> <i>e</i> is no longer in the edge set for <tt>g</tt>. <br>
|
||||
</li><br>
|
||||
|
||||
<li>
|
||||
<a name="sec:clear_vertex"><tt>clear_vertex(u, g)</tt></a>
|
||||
<b>returns</b> <tt>void</tt><br><br>
|
||||
<b>Semantics:</b> Remove all edges to and from vertex <i>u</i> from the graph. <br>
|
||||
<b>Precondition:</b> <i>u</i> is a valid vertex descriptor of
|
||||
<tt>g</tt>. <br> <b>Postconditions:</b> <i>u</i> does not appear as a
|
||||
source or target of any edge in <tt>g</tt>.
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
|
||||
<P>
|
||||
UNDER CONSTRUCTION
|
||||
|
||||
<H3>See Also</H3>
|
||||
|
||||
<a href="./graph_concepts.html">Graph concepts</a>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,165 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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>
|
||||
|
||||
<a href="../../utility/CopyConstructible.html">Copy Constructible</a>
|
||||
(copying a visitor should be a lightweight operation).
|
||||
|
||||
<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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,131 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
153
doc/Graph.html
@@ -1,153 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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. One should
|
||||
note that a model of Graph is <B>not</B> required to be a model of <a
|
||||
href="http://www.sgi.com/tech/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/tech/stl/DefaultConstructible.html">Default Constructible</a>,
|
||||
<a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, and
|
||||
<a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</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/tech/stl/DefaultConstructible.html">Default Constructible</I>,
|
||||
<a
|
||||
href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>,
|
||||
and <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</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>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::traversal_category</pre>
|
||||
This describes the ways in which the vertices and edges of the
|
||||
graph can be visited. The choices are <TT>incidence_graph_tag</TT>,
|
||||
<TT>adjacency_graph_tag</TT>, <TT>bidirectional_graph_tag</TT>,
|
||||
<TT>vertex_list_graph_tag</TT>, <TT>edge_list_graph_tag</TT>, and
|
||||
<TT>adjacency_matrix_tag</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Valid Expressions</H3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::graph_traits<G>::null_vertex()</pre></td></TD>
|
||||
<td>
|
||||
Returns a special <tt>boost::graph_traits<G>::vertex_descriptor</tt> object which does not refer to
|
||||
any vertex of graph object which type is <tt>G</tt>.
|
||||
<td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<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;
|
||||
typedef typename boost::graph_traits<G>::traversal_category traversal_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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,206 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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>u, v</tt></TD>
|
||||
<TD>Are objects of type <tt>boost::graph_traits<G>::vertex_descriptor</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><tt>boost::graph_traits<G>::traversal_category</tt><br><br>
|
||||
This tag type must be convertible to <tt>incidence_graph_tag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<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(u, 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>u</TT> in graph <TT>g</TT>. The source vertex of an edge obtained
|
||||
via an out edge iterator is guaranteed (for both directed and
|
||||
undirected graphs) to be the vertex <tt>u</tt> used in the call to
|
||||
<tt>out_edges(u, g)</tt> and the target vertex must the a vertex
|
||||
adjacent to <tt>u</tt>.<a href="#1">[1]</a>
|
||||
<br>
|
||||
Return type: <TT>std::pair<out_edge_iterator, out_edge_iterator></TT>
|
||||
</TD>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<TD><TT>out_degree(u, 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>u</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>Notes</H3>
|
||||
|
||||
<a name="1">[1]</a> For undirected graphs, the edge <tt>(u,v)</tt> is
|
||||
the same as edge <tt>(v,u)</tt>, so without some extra guarantee an
|
||||
implementation would be free use any ordering for the pair of vertices
|
||||
in an out-edge. For example, if you call <tt>out_edges(u, g)</tt>, and
|
||||
<tt>v</tt> is one of the vertices adjacent to <tt>u</tt>, then the
|
||||
implementation would be free to return <tt>(v,u)</tt> as an out-edge
|
||||
which would be non-intuitive and cause trouble for algorithms.
|
||||
Therefore, the extra requirement is added that the out-edge connecting
|
||||
<tt>u</tt> and <tt>v</tt> must be given as <tt>(u,v)</tt> and not
|
||||
<tt>(v,u)</tt>.
|
||||
|
||||
<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(u, g);
|
||||
e = *p.first;
|
||||
u = source(e, g);
|
||||
v = target(e, g);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
p = out_edges(u, 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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,165 +0,0 @@
|
||||
<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>IteratorConstructibleGraph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="concept:IteratorConstructibleGraph"></A>
|
||||
IteratorConstructibleGraph
|
||||
</H1>
|
||||
|
||||
The IteratorConstructibleGraph concept describes the interface for
|
||||
graph types that can be constructed using a kind of edge iterator. The
|
||||
edge iterator can be any <a
|
||||
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>
|
||||
that dereferences to a pair of integers <i>(i,j)</i>, which represent
|
||||
an edge that should be in the graph. The two integers <i>i</i> and
|
||||
<i>j</i> represent vertices where <i>0 <= i < |V|</i> and <i>0 <= j <
|
||||
|V|</i>. The edge iterator's value type should be
|
||||
<tt>std::pair<T,T></tt> (or at least be a structure that has
|
||||
members <tt>first</tt> and <tt>second</tt>) and the value type
|
||||
<tt>T</tt> of the pair must be convertible to the
|
||||
<tt>vertices_size_type</tt> of the graph (an integer).
|
||||
|
||||
There are two valid expressions required by this concept, both of
|
||||
which are constructors. The first creates a graph object from a
|
||||
first/last iterator range. The second constructor also takes a
|
||||
first/last iterator range and in addition requires the number of
|
||||
vertices and number of edges. For some graph and edge iterator types
|
||||
the second constructor can be more efficient than the first.
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
The following exampe creates two graph objects from an array of edges
|
||||
(vertex pairs). The type <tt>Edge*</tt> satisfies the requirements for
|
||||
an <a
|
||||
href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>
|
||||
and can therefore be used to construct a graph.
|
||||
|
||||
<pre>
|
||||
typedef ... IteratorConstructibleGraph;
|
||||
typedef boost::graph_traits<IteratorConstructibleGraph> Traits;
|
||||
|
||||
typedef std::pair<Traits::vertices_size_type,
|
||||
Traits::vertices_size_type> 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) };
|
||||
Edge* first = edge_array,
|
||||
last = edge_array + sizeof(edge_array)/sizeof(Edge);
|
||||
|
||||
IteratorConstructibleGraph G1(first, last);
|
||||
// do something with G1 ...
|
||||
|
||||
Traits::vertices_size_type size_V = 6;
|
||||
Traits::edges_size_type size_E = sizeof(edge_array)/sizeof(Edge);
|
||||
IteratorConstructibleGraph G2(first, last, size_V, size_E);
|
||||
// do something with G2 ...
|
||||
</pre>
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a href="Graph.html">Graph</a>
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<tr>
|
||||
<td><tt>G</tt></td>
|
||||
<td>is a graph type that models IteratorConstructibleGraph.</td>
|
||||
<tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>g</tt></td>
|
||||
<td>is an object of type <tt>G</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>first, last</tt></td>
|
||||
<td>are edge iterators (see above).</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>Tr</tt></td>
|
||||
<td>is an object of type <tt>graph_traits<G></tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>n_vertices</tt></td>
|
||||
<td>is an object of type <tt>Tr::vertices_size_type</tt>.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>n_edges</tt></td>
|
||||
<td>is an object of type <tt>Tr::edges_size_type</tt>.</td>
|
||||
</tr>
|
||||
|
||||
</Table>
|
||||
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<pre>G g(first, last);</pre>
|
||||
Construct graph object <tt>g</tt> given an edge range <tt>[first,last)</tt>.
|
||||
</td>
|
||||
<tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<pre>G g(first, last, n_vertices, n_edges);</pre>
|
||||
Construct graph object <tt>g</tt> given an edge range
|
||||
<tt>[first,last)</tt>, the number of vertices, and the number of
|
||||
edges. Sometimes this constructor is more efficient than the
|
||||
constructor lacking the graph size information.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</Table>
|
||||
|
||||
|
||||
<!--
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
</PRE>
|
||||
-->
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
95
doc/Makefile
@@ -1,95 +0,0 @@
|
||||
DVIPS = dvips
|
||||
|
||||
LATEX = latex
|
||||
LATEXOUT = dvi
|
||||
RESULT = ps
|
||||
|
||||
LATEX = pdflatex
|
||||
LATEXOUT = pdf
|
||||
RESULT = pdf
|
||||
|
||||
.SUFFIXES: .tex .dvi .ps .pdf .c .lg .eps .fig .gif .dot .w .cpp .o .exe
|
||||
|
||||
.tex.$(LATEXOUT):
|
||||
@ if test ! -f $*.ind; then echo "" > $*.ind; fi
|
||||
@ $(LATEX) $*
|
||||
@ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
|
||||
then $(LATEX) $* ; fi
|
||||
@ if ( grep 'LaTeX Warning: Citation' $*.log > /dev/null ); \
|
||||
then bibtex $* ; $(LATEX) $* ; fi
|
||||
@ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
|
||||
then $(LATEX) $* ; fi
|
||||
@ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
|
||||
then $(LATEX) $* ; fi
|
||||
@ if ( grep 'Writing index file' $*.log > /dev/null ); \
|
||||
then makeindex $* ; $(LATEX) $* ; fi
|
||||
@ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
|
||||
then $(LATEX) $* ; fi
|
||||
@ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
|
||||
then $(LATEX) $* ; fi
|
||||
|
||||
.dvi.ps:
|
||||
$(DVIPS) -t letter -o $*.ps $*
|
||||
|
||||
.eps.pdf:
|
||||
epstopdf $*.eps
|
||||
|
||||
.dot.eps:
|
||||
dot -Tps -o $*.eps $*.dot
|
||||
|
||||
.w.tex: /afs/nd.edu/user11/jsiek/.jweb
|
||||
jweb -np $*.w
|
||||
|
||||
BOOST = $(HOME)/boost
|
||||
BOOST_ALGO = $(HOME)/boost.algorithm
|
||||
CXX = c++
|
||||
INCLUDES = -I$(BOOST) -I$(BOOST_ALGO)
|
||||
#OPT = +K2 --display_error_number --diag_suppress=186
|
||||
OPT = -Wall -Wno-long-double -ftemplate-depth-30
|
||||
CXXFLAGS = $(OPT) $(INCLUDES)
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(CXXFLAGS) $< -c
|
||||
|
||||
|
||||
JWEB = isomorphism-impl.w isomorphism-impl-v3.w
|
||||
DOT = out.dot in.dot iso-eg.dot iso-eg2.dot
|
||||
EPS_GEN = $(DOT:.dot=.eps)
|
||||
WEBTEX = $(JWEB:.w=.tex)
|
||||
PDFPICT = $(EPS_GEN:.eps=.pdf)
|
||||
|
||||
default: isomorphism-impl-v3.$(RESULT)
|
||||
|
||||
final: isomorphism-impl-v3.$(RESULT)
|
||||
$(LATEX) isomorphism-impl-v3
|
||||
csh ./mungeaux.csh *.aux
|
||||
$(LATEX) isomorphism-impl-v3
|
||||
|
||||
#isomorphism-impl.dvi: $(EPS_GEN) $(WEBTEX)
|
||||
#isomorphism-impl.ps: isomorphism-impl.dvi
|
||||
#isomorphism-impl.pdf: $(EPS_GEN) $(PDFPICT) $(WEBTEX)
|
||||
#isomorphism.hpp: isomorphism-impl.w isomorphism-impl.tex
|
||||
|
||||
isomorphism-impl-v3.dvi: $(DOT) $(EPS_GEN) $(WEBTEX)
|
||||
isomorphism-impl-v3.ps: isomorphism-impl-v3.dvi
|
||||
isomorphism-impl-v3.pdf: $(EPS_GEN) $(PDFPICT) $(WEBTEX)
|
||||
|
||||
isomorphism-v3.hpp: isomorphism-impl-v3.w isomorphism-impl-v3.tex
|
||||
|
||||
out.dot: isomorphism-impl.tex
|
||||
in.dot: isomorphism-impl.tex
|
||||
|
||||
isomorphism.o: isomorphism-v3.hpp isomorphism-impl-v3.w
|
||||
|
||||
isomorphism: isomorphism.o
|
||||
$(CXX) $(CXXFLAGS) $< -o $@ $(LIBS)
|
||||
|
||||
isomorphism-v3.hpp: isomorphism-impl-v3.tex isomorphism-impl-v3.w
|
||||
eg1-iso.o: isomorphism-impl-v3.tex isomorphism-impl-v3.w
|
||||
|
||||
eg1-iso: eg1-iso.o
|
||||
$(CXX) $(CXXFLAGS) $< -o $@ $(LIBS)
|
||||
|
||||
|
||||
clean:
|
||||
rm *.aux *.dvi $(EPS_GEN) $(PDFPICT)
|
||||
126
doc/Monoid.html
@@ -1,126 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2001
|
||||
--
|
||||
-- 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>Monoid</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="concept:Monoid"></A>
|
||||
Monoid
|
||||
</H1>
|
||||
|
||||
A <i>Monoid</i> is a concept that describes a simple kind of algebraic
|
||||
system. A <b>monoid</b> consists of a set of elements <i>S</i>, a
|
||||
binary operation, and an identity element. The C++ representation of a
|
||||
monoid consists of a function object that implements the binary
|
||||
operation, a set of objects that represent the elements of <i>S</i>,
|
||||
and an object that represents the identity element.
|
||||
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
The element type must be a model of <a
|
||||
href="../../utility/Assignable.html">Assignable</a> and <a
|
||||
href="../../utility/CopyConstructible.html">CopyConstructible</a>.
|
||||
The function object type must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryFunction.html">BinaryFunction</a>.
|
||||
|
||||
<h3>Notation</h3>
|
||||
|
||||
<Table>
|
||||
<TR>
|
||||
<TD><tt>X</tt></TD>
|
||||
<TD>Is the element type of the Monoid.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>a, b</tt></TD>
|
||||
<TD>are objects of type <tt>X</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>op</tt></TD>
|
||||
<TD>Is the function object implementing the Monoid operation.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>i</tt></TD>
|
||||
<TD>is an object of type <tt>X</tt> and is the identity element
|
||||
for the Monoid.</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><a name="sec:source"><TT>op(a, b)</TT></a></TD>
|
||||
<TD>See below for semantics.<br>
|
||||
Return type: <TT>X</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>a == b</TT></TD>
|
||||
<TD>Returns true if <tt>a</tt> and <tt>b</tt> represent
|
||||
the same element of <i>S</i>.<br>
|
||||
Return type: <TT>bool</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>a != b</TT></TD>
|
||||
<TD>Returns true if <tt>a</tt> and <tt>b</tt> represent
|
||||
different elements of <i>S</i>.<br>
|
||||
Return type: <TT>bool</TT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Invariants</H3>
|
||||
|
||||
<UL>
|
||||
<li>Closure<br>
|
||||
The result of <tt>op(a, b)</tt> is also an element of <i>S</i>.
|
||||
<li>Associativity<br>
|
||||
<tt>op(op(a, b), c) == op(a, op(b, c))</tt>
|
||||
<li>Definition of Identity Element<br>
|
||||
<tt>op(a, i) == a</tt>
|
||||
</UL>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,303 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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/tech/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, and returns an edge
|
||||
descriptor pointing to the new edge. If the graph disallows parallel
|
||||
edges, and the edge <i>(u,v)</i> is already in the graph, then the
|
||||
<tt>bool</tt> flag returned is <tt>false</tt> and the returned edge
|
||||
descriptor points to the already existing edge. Note that for
|
||||
undirected graphs, <i>(u,v)</i> is the same edge as <i>(v,u)</i>, so
|
||||
after a call to the function <tt>add_edge()</tt>, this implies that
|
||||
edge <i>(u,v)</i> will appear in the out-edges of <i>u</i> and
|
||||
<i>(u,v)</i> (or equivalently <i>(v,u)</i>) will appear in the
|
||||
out-edges of <i>v</i>. Put another way, <i>v</i> will be adjacent to
|
||||
<i>u</i> and <i>u</i> will be adjacent to <i>v</i>.
|
||||
<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 occurrences 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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,154 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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(u, v, ep, g)</TT></TD>
|
||||
<TD>Inserts the edge <i>(u,v)</i> into the graph, and
|
||||
copies object <TT>ep</TT> into the property for that edge.<br>
|
||||
Return type: <TT>std::pair<edge_descriptor, bool></TT></TD>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<TD><TT>add_vertex(vp, g)</TT></TD>
|
||||
<TD>
|
||||
Add a new vertex to the graph and copy <TT>vp</TT> into the
|
||||
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(vp, g);
|
||||
p = add_edge(u, v, ep, g);
|
||||
}
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,214 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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>PropertyTag</tt></TD>
|
||||
<TD>A type that models the <a href="./PropertyTag.html">PropertyTag</a> concept.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>p</tt></TD>
|
||||
<TD>An object of type <tt>PropertyTag</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, PropertyTag>::type</pre>
|
||||
The type of the property map for the property specified by
|
||||
<TT>PropertyTag</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 edge descriptor type.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><pre>boost::property_map<G, PropertyTag>::const_type</pre>
|
||||
The type of the const property map for the property specified by
|
||||
<TT>PropertyTag</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>PropertyTag</tt> type. The object <tt>p</tt> is only used to
|
||||
carry the type.<br>
|
||||
Return type: <TT>boost::property_map<G, PropertyTag>::type</TT> if <TT>g</TT> is mutable and <br><TT>boost::property_map<G, PropertyTag>::const_type</TT> otherwise.
|
||||
</td>
|
||||
</TR>
|
||||
|
||||
<tr>
|
||||
<td> <TT>get(p, g, x)</TT> </td>
|
||||
<td>
|
||||
Returns the property value (specified by the <tt>PropertyTag</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>PropertyTag</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>PropertyTag=vertex_distance_t</tt>.</li>
|
||||
<li><tt>adjacency_list</tt> with <tt>VertexPropertyTag=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></TT> and <tt>PropertyTag=vertex_in_degree_t</tt>.</li>
|
||||
</UL>
|
||||
|
||||
|
||||
<H3>Concept Checking Class</H3>
|
||||
|
||||
<PRE>
|
||||
template <class Graph, class X, class PropertyTag>
|
||||
struct PropertyGraphConcept
|
||||
{
|
||||
typedef typename property_map<G, PropertyTag>::type Map;
|
||||
typedef typename property_map<G, PropertyTag>::const_type const_Map;
|
||||
void constraints() {
|
||||
function_requires< GraphConcept<G> >();
|
||||
function_requires< ReadWritePropertyMapConcept<Map, X> >();
|
||||
function_requires< ReadablePropertyMapConcept<const_Map, X> >();
|
||||
|
||||
Map pmap = get(PropertyTag(), g);
|
||||
pval = get(PropertyTag(), g, x);
|
||||
put(PropertyTag(), g, x, pval);
|
||||
ignore_unused_variable_warning(pmap);
|
||||
}
|
||||
void const_constraints(const G& g) {
|
||||
const_Map pmap = get(PropertyTag(), g);
|
||||
pval = get(PropertyTag(), 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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,121 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:PropertyTag"></A>
|
||||
PropertyTag
|
||||
</H2>
|
||||
|
||||
A Property Tag 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. See the section about <A
|
||||
href="using_adjacency_list.html#sec:custom-edge-properties"> Custom
|
||||
Edge Properties</a> for a description of how to define your own
|
||||
property tags.
|
||||
|
||||
|
||||
<h3>Associated Types</h3>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<td>Property Kind </td>
|
||||
<td><TT>property_kind<PropertyTag>::type</TT> </td>
|
||||
<td>
|
||||
|
||||
This specifies whether the property is a <a
|
||||
name="VertexPropertyTag"><b>Vertex Property Tag</b></a>
|
||||
(<tt>vertex_property_tag</tt>), an <a
|
||||
name="EdgePropertyTag"><b>Edge Property Tag</b></a> (<tt>edge_property_tag</tt>), or
|
||||
a <a name="GraphPropertyTag"><b>Graph Property Tag</b></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>. The <tt>property_kind</tt> traits class is defined in <a href="../../../boost/pending/property.hpp"><tt>boost/pending/property.hpp</tt></a>.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Property ID Number </td>
|
||||
<td><TT>property_num<PropertyTag>::value</TT> </td>
|
||||
<td>
|
||||
This is needed as a workaround when using compilers that do not
|
||||
support partial specialization (and hence prevent us from using
|
||||
<tt>boost::is_same</tt> to detect if two property tags are the same).
|
||||
The <tt>property_num</tt> traits class is defined in <a
|
||||
href="../../../boost/pending/property.hpp"><tt>boost/pending/property.hpp</tt></a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Refinement of</h3>
|
||||
|
||||
<a
|
||||
href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructible</a>
|
||||
|
||||
|
||||
<h3>Models</h3>
|
||||
|
||||
The following models of the Property Tag 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<PropertyTag></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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,74 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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 VertexAndEdgeListGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
function_requires< VertexListGraphConcept<G> >();
|
||||
function_requires< EdgeListGraphConcept<G> >();
|
||||
}
|
||||
};
|
||||
</PRE>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,158 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H2><A NAME="concept:VertexListGraph">
|
||||
VertexListGraph
|
||||
</H2>
|
||||
|
||||
The <I>VertexListGraph</I> concept refines the <a
|
||||
href="./Graph.html">Graph</a> concept, and adds the requirement for
|
||||
efficient traversal of all the vertices in the graph.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
<Table border>
|
||||
|
||||
<tr>
|
||||
<td><tt>boost::graph_traits<G>::traversal_category</tt><br><br>
|
||||
This tag type must be convertible to <tt>vertex_list_graph_tag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<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>Design Rationale</H3>
|
||||
|
||||
One issue in the design of this concept is whether to include the
|
||||
refinement from the <a href="./IncidenceGraph.html">IncidenceGraph</a>
|
||||
and <a href="./AdjacencyGraph.html">AdjacencyGraph</a> concepts. The
|
||||
ability to traverse the vertices of a graph is orthogonal to
|
||||
traversing out-edges, so it would make sense to have a VertexListGraph
|
||||
concept that only includes vertex traversal. However, such a concept
|
||||
would no longer really be a graph, but would just be a set, and the
|
||||
STL already has concepts for dealing with such things. However, there
|
||||
are many BGL algorithms that need to traverse the vertices and
|
||||
out-edges of a graph, so for convenience a concept is needed that
|
||||
groups these requirements together, hence the VertexListGraph concept.
|
||||
|
||||
|
||||
<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< IncidenceGraphConcept<G> >();
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,87 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2001
|
||||
--
|
||||
-- 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>Vertex Mutable Graph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="concept:VertexMutableGraph">
|
||||
Vertex Mutable Graph
|
||||
</H2>
|
||||
|
||||
A vertex mutable graph can be changed by adding or removing
|
||||
vertices. The memory management is the responsibility of the graph
|
||||
implementation. The graph user need only make calls to
|
||||
<TT>add_vertex</TT> and <TT>remove_vertex</TT> and the graph
|
||||
implementation does the rest.
|
||||
|
||||
<H3>Refinement of</H3>
|
||||
|
||||
<a href="./Graph.html">Graph</a> and <a
|
||||
href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>
|
||||
|
||||
<H3>Associated Types</H3>
|
||||
|
||||
No additional associated types.
|
||||
|
||||
<h3>Valid Expressions</h3>
|
||||
|
||||
<ul>
|
||||
<li><a name="sec:add_vertex"><TT>add_vertex(g)</TT></a>
|
||||
<b>returns</b> <TT>vertex_descriptor</TT>
|
||||
<br><br>
|
||||
|
||||
<b>Semantics:</b> Add a new vertex to the graph. The
|
||||
<TT>vertex_descriptor</TT> for the new vertex is returned.<br>
|
||||
</li>
|
||||
|
||||
<li><a name="sec:remove_vertex"><tt>remove_vertex(u, g)</tt></a>
|
||||
<b>returns</b> <tt>void</tt><br><br>
|
||||
|
||||
<b> Semantics:</b> Remove <i>u</i> from the vertex set of the graph.
|
||||
<br>
|
||||
<b> Preconditions:</b> <i>u</i> is a valid vertex descriptor of graph <i>g</i>
|
||||
and there are no edges incident to vertex <i>u</i>. The function
|
||||
<TT>clear_vertex</TT> can be used to remove all incident edges.
|
||||
<br>
|
||||
<b> Postconditions: </b> <TT>num_vertices(g)</TT> is one less; <i>u</i>
|
||||
no longer appears in the vertex set of the graph and it
|
||||
is no longer a valid vertex descriptor.
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<H3>Complexity guarantees</H3>
|
||||
<ul>
|
||||
<li> Vertex insertion is guaranteed to be amortized constant time.
|
||||
|
||||
<li> Vertex removal is at most <TT>O(|E| + |V|)</TT>.
|
||||
</ul>
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
<A HREF="../../../people/jeremy_siek.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,129 +0,0 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
||||
<meta name="ProgId" content="FrontPage.Editor.Document">
|
||||
<title>Adjacency Iterator Adaptor Documentation</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
|
||||
<img src="../../../boost.png" alt="boost.png (6897 bytes)"
|
||||
align="center" width="277" height="86">
|
||||
|
||||
<h1>Adjacency Iterator Adaptor</h1>
|
||||
|
||||
Defined in header
|
||||
<a href="../../../boost/graph/adjacency_iterator.hpp">boost/graph/adjacency_iterator.hpp</a>
|
||||
|
||||
<p>
|
||||
The adjacency iterator adaptor transforms an
|
||||
<tt>out_edge_iterator</tt> into an adjacency iterator. That is, it
|
||||
takes an iterator that traverses over edges, and creates an iterator
|
||||
that traverses over the <b><i>target</i></b> vertices of those edges.
|
||||
With this adaptor it is trivial to take a graph type that models <a
|
||||
href="IncidenceGraph.html">Incidence Graph</a> and add the
|
||||
capabilities required of <a href="AdjacencyGraph.html">Adjacency
|
||||
Graph</a>.
|
||||
|
||||
|
||||
<h2>Synopsis</h2>
|
||||
|
||||
<pre>
|
||||
namespace boost {
|
||||
template <class Graph, class VertexDescriptor, class OutEdgeIter>
|
||||
class adjacency_iterator_generator {
|
||||
public:
|
||||
typedef <a href="../../iterator/doc/iterator_adaptor.html">iterator_adaptor</a><...> type;
|
||||
};
|
||||
}
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<p>
|
||||
The following is an example of how to use the
|
||||
<tt>adjacency_iterator_generator</tt> class.
|
||||
|
||||
<p>
|
||||
<PRE>
|
||||
#include <boost/graph/adjacency_iterator.hpp>
|
||||
|
||||
class my_graph {
|
||||
// ...
|
||||
typedef ... out_edge_iterator;
|
||||
typedef ... vertex_descriptor;
|
||||
typedef boost::adjacency_iterator_generator<my_graph, vertex_descriptor, out_edge_iterator>::type adjacency_iterator;
|
||||
// ...
|
||||
};
|
||||
|
||||
</PRE>
|
||||
|
||||
<h3>Template Parameters</h3>
|
||||
|
||||
<Table border>
|
||||
<TR>
|
||||
<TH>Parameter</TH><TH>Description</TH>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>Graph</tt></TD>
|
||||
<TD>The graph type, which must model <a
|
||||
href="./IncidenceGraph.html">Incidence Graph</a>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>VertexDescriptor</tt></TD>
|
||||
<TD>This must be the same type as
|
||||
<tt>graph_traits<Graph>::vertex_descriptor</tt>. The reason why
|
||||
this is a template parameter is that the primary use of
|
||||
<tt>adjacency_iterator_generator</tt> is <b><i>inside</i></b> the
|
||||
definition of the graph class, and in that context we can not use
|
||||
<tt>graph_traits</tt> on the not yet fully defined graph class.<br>
|
||||
<b>Default:</b> <tt>graph_traits<Graph>::vertex_descriptor</tt></TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD><tt>OutEdgeIter</tt></TD>
|
||||
<TD>This must be the same type as
|
||||
<tt>graph_traits<Graph>::out_edge_iterator</tt>.<br>
|
||||
<b>Default:</b> <tt>graph_traits<Graph>::out_edge_iterator
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</Table>
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
The adjacency iterator adaptor (the type
|
||||
<tt>adjacency_iterator_generator<...>::type</tt>) is a model of <a
|
||||
href="../../utility/MultiPassInputIterator.html">Multi-Pass Input Iterator</a>
|
||||
</a>.
|
||||
|
||||
|
||||
<h3>Members</h3>
|
||||
|
||||
The adjacency iterator type implements the member functions and
|
||||
operators required of the <a
|
||||
href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">Random Access Iterator</a>
|
||||
concept, except that the <tt>reference</tt> type is the same as the <tt>value_type</tt>
|
||||
so <tt>operator*()</tt> returns by-value. In addition it has the following constructor:
|
||||
|
||||
<pre>
|
||||
adjacency_iterator_generator::type(const OutEdgeIter& it, const Graph* g)
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->19 Aug 2001<!--webbot bot="Timestamp" endspan i-checksum="14767" --></p>
|
||||
<p>© Copyright Jeremy Siek 2000. Permission to copy, use,
|
||||
modify, sell and distribute this document is granted provided this copyright
|
||||
notice appears in all copies. This document is provided "as is"
|
||||
without express or implied warranty, and with no claim as to its suitability for
|
||||
any purpose.</p>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,162 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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/tech/stl/DefaultConstructible.html">DefaultConstructible</a> and
|
||||
<a href="http://www.sgi.com/tech/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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,558 +0,0 @@
|
||||
<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: Adjacency Matrix</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:adjacency-matrix-class"></A>
|
||||
<pre>
|
||||
adjacency_matrix<Directed, VertexProperty,
|
||||
EdgeProperty, GraphProperty,
|
||||
Allocator>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
The <tt>adjacency_matrix</tt> class implements the BGL graph interface
|
||||
using the traditional adjacency matrix storage format. For a graph
|
||||
with <i>V</i> vertices, a <i>V x V</i> matrix is used, where each
|
||||
element <i>a<sub>ij</sub></i> is a boolean flag that says whether
|
||||
there is an edge from vertex <i>i</i> to vertex <i>j</i>. <a
|
||||
href="#fig:adj-matrix-graph">Figure 1</a> shows the adjacency matrix
|
||||
representation of a graph.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:adj-matrix-graph"></A><A NAME="1509"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG> Adjacency Matrix Representation of a Directed Graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/adj-matrix-graph3.gif" width="386" height="284"></TD>
|
||||
<TD><IMG SRC="./figs/adj-matrix.gif" width="135" height="136"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
The advantage of this matrix format over the adjacency list is that
|
||||
edge insertion and removal is constant time. There are several
|
||||
disadvantages. The first is that the amount of memory used is
|
||||
<i>O(V<sup>2</sup>)</i> instead of <i>O(V + E)</i> (where <i>E</i> is
|
||||
the number of edges). The second is that operations that traverse all
|
||||
the out-edges of each vertex (such as breadth-first search) run in
|
||||
<i>O(V<sup>2</sup>)</i> time instead of <i>O(V + E)</i> time for the
|
||||
adjacency list. In short, it is better to use the
|
||||
<tt>adjacency_matrix</tt> for dense graphs (where <i>E</i> is close to
|
||||
<i>V<sup>2</sup></i>) and it is better to use <a
|
||||
href="adjacency_list.html"><tt>adjacency_list</tt></a> for sparse
|
||||
graphs (where <i>E</i> is much smaller than <i>V<sup>2</sup></i>).
|
||||
|
||||
The <tt>adjacency_matrix</tt> class extends the traditional
|
||||
data-structure by allowing objects to be attached to vertices and
|
||||
edges using the same property template parameters supported by <a
|
||||
href="adjacency_list.html"><tt>adjacency_list</tt></a>. These may be
|
||||
<a href="bundles.html">bundled properties</a> or standard (backward-compatible)
|
||||
<a
|
||||
href="using_adjacency_list.html#sec:adjacency-list-properties">interior
|
||||
properties</a>. The types of all property values must be
|
||||
Copy Constructible, Assignable and Default Constructible.
|
||||
|
||||
In the case of an undirected graph, the
|
||||
<tt>adjacency_matrix</tt>. class does not use a full <i>V x V</i>
|
||||
matrix but instead uses a lower triangle (the diagonal and below)
|
||||
since the matrix for an undirected graph is symmetric. This reduces
|
||||
the storage to <i>(V<sup>2</sup>)/2</i>. <a
|
||||
href="#fig:undir-adj-matrix-graph">Figure 2</a> shows an adjacency
|
||||
matrix representation of an undirected graph.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:undir-adj-matrix-graph"></A><A NAME="1509"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG> Adjacency Matrix Representation of an Undirected Graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/undir-adj-matrix-graph3.gif" width="260" height="240"></TD>
|
||||
<TD><IMG SRC="./figs/undir-adj-matrix2.gif" width="135" height="136"></TD></TR>
|
||||
</TABLE>
|
||||
</DIV><P></P>
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
Creating the graph of <a href="#fig:adj-matrix-graph">Figure 1</a>.
|
||||
<pre>
|
||||
enum { A, B, C, D, E, F, N };
|
||||
const char* name = "ABCDEF";
|
||||
|
||||
typedef boost::adjacency_matrix<boost::directedS> Graph;
|
||||
Graph g(N);
|
||||
add_edge(B, C, g);
|
||||
add_edge(B, F, g);
|
||||
add_edge(C, A, g);
|
||||
add_edge(C, C, g);
|
||||
add_edge(D, E, g);
|
||||
add_edge(E, D, g);
|
||||
add_edge(F, A, g);
|
||||
|
||||
std::cout << "vertex set: ";
|
||||
boost::print_vertices(g, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "edge set: ";
|
||||
boost::print_edges(g, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "out-edges: " << std::endl;
|
||||
boost::print_graph(g, name);
|
||||
std::cout << std::endl;
|
||||
</pre>
|
||||
The output is:
|
||||
<pre>
|
||||
vertex set: A B C D E F
|
||||
|
||||
edge set: (B,C) (B,F) (C,A) (C,C) (D,E) (E,D) (F,A)
|
||||
|
||||
out-edges:
|
||||
A -->
|
||||
B --> C F
|
||||
C --> A C
|
||||
D --> E
|
||||
E --> D
|
||||
F --> A
|
||||
</pre>
|
||||
|
||||
Creating the graph of <a href="#fig:undir-adj-matrix-graph">Figure 2</a>.
|
||||
<pre>
|
||||
enum { A, B, C, D, E, F, N };
|
||||
const char* name = "ABCDEF";
|
||||
|
||||
typedef boost::adjacency_matrix<boost::undirectedS> UGraph;
|
||||
UGraph ug(N);
|
||||
add_edge(B, C, ug);
|
||||
add_edge(B, F, ug);
|
||||
add_edge(C, A, ug);
|
||||
add_edge(D, E, ug);
|
||||
add_edge(F, A, ug);
|
||||
|
||||
std::cout << "vertex set: ";
|
||||
boost::print_vertices(ug, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "edge set: ";
|
||||
boost::print_edges(ug, name);
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "incident edges: " << std::endl;
|
||||
boost::print_graph(ug, name);
|
||||
std::cout << std::endl;
|
||||
</pre>
|
||||
The output is:
|
||||
<pre>
|
||||
vertex set: A B C D E F
|
||||
|
||||
edge set: (C,A) (C,B) (E,D) (F,A) (F,B)
|
||||
|
||||
incident edges:
|
||||
A <--> C F
|
||||
B <--> C F
|
||||
C <--> A B
|
||||
D <--> E
|
||||
E <--> D
|
||||
F <--> A B
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/adjacency_matrix.hpp"><tt>boost/graph/adjacency_matrix.hpp</tt></a>
|
||||
|
||||
|
||||
<h3>Template Parameters</h3>
|
||||
|
||||
<p>
|
||||
<table border>
|
||||
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>Directed</tt></td>
|
||||
<td>A selector to choose whether the graph is directed or undirected. The options are <tt>directedS</tt> and <tt>undirectedS</tt>.</td>
|
||||
<td><tt>directedS</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>VertexProperty</tt></td>
|
||||
<td>for specifying internal property storage.</td>
|
||||
<td><tt>no_property</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>EdgeProperty</tt></td>
|
||||
<td>for specifying internal property storage.</td>
|
||||
<td><tt>no_property</tt></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>GraphProperty</tt></td>
|
||||
<td>for specifying property storage for the graph object.</td>
|
||||
<td><tt>no_property</tt></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Model Of</h3>
|
||||
|
||||
<a href="./VertexAndEdgeListGraph.html">VertexAndEdgeListGraph</a>, <a
|
||||
href="./AdjacencyMatrix.html">AdjacencyMatrix</a>, <a
|
||||
href="./MutablePropertyGraph.html">MutablePropertyGraph</a>,
|
||||
<a href="../../utility/CopyConstructible.html">CopyConstructible</a>,
|
||||
and <a href="../../utility/Assignable.html">Assignable</a>.
|
||||
|
||||
|
||||
<h3>Associates Types</h3>
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>graph_traits<adjacency_matrix>::vertex_descriptor</tt>
|
||||
<br><br>
|
||||
The type for the vertex descriptors associated with the
|
||||
<tt>adjacency_matrix</tt>.<br>
|
||||
(Required by <a href="./Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
|
||||
<tt>graph_traits<adjacency_matrix>::edge_descriptor</tt>
|
||||
<br><br>
|
||||
The type for the edge descriptors associated with the
|
||||
<tt>adjacency_matrix</tt>.<br>
|
||||
(Required by <a href="Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::vertex_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>vertices()</tt>.
|
||||
The vertex iterator models <a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>. <br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::edge_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>edges()</tt>. This
|
||||
iterator models <a href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::out_edge_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>out_edges()</tt>. This
|
||||
iterator models <a href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. <br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::adjacency_iterator</tt>
|
||||
<br><br>
|
||||
The type for the iterators returned by <tt>adjacent_vertices()</tt>. This
|
||||
iterator models the same concept as the out-edge iterator.<br>
|
||||
(Required by <a href="AdjacencyGraph.html">AdjacencyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::directed_category</tt>
|
||||
<br><br>
|
||||
Provides information about whether the graph is directed
|
||||
(<tt>directed_tag</tt>) or undirected (<tt>undirected_tag</tt>).<br>
|
||||
(Required by <a href="Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::edge_parallel_category</tt>
|
||||
<br><br>
|
||||
An adjacency matrix does not allow the insertion of
|
||||
parallel edges, so this type is always
|
||||
<tt>disallow_parallel_edge_tag</tt>. <br>
|
||||
(Required by <a href="Graph.html">Graph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::vertices_size_type</tt>
|
||||
<br><br>
|
||||
The type used for dealing with the number of vertices in
|
||||
the graph.<br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::edges_size_type</tt>
|
||||
<br><br>
|
||||
The type used for dealing with the number of edges in the graph.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>graph_traits<adjacency_matrix>::degree_size_type</tt>
|
||||
<br><br>
|
||||
The type used for dealing with the number of out-edges of a vertex.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<tt>property_map<adjacency_matrix, PropertyTag>::type</tt><br>
|
||||
<tt>property_map<adjacency_matrix, PropertyTag>::const_type</tt>
|
||||
<br><br>
|
||||
The map type for vertex or edge properties in the graph. The
|
||||
specific property is specified by the <tt>PropertyTag</tt> template
|
||||
argument, and must match one of the properties specified in the
|
||||
<tt>VertexProperty</tt> or <tt>EdgeProperty</tt> for the graph.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
adjacency_matrix(vertices_size_type n,
|
||||
const GraphProperty& p = GraphProperty())
|
||||
</pre>
|
||||
Creates a graph object with <tt>n</tt> vertices and zero edges.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename EdgeIterator>
|
||||
adjacency_matrix(EdgeIterator first,
|
||||
EdgeIterator last,
|
||||
vertices_size_type n,
|
||||
const GraphProperty& p = GraphProperty())
|
||||
</pre>
|
||||
Creates a graph object with <tt>n</tt> vertices with the edges
|
||||
specified in the edge list given by the range <tt>[first, last)</tt>.
|
||||
The value type of the <tt>EdgeIterator</tt> must be a
|
||||
<tt>std::pair</tt>, where the type in the pair is an integer type. The
|
||||
integers will correspond to vertices, and they must all fall in the
|
||||
range of
|
||||
<tt>[0, n)</tt>. <br>
|
||||
(Required by <a href="IteratorConstructibleGraph.html">IteratorConstructibleGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename EdgeIterator, typename EdgePropertyIterator>
|
||||
adjacency_matrix(EdgeIterator first, EdgeIterator last,
|
||||
EdgePropertyIterator ep_iter,
|
||||
vertices_size_type n,
|
||||
const GraphProperty& p = GraphProperty())
|
||||
</pre>
|
||||
Creates a graph object with <tt>n</tt> vertices, with the edges
|
||||
specified in the edge list given by the range <tt>[first, last)</tt>.
|
||||
The value type of the <tt>EdgeIterator</tt> must be a
|
||||
<tt>std::pair</tt>, where the type in the pair is an integer type. The
|
||||
integers will correspond to vertices, and they must all fall in the
|
||||
range of <tt>[0, n)</tt>. The <tt>value_type</tt> of the
|
||||
<tt>ep_iter</tt> should be <tt>EdgeProperty</tt>.
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<vertex_iterator, vertex_iterator>
|
||||
vertices(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the vertex set of graph <tt>g</i>.<br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_iterator, edge_iterator>
|
||||
edges(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the edge set of graph <tt>g</i>.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<adjacency_iterator, adjacency_iterator>
|
||||
adjacent_vertices(vertex_descriptor v, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the vertices adjacent to
|
||||
vertex <tt>v</i> in graph <tt>g</i>.<br>
|
||||
(Required by <a href="AdjacencyGraph.html">AdjacencyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<out_edge_iterator, out_edge_iterator>
|
||||
out_edges(vertex_descriptor v, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns an iterator-range providing access to the out-edges of
|
||||
vertex <tt>v</i> in graph <tt>g</i>. If the graph is undirected,
|
||||
this iterator-range provides access to all edge incident on
|
||||
vertex <tt>v</i>. <br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertex_descriptor
|
||||
source(edge_descriptor e, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the source vertex of edge <tt>e</i>.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertex_descriptor
|
||||
target(edge_descriptor e, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the target vertex of edge <tt>e</i>.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
degree_size_type
|
||||
out_degree(vertex_descriptor u, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the number of edges leaving vertex <tt>u</i>.<br>
|
||||
(Required by <a href="IncidenceGraph.html">IncidenceGraph</a>.)
|
||||
<hr>
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertices_size_type num_vertices(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the number of vertices in the graph <tt>g</i>.<br>
|
||||
(Required by <a href="VertexListGraph.html">VertexListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
edges_size_type num_edges(const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the number of edges in the graph <tt>g</tt>.<br>
|
||||
(Required by <a href="EdgeListGraph.html">EdgeListGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
vertex_descriptor vertex(vertices_size_type n, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the nth vertex in the graph's vertex list.
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_descriptor, bool>
|
||||
edge(vertex_descriptor u, vertex_descriptor v,
|
||||
const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the edge connecting vertex <tt>u</i> to vertex <tt>v</i> in graph <tt>g</i>.<br>
|
||||
(Required by <a href="AdjacencyMatrix.html">AdjacencyMatrix</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_descriptor, bool>
|
||||
add_edge(vertex_descriptor u, vertex_descriptor v,
|
||||
adjacency_matrix& g)
|
||||
</pre>
|
||||
Adds edge <tt>(u,v)</i> to the graph and returns the edge descriptor for
|
||||
the new edge. If the edge is already in the graph then a duplicate
|
||||
will not be added and the <tt>bool</tt> flag will be <tt>false</tt>.
|
||||
This operation does not invalidate any of the graph's iterators
|
||||
or descriptors.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
std::pair<edge_descriptor, bool>
|
||||
add_edge(vertex_descriptor u, vertex_descriptor v,
|
||||
const EdgeProperty& p,
|
||||
adjacency_matrix& g)
|
||||
</pre>
|
||||
Adds edge <tt>(u,v)</i> to the graph and attaches <tt>p</tt> as the
|
||||
value of the edge's internal property storage. Also see the previous
|
||||
<tt>add_edge()</tt> member function for more details.
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
void remove_edge(vertex_descriptor u, vertex_descriptor v,
|
||||
adjacency_matrix& g)
|
||||
</pre>
|
||||
Removes the edge <tt>(u,v)</i> from the graph. <br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
void remove_edge(edge_descriptor e, adjacency_matrix& g)
|
||||
</pre>
|
||||
Removes the edge <tt>e</tt> from the graph. This is equivalent
|
||||
to calling <tt>remove_edge(source(e, g), target(e, g), g)</tt>.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
void clear_vertex(vertex_descriptor u, adjacency_matrix& g)
|
||||
</pre>
|
||||
Removes all edges to and from vertex <tt>u</i>. The vertex still appears
|
||||
in the vertex set of the graph.<br>
|
||||
(Required by <a href="MutableGraph.html">MutableGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename Property>
|
||||
property_map<adjacency_matrix, Property>::type
|
||||
get(Property, adjacency_matrix& g)
|
||||
|
||||
template <typename Property>
|
||||
property_map<adjacency_matrix, Property>::const_type
|
||||
get(Property, const adjacency_matrix& g)
|
||||
</pre>
|
||||
Returns the property map object for the vertex property specified by
|
||||
<tt>Property</tt>. The <tt>Property</tt> must match one of the
|
||||
properties specified in the graph's <tt>VertexProperty</tt> template
|
||||
argument.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename Property, typename X>
|
||||
typename property_traits<
|
||||
typename property_map<adjacency_matrix, Property>::const_type
|
||||
>::value_type
|
||||
get(Property, const adjacency_matrix& g, X x)
|
||||
</pre>
|
||||
This returns the property value for <tt>x</tt>, which is either
|
||||
a vertex or edge descriptor.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename Property, typename X, typename Value>
|
||||
void
|
||||
put(Property, const adjacency_matrix& g, X x, const Value& value)
|
||||
</pre>
|
||||
This sets the property value for <tt>x</tt> to
|
||||
<tt>value</tt>. <tt>x</tt> is either a vertex or edge descriptor.
|
||||
<tt>Value</tt> must be convertible to
|
||||
<tt>typename property_traits<property_map<adjacency_matrix, Property>::type>::value_type</tt>.<br>
|
||||
(Required by <a href="PropertyGraph.html">PropertyGraph</a>.)
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename GraphProperty, typename GraphProperty>
|
||||
typename property_value<GraphProperty, GraphProperty>::type&
|
||||
get_property(adjacency_matrix& g, GraphProperty)
|
||||
</pre>
|
||||
Return the property specified by <tt>GraphProperty</tt> that is attached
|
||||
to the graph object <tt>g</tt>. The <tt>property_value</tt> traits class
|
||||
is defined in <tt>boost/pending/property.hpp</tt>.
|
||||
|
||||
<hr>
|
||||
<pre>
|
||||
template <typename GraphProperty, typename GraphProperty>
|
||||
const typename property_value<GraphProperty, GraphProperty>::type&
|
||||
get_property(const adjacency_matrix& g, GraphProperty)
|
||||
</pre>
|
||||
Return the property specified by <tt>GraphProperty</tt> that is
|
||||
attached to the graph object <tt>g</tt>. The <tt>property_value</tt>
|
||||
traits class is defined in <tt>boost/pending/property.hpp</tt>.
|
||||
|
||||
|
||||
<hr>
|
||||
@@ -1,100 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) 2004 Kris Beevers
|
||||
--
|
||||
-- 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: astar_heuristic</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
astar_heuristic<Graph, CostType>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This class is a default implementation of the <a
|
||||
href="./AStarHeuristic.html">AStarHeuristic</a> concept. It
|
||||
implements a "zero" heuristic -- a heuristic function that returns a
|
||||
cost of zero regardless of the vertex it is passed.
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./AStarHeuristic.html">AStarHeuristic</a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>Graph</TT></TD>
|
||||
<TD>
|
||||
The type of the graph being searched.
|
||||
</TD>
|
||||
<TD></TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>CostType</TT></TD>
|
||||
<TD>
|
||||
A type that can be used with the <tt>compare</tt> and
|
||||
<tt>combine</tt> functions passed to A*. Typically an integer or
|
||||
floating point type.
|
||||
</TD>
|
||||
<TD></TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/astar_search.hpp">
|
||||
<TT>boost/graph/astar_search.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements the single member function required by <a
|
||||
href="./AStarHeuristic.html">AStarHeuristic</a>:
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
CostType operator()(graph_traits<Graph>::vertex_descriptor u);
|
||||
</tt></td><td>
|
||||
Called for the target of every out edge of a vertex being examined.
|
||||
Returns the cost, estimated by the heuristic, from vertex <tt>u</tt>
|
||||
to a goal.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<A HREF="http://www.cs.rpi.edu/~beevek/">Kristopher Beevers</A>,
|
||||
Rensselaer Polytechnic Institute (<A
|
||||
HREF="mailto:beevek@cs.rpi.edu">beevek@cs.rpi.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,477 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) 2004 Kris Beevers
|
||||
--
|
||||
-- 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: A* Heuristic Search</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:astar"></A>
|
||||
<TT>astar_search</TT>
|
||||
</H1>
|
||||
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// Named parameter interface</i>
|
||||
template <typename VertexListGraph,
|
||||
typename AStarHeuristic,
|
||||
typename P, typename T, typename R>
|
||||
void
|
||||
astar_search
|
||||
(VertexListGraph &g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
<a href="AStarHeuristic.html">AStarHeuristic</a> h, const bgl_named_params<P, T, R>& params);
|
||||
|
||||
<i>// Non-named parameter interface</i>
|
||||
template <typename VertexListGraph, typename AStarHeuristic,
|
||||
typename <a href="AStarVisitor.html">AStarVisitor</a>, typename PredecessorMap,
|
||||
typename CostMap, typename DistanceMap,
|
||||
typename WeightMap, typename VertexIndexMap,
|
||||
typename ColorMap,
|
||||
typename <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">CompareFunction</a>, typename <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">CombineFunction</a>,
|
||||
typename CostInf, typename CostZero>
|
||||
inline void
|
||||
astar_search
|
||||
(VertexListGraph &g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
AStarHeuristic h, AStarVisitor vis,
|
||||
PredecessorMap predecessor, CostMap cost,
|
||||
DistanceMap distance, WeightMap weight,
|
||||
VertexIndexMap index_map, ColorMap color,
|
||||
CompareFunction compare, CombineFunction combine,
|
||||
CostInf inf, CostZero zero);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This algorithm implements a heuristic search on a weighted, directed
|
||||
or undirected graph for the case where all edge weights are
|
||||
non-negative.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The A* algorithm is a <i>heuristic graph search algorithm</i>: an A*
|
||||
search is "guided" by a <i>heuristic function</i>. A heuristic
|
||||
function <i>h(v)</i> is one which estimates the cost from a non-goal
|
||||
state (<i>v</i>) in the graph to some goal state, <i>g</i>.
|
||||
Intuitively, A* follows paths (through the graph) to the goal that are
|
||||
estimated by the heuristic function to be the best paths. Unlike
|
||||
best-first search, A* takes into account the known cost from the start
|
||||
of the search to <i>v</i>; the paths A* takes are guided by a function
|
||||
<i>f(v) = g(v) + h(v)</i>, where <i>h(v)</i> is the heuristic
|
||||
function, and <i>g(v)</i> (sometimes denoted <i>c(s, v)</i>) is the
|
||||
known cost from the start to <i>v</i>. Clearly, the efficiency of A*
|
||||
is highly dependent on the heuristic function with which it is used.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The A* algorithm is very similar to Dijkstra's Shortest Paths
|
||||
algorithm. This implementation finds all the shortest paths from the
|
||||
start vertex to every other vertex by creating a search tree,
|
||||
examining vertices according to their remaining cost to some goal, as
|
||||
estimated by a heuristic function. Most commonly, A* is used to find
|
||||
some specific goal vertex or vertices in a graph, after which the
|
||||
search is terminated.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
A* is particularly useful for searching <i>implicit</i> graphs.
|
||||
Implicit graphs are graphs that are not completely known at the
|
||||
beginning of the search. Upon visiting a vertex, its neighbors are
|
||||
"generated" and added to the search. Implicit graphs are particularly
|
||||
useful for searching large state spaces -- in gameplaying scenarios
|
||||
(e.g. chess), for example -- in which it may not be possible to store
|
||||
the entire graph. Implicit searches can be performed with this
|
||||
implementation of A* by creating special visitors that generate
|
||||
neighbors of newly-expanded vertices.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
This implementation of A* is based on an OPEN/CLOSED list formulation
|
||||
of the algorithm. Vertices on the OPEN list have been ``discovered''
|
||||
by the algorithm, but not ``expanded'' (we have not discovered their
|
||||
adjacent vertices). Vertices on the CLOSED list have been completely
|
||||
examined by our search (we have expanded them and added their children
|
||||
to the OPEN list). Vertices that are on neither list have not been
|
||||
encountered in any context so far in our search. A major advantage of
|
||||
this formulation of the A* algorithm over other approaches is that it
|
||||
avoids ``cycles'' in the state space; the search will not become
|
||||
trapped by loops in the graph. The OPEN/CLOSED lists are implemented
|
||||
using BGL's vertex coloring mechanisms. Vertices in OPEN are colored
|
||||
gray, vertices in CLOSED are colored black, and undiscovered vertices
|
||||
are colored white.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The criteria for expanding a vertex on the OPEN list is that it has
|
||||
the lowest <i>f(v) = g(v) + h(v)</i> value of all vertices on OPEN.
|
||||
Cost information about vertices is stored in a property map.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The following is the pseudocode for the A* heuristic search algorithm.
|
||||
In the pseudocode, <i>h</i> is the heuristic function, <i>w</i> is the
|
||||
edge weight, <i>d</i> is the distance of a vertex from <i>s</i>, and
|
||||
<i>Q</i> is a priority queue, sorted by <i>f</i>, the estimated cost
|
||||
to the goal of the path through a vertex. <i>p</i> is a predecessor
|
||||
map. The visitor event points for the algorithm are indicated by the
|
||||
labels on the right.
|
||||
</P>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
A*(<i>G</i>, <i>s</i>, <i>h</i>)
|
||||
<b>for</b> each vertex <i>u in V</i>
|
||||
<i>d[u] := f[u] := infinity</i>
|
||||
<i>color[u] :=</i> WHITE
|
||||
<i>p[u] := u</i>
|
||||
<b>end for</b>
|
||||
<i>color[s] :=</i> GRAY
|
||||
<i>d[s] := 0</i>
|
||||
<i>f[s] := h(s)</i>
|
||||
INSERT(<i>Q, s</i>)
|
||||
<b>while</b> (<i>Q != Ø</i>)
|
||||
<i>u :=</i> EXTRACT-MIN(<i>Q</i>)
|
||||
<b>for</b> each vertex <i>v in Adj[u]</i>
|
||||
<b>if</b> (<i>w(u,v) + d[u] < d[v]</i>)
|
||||
<i>d[v] := w(u,v) + d[u]</i>
|
||||
<i>f[v] := d[v] + h(v)</i>
|
||||
<i>p[v] := u</i>
|
||||
<b>if</b> (<i>color[v] =</i> WHITE)
|
||||
<i>color[v] :=</i> GRAY
|
||||
INSERT(<i>Q, v</i>)
|
||||
<b>else if</b> (<i>color[v] =</i> BLACK)
|
||||
<i>color[v] :=</i> GRAY
|
||||
INSERT(<i>Q, v</i>)
|
||||
<b>end if</b>
|
||||
<b>else</b>
|
||||
<i>...</i>
|
||||
<b>end for</b>
|
||||
<i>color[u] :=</i> BLACK
|
||||
<b>end while</b>
|
||||
</pre>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
|
||||
initialize vertex <i>u</i>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
discover vertex <i>s</i>
|
||||
|
||||
examine vertex <i>u</i>
|
||||
examine edge <i>(u,v)</i>
|
||||
|
||||
edge <i>(u,v)</i> relaxed
|
||||
|
||||
|
||||
|
||||
|
||||
discover vertex <i>v</i>
|
||||
|
||||
|
||||
reopen vertex <i>v</i>
|
||||
|
||||
|
||||
edge <i>(u,v)</i> not relaxed
|
||||
|
||||
finish vertex <i>u</i>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/astar_search.hpp"><tt>boost/graph/astar_search.hpp</tt></a>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>VertexListGraph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied. The type
|
||||
<tt>VertexListGraph</tt> must be a model of the <a
|
||||
href="VertexListGraph.html">
|
||||
Vertex List Graph</a> concept.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
<blockquote>
|
||||
The start vertex for the search. All distances will be calculated
|
||||
from this vertex, and the shortest paths tree (recorded in the
|
||||
predecessor map) will be rooted at this vertex.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>AStarHeuristic h</tt>
|
||||
<blockquote>
|
||||
The heuristic function that guides the search. The type
|
||||
<tt>AStarHeuristic</tt> must be a model of the <a href="AStarHeuristic.html">AStarHeuristic</a>
|
||||
concept.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>weight_map(WeightMap w_map)</tt>
|
||||
<blockquote>
|
||||
The weight or ``length'' of each edge in the graph. The weights
|
||||
must all be non-negative; the algorithm will throw a <a
|
||||
href="./exception.html#negative_edge"><tt>negative_edge</tt></a>
|
||||
exception if one of the edges is negative. The type
|
||||
<tt>WeightMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html"><tt>Readable
|
||||
Property Map</tt></a>. The edge descriptor type of the graph needs
|
||||
to be usable as the key type for the weight map. The value type
|
||||
for this map must be the same as the value type of the distance
|
||||
map.<br>
|
||||
<b>Default:</b> <tt>get(edge\_weight, g)</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This is necessary for efficient updates of
|
||||
the heap data structure when an edge is relaxed. The type
|
||||
<tt>VertexIndexMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html"><tt>Readable
|
||||
Property Map</tt></a>. The value type of the map must be an integer
|
||||
type. The vertex descriptor type of the graph needs to be usable as
|
||||
the key type of the map.<br>
|
||||
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt>
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>predecessor_map(PredecessorMap p_map)</tt>
|
||||
<blockquote>
|
||||
|
||||
The predecessor map records the edges in the minimum spanning tree.
|
||||
Upon completion of the algorithm, the edges <tt>(p[u],u)</tt> for
|
||||
all <tt>u</tt> in <tt>V</tt> are in the minimum spanning tree. If
|
||||
<tt>p[u] = u</tt> then <tt>u</tt> is either the start vertex or a
|
||||
vertex that is not reachable from the start. The
|
||||
<tt>PredecessorMap</tt> type must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html"><tt>Read/Write
|
||||
Property Map</tt></a> with key and vertex types the same as the
|
||||
vertex descriptor type of the graph.<br>
|
||||
|
||||
<b>Default:</b> <tt>dummy_property_map</tt>
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>distance_map(DistanceMap d_map)</tt>
|
||||
<blockquote>
|
||||
|
||||
The shortest path weight from the start vertex <tt>s</tt> to each
|
||||
vertex in the graph <tt>g</tt> is recorded in this property map.
|
||||
The shortest path weight is the sum of the edge weights along the
|
||||
shortest path. The type <tt>DistanceMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html"><tt>Read/Write
|
||||
Property Map</tt></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 is the element type of a <a
|
||||
href="./Monoid.html"><tt>Monoid</tt></a> formed with the
|
||||
<tt>combine</tt> function object and the zero object for the
|
||||
identity element. Also the distance value type must have a <a
|
||||
href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html"><tt>StrictWeakOrdering</tt></a>
|
||||
provided by the <tt>compare</tt> function object.<br>
|
||||
|
||||
<b>Default:</b> <tt>iterator_property_map</tt> created from a
|
||||
<tt>std::vector</tt> with the same value type as the
|
||||
<tt>WeightMap</tt>, and of size <tt>num_vertices(g)</tt>, and using
|
||||
the <tt>i_map</tt> for the index map.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>rank_map(CostMap c_map)</tt>
|
||||
<blockquote>
|
||||
|
||||
The <i>f</i>-value for each vertex. The <i>f</i>-value is defined
|
||||
as the sum of the cost to get to a vertex from the start vertex, and
|
||||
the estimated cost (as returned by the heuristic function
|
||||
<tt>h</tt>) from the vertex to a goal. The type <tt>CostMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html"><tt>Read/Write
|
||||
Property Map</tt></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 is the element type of a <a
|
||||
href="./Monoid.html"><tt>Monoid</tt></a> formed with the
|
||||
<tt>combine</tt> function object and the zero object for the
|
||||
identity element. Also the distance value type must have a <a
|
||||
href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html"><tt>StrictWeakOrdering</tt></a>
|
||||
provided by the <tt>compare</tt> function object. The value type
|
||||
for this map must be the same as the value type for the distance
|
||||
map.<br>
|
||||
|
||||
<b>Default:</b> <tt>iterator_property_map</tt> created from a
|
||||
<tt>std::vector</tt> with the same value type as the
|
||||
<tt>WeightMap</tt>, and of size <tt>num_vertices(g)</tt>, and using
|
||||
the <tt>i_map</tt> for the index map.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>color_map(ColorMap c_map)</tt>
|
||||
<blockquote>
|
||||
|
||||
This is used during the execution of the algorithm to mark the
|
||||
vertices, indicating whether they are on the OPEN or CLOSED lists.
|
||||
The vertices start out white and become gray when they are inserted
|
||||
into the OPEN list. They then turn black when they are examined and
|
||||
placed on the CLOSED list. At the end of the algorithm, vertices
|
||||
reachable from the source vertex will have been colored black. All
|
||||
other vertices will still be white. The type <tt>ColorMap</tt> must
|
||||
be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html"><tt>Read/Write
|
||||
Property Map</tt></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"><tt>Color Value</tt></a>.<br>
|
||||
|
||||
<b>Default:</b> <tt>iterator_property_map</tt> created from a
|
||||
<tt>std::vector</tt> of value type <tt>default_color_type</tt>, with
|
||||
size <tt>num_vertices(g)</tt>, and using the <tt>i_map</tt> for the
|
||||
index map.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_compare(CompareFunction cmp)</tt>
|
||||
<blockquote>
|
||||
|
||||
This function is use to compare distances to determine which vertex
|
||||
is closer to the start vertex, and to compare <i>f</i>-values to
|
||||
determine which vertex on the OPEN list to examine next. The
|
||||
<tt>CompareFunction</tt> type must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryPredicate.html"><tt>Binary
|
||||
Predicate</tt></a> and have argument types that match the value type
|
||||
of the <tt>DistanceMap</tt> property map.<br>
|
||||
|
||||
<b>Default:</b> <tt>std::less<D></tt> with <tt>D = typename
|
||||
property_traits<DistanceMap>::value_type</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_combine(CombineFunction cmb)</tt>
|
||||
<blockquote>
|
||||
|
||||
This function is used to combine distances to compute the distance
|
||||
of a path, and to combine distance and heuristic values to compute
|
||||
the <i>f</i>-value of a vertex. The <tt>CombineFunction</tt> type
|
||||
must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryFunction.html"><tt>Binary
|
||||
Function</tt></a>. Both argument types of the binary function must
|
||||
match the value type of the <tt>DistanceMap</tt> property map (which
|
||||
is the same as that of the <tt>WeightMap</tt> and <tt>CostMap</tt>
|
||||
property maps). The result type must be the same type as the
|
||||
distance value type.<br>
|
||||
|
||||
<b>Default:</b> <tt>std::plus<D></tt> with <tt>D = typename
|
||||
property_traits<DistanceMap>::value_type</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_inf(D inf)</tt>
|
||||
<blockquote>
|
||||
|
||||
The <tt>inf</tt> object must be the greatest value of any <tt>D</tt>
|
||||
object. That is, <tt>compare(d, inf) == true</tt> for any <tt>d !=
|
||||
inf</tt>. The type <tt>D</tt> is the value type of the
|
||||
<tt>DistanceMap</tt>.<br>
|
||||
|
||||
<b>Default:</b> <tt>std::numeric_limits<D>::max()</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_zero(D zero)</tt>
|
||||
<blockquote>
|
||||
|
||||
The <tt>zero</tt> value must be the identity element for the <a
|
||||
href="./Monoid.html"><tt>Monoid</tt></a> formed by the distance
|
||||
values and the <tt>combine</tt> function object. The type
|
||||
<tt>D</tt> is the value type of the <tt>DistanceMap</tt>.<br>
|
||||
|
||||
<b>Default</b>: <tt>D()</tt> with <tt>D = typename
|
||||
property_traits<DistanceMap>::value_type</tt>.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>visitor(AStarVisitor v)</tt>
|
||||
<blockquote>
|
||||
|
||||
Use this to specify actions that you would like to happen during
|
||||
certain event points within the algorithm. The type
|
||||
<tt>AStarVisitor</tt> must be a model of the <a
|
||||
href="AStarVisitor.html"><tt>AStarVisitor</tt></a> concept. The
|
||||
visitor object is passed by value <a href="#1">[1]</a>.<br>
|
||||
|
||||
<b>Default:</b> <tt>astar_visitor<null_visitor></tt>
|
||||
</blockquote>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O((E + V) log V)</i>.
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>vis.initialize_vertex(u, g)</tt></b>
|
||||
is invoked on each vertex in the graph before the start of the
|
||||
algorithm.
|
||||
<li><b><tt>vis.discover_vertex(v, g)</tt></b>
|
||||
is invoked when a vertex is first discovered and is added to the
|
||||
OPEN list.
|
||||
<li><b><tt>vis.examine_vertex(u, g)</tt></b>
|
||||
is invoked when a vertex is popped from
|
||||
the queue (i.e., it has the lowest cost on the OPEN list).
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b>
|
||||
is invoked on each out-edge of a vertex immediately after it is
|
||||
examined.
|
||||
<li><b><tt>vis.edge_relaxed(e, g)</tt></b>
|
||||
is invoked on edge <i>(u,v)</i> if <i>d[u] + w(u,v) < d[v]</i>.
|
||||
<li><b><tt>vis.edge_not_relaxed(e, g)</tt></b>
|
||||
is invoked if the edge is not relaxed (see above).
|
||||
<li><b><tt>vis.black_target(u, g)</tt></b>
|
||||
is invoked when a vertex that is on the CLOSED list is
|
||||
"rediscovered" via a more efficient path, and is re-added to the
|
||||
OPEN list.
|
||||
<li><b><tt>vis.finish_vertex(u, g)</tt></b>
|
||||
is invoked on a vertex when it is added to the CLOSED list, which
|
||||
happens after all of its out edges have been examined.
|
||||
</ul>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
See <a href="../example/astar-cities.cpp">
|
||||
<TT>example/astar-cities.cpp</TT></a> for an example of
|
||||
using A* search.
|
||||
|
||||
<H3>Notes</H3>
|
||||
|
||||
<a name="1">[1]</a> Since the visitor parameter is passed by value, if
|
||||
your visitor contains state then any changes to the state during the
|
||||
algorithm will be made to a copy of the visitor object, not the
|
||||
visitor object passed in. Therefore you may want the visitor to hold
|
||||
this state by pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<A HREF="http://www.cs.rpi.edu/~beevek/">Kristopher Beevers</A>,
|
||||
Rensselaer Polytechnic Institute (<A
|
||||
HREF="mailto:beevek@cs.rpi.edu">beevek@cs.rpi.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,112 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) 2004 Kris Beevers
|
||||
--
|
||||
-- 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: astar_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
astar_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="./AStarVisitor.html">AStarVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
See the example for <a href="./EventVisitor.html">EventVisitor</a>.
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./AStarVisitor.html">AStarVisitor</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/astar_search.hpp">
|
||||
<TT>boost/graph/astar_search.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./AStarVisitor.html">AStarVisitor</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>
|
||||
astar_visitor<EventVisitorList><br>
|
||||
make_astar_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be an A* 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 © 2004</TD><TD>
|
||||
<A HREF="http://www.cs.rpi.edu/~beevek/">Kristopher Beevers</A>,
|
||||
Rensselaer Polytechnic Institute (<A
|
||||
HREF="mailto:beevek@cs.rpi.edu">beevek@cs.rpi.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,6 +0,0 @@
|
||||
\DeclareOption{awpaper}
|
||||
{\setlength\paperheight {9.25in}%
|
||||
\setlength\paperwidth {7.375in}}
|
||||
\DeclareOption*{\PassOptonsToPackage{\CurrentOption}{newsiambook}}
|
||||
\ProcessOptions
|
||||
\ExecuteOptions{awpaper}
|
||||
@@ -1,97 +0,0 @@
|
||||
<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: Bandwidth</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:bandwidth">
|
||||
<TT>bandwidth</TT>
|
||||
</H1>
|
||||
|
||||
<pre>
|
||||
(1)
|
||||
template <typename Graph>
|
||||
typename graph_traits<Graph>::vertices_size_type
|
||||
bandwidth(const Graph& g)
|
||||
|
||||
(2)
|
||||
template <typename Graph, typename VertexIndexMap>
|
||||
typename graph_traits<Graph>::vertices_size_type
|
||||
bandwidth(const Graph& g, VertexIndexMap index_map)
|
||||
</pre>
|
||||
|
||||
The <b><i>bandwidth</i></b> of an undirected graph is the maximum
|
||||
distance between two adjacent vertices, with distance measured on a
|
||||
line upon which the vertices have been placed at unit intervals. To
|
||||
put it another way, if the vertices of an undirected graph
|
||||
<i>G=(V,E)</i> are each assigned an index from zero to <i>|V| - 1</i>
|
||||
given by <i>index[v]</i>, then the bandwidth of <i>G</i> is<br>
|
||||
<br>
|
||||
<i>B(G) = max { |index[u] - index[v]| | (u,v) in E }</i><br>
|
||||
|
||||
|
||||
<h3>Defined in</h3>
|
||||
|
||||
<a href="../../../boost/graph/bandwidth.hpp"><tt>boost/graph/bandwidth.hpp</tt></a>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<H1><A NAME="sec:ith-bandwidth">
|
||||
<TT>ith_bandwidth</TT>
|
||||
</H1>
|
||||
|
||||
<pre>
|
||||
(1)
|
||||
template <typename Graph>
|
||||
typename graph_traits<Graph>::vertices_size_type
|
||||
ith_bandwidth(typename graph_traits<Graph>::vertex_descriptor i,
|
||||
const Graph& g)
|
||||
|
||||
(2)
|
||||
template <typename Graph, typename VertexIndexMap>
|
||||
typename graph_traits<Graph>::vertices_size_type
|
||||
ith_bandwidth(typename graph_traits<Graph>::vertex_descriptor i,
|
||||
const Graph& g,
|
||||
VertexIndexMap index)
|
||||
</pre>
|
||||
|
||||
The <b><i>i-th bandwidth</i></b> a graph is the maximum distance
|
||||
between the <i>i-th</i> vertex and any of its neighbors.<br>
|
||||
<br>
|
||||
<i>B<sub>i</sub>(G) = max { |index[i] - index[j]| | (i,j) in E }</i><br>
|
||||
<br>
|
||||
So the bandwidth <i>B(G)</i> can be expressed as the maximum
|
||||
of the i-th bandwidths <i>B<sub>i</sub>(G)</i>.<br>
|
||||
<br>
|
||||
<i>B(G) = max { B<sub>i</sub>(G) | i=0...|V|-1 }</i><br>
|
||||
|
||||
<h3>Defined in</h3>
|
||||
|
||||
<a href="../../../boost/graph/bandwidth.hpp"><tt>boost/graph/bandwidth.hpp</tt></a>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,140 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content=
|
||||
"HTML Tidy for Mac OS X (vers 12 April 2005), see www.w3.org">
|
||||
<meta http-equiv="Content-Type" content=
|
||||
"text/html; charset=us-ascii">
|
||||
<title>Function betweenness_centrality_clustering</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="titlepage"></div>
|
||||
<div class="refnamediv">
|
||||
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<h1><img src="figs/python.gif" alt="(Python)"/><span class="refentrytitle">Function
|
||||
betweenness_centrality_clustering</span></h1>
|
||||
<p>boost::betweenness_centrality_clustering — Graph
|
||||
clustering based on edge betweenness centrality.</p>
|
||||
</div>
|
||||
<h2 xmlns:rev=
|
||||
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class=
|
||||
"refsynopsisdiv-title">Synopsis</h2>
|
||||
<div xmlns:rev=
|
||||
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class=
|
||||
"refsynopsisdiv">
|
||||
<pre class="synopsis">
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> MutableGraph, <span class=
|
||||
"bold"><b>typename</b></span> Done, <span class=
|
||||
"bold"><b>typename</b></span> EdgeCentralityMap,
|
||||
<span class=
|
||||
"bold"><b>typename</b></span> VertexIndexMap>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>void</b></span></span> betweenness_centrality_clustering(MutableGraph & g, Done done,
|
||||
EdgeCentralityMap edge_centrality,
|
||||
VertexIndexMap vertex_index);
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> MutableGraph, <span class=
|
||||
"bold"><b>typename</b></span> Done, <span class=
|
||||
"bold"><b>typename</b></span> EdgeCentralityMap>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>void</b></span></span> betweenness_centrality_clustering(MutableGraph & g, Done done,
|
||||
EdgeCentralityMap edge_centrality);
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> MutableGraph, <span class=
|
||||
"bold"><b>typename</b></span> Done>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>void</b></span></span> betweenness_centrality_clustering(MutableGraph & g, Done done);
|
||||
</pre></div>
|
||||
<div class="refsect1" lang="en"><a name="id822306" id=
|
||||
"id822306"></a>
|
||||
<h2>Description</h2>
|
||||
<p>This algorithm implements graph clustering based on edge
|
||||
betweenness centrality. It is an iterative algorithm, where in each
|
||||
step it compute the edge betweenness centrality (via <a href=
|
||||
"betweenness_centrality.html">brandes_betweenness_centrality</a>) and
|
||||
removes the edge with the maximum betweenness centrality. The
|
||||
<tt class="computeroutput">done</tt> function object determines
|
||||
when the algorithm terminates (the edge found when the algorithm
|
||||
terminates will not be removed).</p>
|
||||
|
||||
<h2>Parameters</h2>
|
||||
IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied. The type
|
||||
<tt>Graph</tt> must be a model of <a
|
||||
href="VertexListGraph.html">Vertex List Graph</a> and <a
|
||||
href="IncidenceGraph.html">Incidence Graph</a>. When an edge
|
||||
centrality map is supplied, it must also model <a
|
||||
href="EdgeListGraph.html">Edge List Graph</a> and <a
|
||||
href="MutableGraph.html">MutableGraph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Done done</tt>
|
||||
<blockquote>
|
||||
The function object that indicates termination of the algorithm.
|
||||
It must be a ternary function object thats accepts the maximum
|
||||
centrality, the descriptor of the edge that will be removed, and
|
||||
the graph <tt class="computeroutput">g</tt>.<br>
|
||||
<b>Python</b>: Any callable Python object will suffice.
|
||||
</blockquote>
|
||||
|
||||
OUT/UTIL: <tt>EdgeCentralityMap edge_centrality_map</tt>
|
||||
<blockquote>
|
||||
This property map is used to accumulate the betweenness centrality
|
||||
of each edge, and is a secondary form of output for the
|
||||
algorithm. The type <tt>EdgeCentralityMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>, with the graph's edge descriptor type as its key
|
||||
type. The value type of this property map should be the same as the
|
||||
value type of the <tt>CentralityMap</tt> property map.<br>
|
||||
|
||||
<b>Default:</b> a <tt>dummy_property_map</tt>, which requires no
|
||||
work to compute and returns no answer.<br>
|
||||
<b>Python</b>: The color map must be a <tt>edge_double_map</tt> for
|
||||
the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_edge_double_map("centrality")</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>VertexIndexMap vertex_index</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This is necessary for efficient updates of the
|
||||
heap data structure when an edge is relaxed. The type
|
||||
<tt>VertexIndexMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The value type of the map must be an
|
||||
integer type. The vertex descriptor type of the graph needs to be
|
||||
usable as the key type of the map.<br>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
<table xmlns:rev=
|
||||
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
|
||||
"100%">
|
||||
<tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Where Defined</h3>
|
||||
<<a href=
|
||||
"../../../boost/graph/bc_clustering.hpp">boost/graph/bc_clustering.hpp</a>>
|
||||
<hr>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td nowrap>Copyright © 2004</td>
|
||||
<td><a href="../../../people/doug_gregor.html">Douglas Gregor</a>,
|
||||
Indiana University (dgregor@cs.indiana.edu)<br>
|
||||
<a href="http://www.osl.iu.edu/~lums">Andrew Lumsdaine</a>, Indiana
|
||||
University (<a href=
|
||||
"mailto:lums@osl.iu.edu">lums@osl.iu.edu</a>)</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,353 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1><A NAME="sec:bellman-ford"></A><img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>bellman_ford_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named paramter version</i>
|
||||
template <class <a href="./EdgeListGraph.html">EdgeListGraph</a>, class Size, class P, class T, class R>
|
||||
bool bellman_ford_shortest_paths(const EdgeListGraph& g, Size N,
|
||||
const bgl_named_params<P, T, R>& params = <i>all defaults</i>);
|
||||
|
||||
template <class <a href="./VertexAndEdgeListGraph.html">VertexAndEdgeListGraph</a>, class P, class T, class R>
|
||||
bool bellman_ford_shortest_paths(const VertexAndEdgeListGraph& g,
|
||||
const bgl_named_params<P, T, R>& params = <i>all defaults</i>);
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <class <a href="./EdgeListGraph.html">EdgeListGraph</a>, class Size, class WeightMap,
|
||||
class PredecessorMap, class DistanceMap,
|
||||
class <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">BinaryFunction</a>, class <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">BinaryPredicate</a>,
|
||||
class <a href="./BellmanFordVisitor.html">BellmanFordVisitor</a>>
|
||||
bool bellman_ford_shortest_paths(EdgeListGraph& g, Size N,
|
||||
WeightMap weight, PredecessorMap pred, DistanceMap distance,
|
||||
BinaryFunction combine, BinaryPredicate compare, BellmanFordVisitor v)
|
||||
</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. For the definition of the shortest paths problem see
|
||||
Section <A
|
||||
HREF="./graph_theory_review.html#sec:shortest-paths-algorithms">Shortest-Paths
|
||||
Algorithms</A>.
|
||||
If you only need to solve the shortest paths problem for positive edge
|
||||
weights, Dijkstra's algorithm provides a more efficient
|
||||
alternative. If all the edge weights are all equal to one then breadth-first
|
||||
search provides an even more efficient alternative.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Before calling the <tt>bellman_ford_shortest_paths()</tt> function,
|
||||
the user must assign the source vertex a distance of zero and all
|
||||
other vertices a distance of infinity <i>unless</i> you are providing
|
||||
a starting vertex. The Bellman-Ford algorithm
|
||||
proceeds by looping through all of the edges in the graph, applying
|
||||
the relaxation operation to each edge. In the following pseudo-code,
|
||||
<i>v</i> is a vertex adjacent to <i>u</i>, <i>w</i> maps edges to
|
||||
their weight, and <i>d</i> is a distance map that records the length
|
||||
of the shortest path to each vertex seen so far. <i>p</i> is a
|
||||
predecessor map which records the parent of each vertex, which will
|
||||
ultimately be the parent in the shortest paths tree
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
RELAX(<i>u</i>, <i>v</i>, <i>w</i>, <i>d</i>, <i>p</i>)
|
||||
<b>if</b> (<i>w(u,v) + d[u] < d[v]</i>)
|
||||
<i>d[v] := w(u,v) + d[u]</i>
|
||||
<i>p[v] := u</i>
|
||||
<b>else</b>
|
||||
...
|
||||
</pre>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
|
||||
|
||||
relax edge <i>(u,v)</i>
|
||||
|
||||
|
||||
edge <i>(u,v)</i> is not relaxed
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The algorithm repeats this loop <i>|V|</i> times after which it is
|
||||
guaranteed that the distances to each vertex have been reduced to the
|
||||
minimum possible unless there is a negative cycle in the graph. If
|
||||
there is a negative cycle, then there will be edges in the graph that
|
||||
were not properly minimized. That is, there will be edges <i>(u,v)</i> such
|
||||
that <i>w(u,v) + d[u] < d[v]</i>. The algorithm loops over the edges in
|
||||
the graph one final time to check if all the edges were minimized,
|
||||
returning <tt>true</tt> if they were and returning <tt>false</tt>
|
||||
otherwise.
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
BELLMAN-FORD(<i>G</i>)
|
||||
<i>// Optional initialization</i>
|
||||
<b>for</b> each vertex <i>u in V</i>
|
||||
<i>d[u] := infinity</i>
|
||||
<i>p[u] := u</i>
|
||||
<b>end for</b>
|
||||
<b>for</b> <i>i := 1</i> <b>to</b> <i>|V|-1</i>
|
||||
<b>for</b> each edge <i>(u,v) in E</i>
|
||||
RELAX(<i>u</i>, <i>v</i>, <i>w</i>, <i>d</i>, <i>p</i>)
|
||||
<b>end for</b>
|
||||
<b>end for</b>
|
||||
<b>for</b> each edge <i>(u,v) in E</i>
|
||||
<b>if</b> (<i>w(u,v) + d[u] < d[v]</i>)
|
||||
<b>return</b> (false, , )
|
||||
<b>else</b>
|
||||
...
|
||||
<b>end for</b>
|
||||
<b>return</b> (true, <i>p</i>, <i>d</i>)
|
||||
</pre>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
examine edge <i>(u,v)</i>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
edge <i>(u,v)</i> was not minimized
|
||||
|
||||
edge <i>(u,v)</i> was minimized
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
There are two main options for obtaining output from the
|
||||
<tt>bellman_ford_shortest_paths()</tt> function. If the user provides
|
||||
a distance property map through the <tt>distance_map()</tt> parameter
|
||||
then the shortest distance from the source vertex to every other
|
||||
vertex in the graph will be recorded in the distance map (provided the
|
||||
function returns <tt>true</tt>). The second option is recording the
|
||||
shortest paths tree in the <tt>predecessor_map()</tt>. For each vertex
|
||||
<i>u in V</i>, <i>p[u]</i> will be the predecessor of <i>u</i> in the
|
||||
shortest paths tree (unless <i>p[u] = u</i>, in which case <i>u</i> is
|
||||
either the source vertex or a vertex unreachable from the source). In
|
||||
addition to these two options, the user can provide her own
|
||||
custom-made visitor that can take actions at any of the
|
||||
algorithm's event points.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
|
||||
IN: <tt>EdgeListGraph& g</tt>
|
||||
<blockquote>
|
||||
A directed or undirected graph whose type must be a model of
|
||||
<a href="./EdgeListGraph.html">Edge List Graph</a>. If a root vertex is
|
||||
provided, then the graph must also model
|
||||
<a href="./VertexListGraph.html">Vertex List Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Size N</tt>
|
||||
<blockquote>
|
||||
The number of vertices in the graph. The type <tt>Size</tt> must
|
||||
be an integer type.<br>
|
||||
<b>Default:</b> <tt>num_vertices(g)</tt>.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>weight_map(WeightMap w)</tt>
|
||||
<blockquote>
|
||||
The weight (also know as ``length'' or ``cost'') of each edge in the
|
||||
graph. The <tt>WeightMap</tt> type must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>. The key type for this property map must be the edge
|
||||
descriptor of the graph. The value type for the weight map must be
|
||||
<i>Addable</i> with the distance map's value type. <br>
|
||||
<b>Default:</b> <tt>get(edge_weight, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Must be an <tt>edge_double_map</tt> for the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_edge_double_map("weight")</tt>
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>predecessor_map(PredecessorMap p_map)</tt>
|
||||
<blockquote>
|
||||
The predecessor map records the edges in the minimum spanning
|
||||
tree. Upon completion of the algorithm, the edges <i>(p[u],u)</i>
|
||||
for all <i>u in V</i> are in the minimum spanning tree. If <i>p[u] =
|
||||
u</i> then <i>u</i> is either the source vertex or a vertex that is
|
||||
not reachable from the source. The <tt>PredecessorMap</tt> type
|
||||
must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> which key and vertex types the same as the vertex
|
||||
descriptor type of the graph.<br>
|
||||
<b>Default:</b> <tt>dummy_property_map</tt><br>
|
||||
|
||||
<b>Python</b>: Must be a <tt>vertex_vertex_map</tt> for the graph.<br>
|
||||
</blockquote>
|
||||
|
||||
IN/OUT: <tt>distance_map(DistanceMap d)</tt>
|
||||
<blockquote>
|
||||
The shortest path weight from the source vertex to each vertex in
|
||||
the graph <tt>g</tt> is recorded in this property map. The type
|
||||
<tt>DistanceMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>. The key type of the property map must be the
|
||||
vertex descriptor type of the graph, and the value type of the
|
||||
distance map must be <a
|
||||
href="http://www.sgi.com/tech/stl/LessThanComparable.html"> Less
|
||||
Than Comparable</a>.<br> <b>Default:</b> <tt>get(vertex_distance,
|
||||
g)</tt><br>
|
||||
<b>Python</b>: Must be a <tt>vertex_double_map</tt> for the graph.<br>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>root_vertex(Vertex s)</tt>
|
||||
<blockquote>
|
||||
The starting (or "root") vertex from which shortest paths will be
|
||||
computed. When provided, the distance map need not be initialized
|
||||
(the algorithm will perform the initialization itself). However, the
|
||||
graph must model <a href="./VertexListGraph.html">Vertex List
|
||||
Graph</a> when this parameter is provided.<br>
|
||||
<b>Default:</b> None; if omitted, the user must initialize the
|
||||
distance map.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>visitor(BellmanFordVisitor v)</tt>
|
||||
<blockquote>
|
||||
The visitor object, whose type must be a model of
|
||||
<a href="./BellmanFordVisitor.html">Bellman-Ford Visitor</a>.
|
||||
The visitor object is passed by value <a
|
||||
href="#1">[1]</a>.
|
||||
<br>
|
||||
<b>Default:</b> <tt>bellman_visitor<null_visitor></tt><br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a
|
||||
href="BellmanFordVisitor.html#python"><tt>BellmanFordVisitor</tt></a> type
|
||||
of the graph.
|
||||
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_combine(BinaryFunction combine)</tt>
|
||||
<blockquote>
|
||||
This function object replaces the role of addition in the relaxation
|
||||
step. The first argument type must match the distance map's value
|
||||
type and the second argument type must match the weight map's value
|
||||
type. The result type must be the same as the distance map's value
|
||||
type.<br>
|
||||
<b>Default:</b><tt>std::plus<D></tt>
|
||||
with <tt>D=typename property_traits<DistanceMap>::value_type</tt>.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_compare(BinaryPredicate compare)</tt>
|
||||
<blockquote>
|
||||
This function object replaces the role of the less-than operator
|
||||
that compares distances in the relaxation step. The argument types
|
||||
must match the distance map's value type.<br>
|
||||
<b>Default:</b> <tt>std::less<D></tt>
|
||||
with <tt>D=typename property_traits<DistanceMap>::value_type</tt>.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(V E)</i>.
|
||||
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b> is invoked on every edge in
|
||||
the graph <i>|V|</i> times.
|
||||
<li><b><tt>vis.edge_relaxed(e, g)</tt></b> is invoked when the distance
|
||||
label for the target vertex is decreased. The edge <i>(u,v)</i> that
|
||||
participated in the last relaxation for vertex <i>v</i> is an edge in the
|
||||
shortest paths tree.
|
||||
<li><b><tt>vis.edge_not_relaxed(e, g)</tt></b> is invoked if the distance label
|
||||
for the target vertex is not decreased.
|
||||
<li><b><tt>vis.edge_minimized(e, g)</tt></b> is invoked during the
|
||||
second stage of the algorithm, during the test of whether each edge
|
||||
was minimized. If the edge is minimized then this function
|
||||
is invoked.
|
||||
<li><b><tt>vis.edge_not_minimized(e, g)</tt></b> is also invoked during the
|
||||
second stage of the algorithm, during the test of whether each edge
|
||||
was minimized. If the edge was not minimized, this function is
|
||||
invoked. This happens when there is a negative cycle in the graph.
|
||||
</ul>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
An example of using the Bellman-Ford algorithm is in <a
|
||||
href="../example/bellman-example.cpp"><TT>examples/bellman-example.cpp</TT></a>.
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p><a name="1">[1]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,115 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,296 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost Graph Library: Brandes' Betweenness Centrality</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
<h1><img src="figs/python.gif" alt="(Python)"/><tt>brandes_betweenness_centrality</tt></h1>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
<em>// named parameter versions</em>
|
||||
template<typename Graph, typename Param, typename Tag, typename Rest>
|
||||
void
|
||||
brandes_betweenness_centrality(const Graph& g,
|
||||
const bgl_named_params<Param,Tag,Rest>& params);
|
||||
|
||||
template<typename Graph, typename CentralityMap>
|
||||
void
|
||||
brandes_betweenness_centrality(const Graph& g, CentralityMap centrality_map);
|
||||
|
||||
template<typename Graph, typename CentralityMap, typename EdgeCentralityMap>
|
||||
void
|
||||
brandes_betweenness_centrality(const Graph& g, CentralityMap centrality_map,
|
||||
EdgeCentralityMap edge_centrality);
|
||||
|
||||
<em>// non-named parameter versions</em>
|
||||
template<typename Graph, typename CentralityMap, typename EdgeCentralityMap,
|
||||
typename IncomingMap, typename DistanceMap, typename DependencyMap,
|
||||
typename PathCountMap, typename VertexIndexMap>
|
||||
void
|
||||
brandes_betweenness_centrality(const Graph& g, CentralityMap centrality_map,
|
||||
EdgeCentralityMap edge_centrality,
|
||||
IncomingMap incoming,
|
||||
DistanceMap distance, DependencyMap dependency,
|
||||
PathCountMap path_count,
|
||||
VertexIndexMap vertex_index);
|
||||
|
||||
template<typename Graph, typename CentralityMap, typename EdgeCentralityMap,
|
||||
typename IncomingMap, typename DistanceMap, typename DependencyMap,
|
||||
typename PathCountMap, typename VertexIndexMap, typename WeightMap>
|
||||
void
|
||||
brandes_betweenness_centrality(const Graph& g, CentralityMap centrality_map,
|
||||
EdgeCentralityMap edge_centrality,
|
||||
IncomingMap incoming,
|
||||
DistanceMap distance, DependencyMap dependency,
|
||||
PathCountMap path_count,
|
||||
VertexIndexMap vertex_index,
|
||||
WeightMap weight_map);
|
||||
|
||||
<em>// helper functions</em>
|
||||
template<typename Graph, typename CentralityMap>
|
||||
void
|
||||
relative_betweenness_centrality(const Graph& g, CentralityMap centrality_map);
|
||||
|
||||
template<typename Graph, typename CentralityMap>
|
||||
typename property_traits<CentralityMap>::value_type
|
||||
central_point_dominance(const Graph& g, CentralityMap centrality_map);
|
||||
</pre>
|
||||
|
||||
<p>This algorithm [<a href="bibliography.html#brandes01">54</a>]
|
||||
computes the <em>betweenness centrality</em> [<a
|
||||
href="bibliography.html#freeman77">55</a>,<a
|
||||
href="bibliography.html#anthonisse71">56</a>] of each vertex or each
|
||||
edge in the graph. The betweenness centrality of a vertex <em>v</em>
|
||||
is defined by
|
||||
|
||||
<p><img src="figs/betweenness_centrality.gif">,
|
||||
|
||||
<p>where <img src="figs/sigma_st.gif"> is the number of shortest paths from
|
||||
vertex <em>s</em> to vertex <em>t</em> and <img src="figs/sigma_stv.gif">
|
||||
is the number of shortest paths from vertex <em>s</em> to vertex
|
||||
<em>t</em> that pass through vertex <em>v</em>.
|
||||
|
||||
<!-- \sum_{s \neq v \neq t}\frac{\sigma_{st}(v)}{\sigma_{st}} -->
|
||||
|
||||
<p>The edge betweenness centrality indicates for each edge the
|
||||
betweenness centrality that was contributed to the target(s) of the
|
||||
edge (plural for undirected graphs). Similar to (vertex) betweenness
|
||||
centrality, edge betweenness centrality can be used to determine the
|
||||
edges through which most shortest paths must pass. A single invocation
|
||||
of this algorithm can compute either the vertex or edge centrality (or
|
||||
both).</p>
|
||||
|
||||
<p>This algorithm can operate either on weighted graphs (if a suitable
|
||||
edge weight map is supplied) or unweighted graphs (if no edge weight
|
||||
map is supplied). The result is the absolute betweenness centrality;
|
||||
to convert to the relative betweenness centrality, which scales each
|
||||
absolute centrality by <img src="figs/rel_betweenness_centrality.gif">
|
||||
(where <em>n</em> is the number of vertices in the graph), use
|
||||
<tt>relative_betweenness_centrality</tt>. Given the relative
|
||||
betweenness centrality, one can compute the <em>central point
|
||||
dominance</em> [<a href="bibliography.html#freeman77">55</a>], which is a measure of the maximum "betweenness" of any
|
||||
point in the graph: it will be 0 for complete graphs and
|
||||
1 for "wheel" graphs (in which there is a central vertex that all
|
||||
paths include; see <a href="#Fig1">Fig. 1</a>). Let <img src="figs/v_star.gif"> be the vertex with the largest relative betweenness centrality; then, the central point dominance is defined as:
|
||||
|
||||
<p><img src="figs/central_point_dominance.gif">
|
||||
|
||||
<!-- C_B' = \frac{\sum_{v \in V} C_B(v^*) - C_B'(v)}{n-1} -->
|
||||
|
||||
<p><a name="Fig1">
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fig. 1: A wheel graph, where every path travels through the central node. <br>The central point dominance of this graph is 1.</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><img src="figs/wheel_graph.gif"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
<a href="../../../boost/graph/betweenness_centrality.hpp"><tt>boost/graph/betweenness_centrality.hpp</tt></a>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied. The type
|
||||
<tt>Graph</tt> must be a model of <a
|
||||
href="VertexListGraph.html">Vertex List Graph</a> and <a
|
||||
href="IncidenceGraph.html">Incidence Graph</a>. When an edge
|
||||
centrality map is supplied, it must also model <a
|
||||
href="EdgeListGraph.html">Edge List Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>IncomingMap incoming</tt>
|
||||
<blockquote>
|
||||
This property map records the set of edges incoming to each vertex that comprise a shortest path from a particular source vertex through this vertex, and is used internally by the algorithm.The <tt>IncomingMap</tt> type must be a <a
|
||||
href="../../property_map/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</a> whose key type is the same as the vertex descriptor type of
|
||||
the graph and whose value type is a Sequence (e.g., an
|
||||
<tt>std::vector</tt>) containing edge descriptors.<br>
|
||||
|
||||
<b>Default:</b> <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>std::vector<Edge></tt>, where
|
||||
<tt>Edge</tt> is the edge descriptor type of the graph.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>DistanceMap distance_map</tt>
|
||||
<blockquote>
|
||||
The shortest path weight from each source vertex <tt>s</tt> to each
|
||||
vertex in the graph <tt>g</tt> is recorded in this property map, but
|
||||
the result is only used internally. The type <tt>DistanceMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</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 is the element type of a <a
|
||||
href="./Monoid.html">Monoid</a>.<br>
|
||||
|
||||
<b>Default:</b> <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of the <tt>WeightMap</tt>'s value type (or the
|
||||
<tt>vertices_size_type</tt> of the graph when no weight map exists)
|
||||
of size <tt>num_vertices(g)</tt> and using the <tt>vertex_index</tt> for
|
||||
the index map.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>DependencyMap dependency</tt>
|
||||
<blockquote>
|
||||
Property map used internally to accumulate partial betweenness
|
||||
centrality results. The type <tt>DependencyMap</tt> must be a model
|
||||
of <a href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>. The vertex descriptor type of the graph needs to
|
||||
be usable as the key type of the dependency map. The value type of
|
||||
the dependency map must be compatible with the value type of the
|
||||
centrality map.<br>
|
||||
|
||||
<b>Default:</b> <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of the <tt>CentralityMap</tt>'s value type of
|
||||
size <tt>num_vertices(g)</tt> and using the <tt>vertex_index</tt>
|
||||
for the index map.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>PathCountMap path_count</tt>
|
||||
<blockquote>
|
||||
Property map used internally to accumulate the number of paths that
|
||||
pass through each particular vertex. The type <tt>PathCountMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>. The vertex descriptor type of the graph needs to
|
||||
be usable as the key type of the dependency map. The value type of
|
||||
the dependency map must be an integral type large enough to store
|
||||
the number of paths in the graph.<br>
|
||||
|
||||
<b>Default:</b> <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of the <tt>degree_size_type</tt> of the graph of
|
||||
size <tt>num_vertices(g)</tt> and using the <tt>vertex_index</tt>
|
||||
for the index map.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named parameters</h3>
|
||||
OUT/UTIL: <tt>CentralityMap centrality_map</tt>
|
||||
<blockquote>
|
||||
This property map is used to accumulate the betweenness centrality
|
||||
of each vertex, and is the primary output of the algorithm. The type
|
||||
<tt>CentralityMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>, with the graph's vertex descriptor type as its key
|
||||
type. The value type of this property map should be a floating-point
|
||||
or rational type.<br>
|
||||
|
||||
<b>Default:</b> a <tt>dummy_property_map</tt>, which requires no
|
||||
work to compute and returns no answer.<br>
|
||||
<b>Python</b>: The color map must be a <tt>vertex_double_map</tt> for
|
||||
the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_vertex_double_map("centrality")</tt>
|
||||
</blockquote>
|
||||
|
||||
OUT/UTIL: <tt>EdgeCentralityMap edge_centrality_map</tt>
|
||||
<blockquote>
|
||||
This property map is used to accumulate the betweenness centrality
|
||||
of each edge, and is a secondary form of output for the
|
||||
algorithm. The type <tt>EdgeCentralityMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>, with the graph's edge descriptor type as its key
|
||||
type. The value type of this property map should be the same as the
|
||||
value type of the <tt>CentralityMap</tt> property map.<br>
|
||||
|
||||
<b>Default:</b> a <tt>dummy_property_map</tt>, which requires no
|
||||
work to compute and returns no answer.<br>
|
||||
<b>Python</b>: The color map must be a <tt>edge_double_map</tt> for
|
||||
the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_edge_double_map("centrality")</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap vertex_index)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This is necessary for efficient updates of the
|
||||
heap data structure when an edge is relaxed. The type
|
||||
<tt>VertexIndexMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The value type of the map must be an
|
||||
integer type. The vertex descriptor type of the graph needs to be
|
||||
usable as the key type of the map.<br>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>weight_map(WeightMap w_map)</tt>
|
||||
<blockquote>
|
||||
The weight or ``length'' of each edge in the graph. The weights
|
||||
must all be non-negative, and the algorithm will throw a
|
||||
<a href="./exception.html#negative_edge"><tt>negative_edge</tt></a>
|
||||
exception is one of the edges is negative.
|
||||
The type <tt>WeightMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The edge descriptor type of
|
||||
the graph needs to be usable as the key type for the weight
|
||||
map. The value type for this map must be
|
||||
the same as the value type of the distance map.<br>
|
||||
<b>Default:</b> All edge weights are assumed to be equivalent.
|
||||
<b>Python</b>: If supplied, must be an <tt>edge_double_map</tt> for the graph.
|
||||
</blockquote>
|
||||
|
||||
<h3>Complexity</h3>
|
||||
The time complexity is <em>O(VE)</em> for unweighted graphs and
|
||||
<em>O(VE + V(V+E) log V)</em> for weighted graphs. The space complexity
|
||||
is <em>O(VE)</em>.
|
||||
|
||||
<hr>
|
||||
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<A HREF="../../../people/doug_gregor.html">Douglas Gregor</A>, Indiana University (dgregor@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
<!-- Created: Fri Jun 4 16:42:50 EST 2004 -->
|
||||
<!-- hhmts start -->Last modified: Tue Mar 1 14:14:51 EST 2005 <!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,132 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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,
|
||||
boost::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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
Before Width: | Height: | Size: 8.2 KiB |
@@ -1,100 +0,0 @@
|
||||
<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: Named Parameters</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:bgl-named-params"></A>
|
||||
<pre>
|
||||
bgl_named_params<Param, Type, Rest>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
<p>
|
||||
Many of the Boost.Graph algorithms have a long list of parameters,
|
||||
most of which have default values. This causes several problems.
|
||||
First, C++ does not provide a mechanism for handling default
|
||||
parameters of template functions. However, this can be overcome by
|
||||
creating multiply version of an algorithm with different numbers of
|
||||
parameters with each version providing defaults for some subset of
|
||||
the parameters. This is the approach used in previous versions of
|
||||
Boost.Graph. This solution is still unsatisfactory for several
|
||||
reasons:
|
||||
|
||||
<ul>
|
||||
<li>The defaults for parameters can only been used in a particular
|
||||
order. If the ordering of the defaults does not fit the users situation
|
||||
he or she has to resort to providing all the parameters.
|
||||
|
||||
<li>Since the list of parameters is long, it is easy to forget
|
||||
the ordering.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
A better solution is provided by <tt>bgl_named_params</tt>. This class
|
||||
allows users to provide parameters is any order, and matches
|
||||
arguments to parameters based on parameter names.
|
||||
|
||||
<p>
|
||||
The following code shows an example of calling
|
||||
<tt>bellman_ford_shortest_paths</tt> using the named parameter
|
||||
technique. Each of the arguments is passed to a function whose name
|
||||
indicates which parameter the argument is for. Each of the named
|
||||
parameters is separated by a <b>period</b>, not a comma.
|
||||
|
||||
<pre>
|
||||
bool r = boost::bellman_ford_shortest_paths(g, int(N),
|
||||
boost::weight_map(weight).
|
||||
distance_map(&distance[0]).
|
||||
predecessor_map(&parent[0]));
|
||||
</pre>
|
||||
|
||||
<p>The order in which the arguments are provided does not matter as
|
||||
long as they are matched with the correct parameter function. Here is
|
||||
an call to <tt>bellman_ford_shortest_paths</tt> that is equivalent to
|
||||
the one above.
|
||||
|
||||
<pre>
|
||||
bool r = boost::bellman_ford_shortest_paths(g, int(N),
|
||||
boost::predecessor_map(&parent[0]).
|
||||
distance_map(&distance[0]).
|
||||
weight_map(weight));
|
||||
</pre>
|
||||
|
||||
<p>Typically the user never needs to deal with the
|
||||
<tt>bgl_named_params</tt> class directly, since there are functions
|
||||
like <tt>boost::weight_map</tt> that create an instance of
|
||||
<tt>bgl_named_params</tt>.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,398 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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.
|
||||
|
||||
<P></P><DT><A NAME="ford56:_maxim">36</a>
|
||||
<DD>L. R. Ford and D. R. Fulkerson<BR>
|
||||
<EM>Maximal flow through a network.</EM><br>
|
||||
Can. Journal of Mathematics 1956 pp.399-404
|
||||
|
||||
<P></P><DT><A NAME="goldberg85:_new_max_flow_algor">37</a>
|
||||
<DD>A. V. Goldberg<BR>
|
||||
<EM>A New Max-Flow Algorithm.</EM><br>
|
||||
MIT Tehnical report MIT/LCS/TM-291, 1985.
|
||||
|
||||
<P></P><DT><A NAME="karzanov74:_deter">38</a>
|
||||
<DD>A. V. Karzanov<BR>
|
||||
<EM>Determining the maximal flow in a network by the method of preflows.</EM><br>
|
||||
Sov. Math. Dokl. 1974
|
||||
|
||||
<P></P><DT><A NAME="ahuja93:_network_flows">39</a>
|
||||
<DD>Ravindra K. Ahuja and Thomas L. Magnanti and James B. Orlin<BR>
|
||||
<EM>Network Flows: Theory, Algorithms, and Applications.</EM><br>
|
||||
Prentice Hall, 1993.
|
||||
|
||||
<P></P><DT><A NAME="edmonds72:_improvements_netflow">40</a>
|
||||
<DD>Jack Edmonds and Richard M. Karp<BR>
|
||||
<EM>Theoretical improvements in the algorithmic efficiency for network flow problems.</EM><br>
|
||||
Journal of the ACM, 1972 19:248-264
|
||||
|
||||
<P></P><DT><A NAME="tarjan72:dfs_and_linear_algo">41</a>
|
||||
<DD>Robert E. Tarjan<BR>
|
||||
<EM>Depth first search and linear graph algorithms.</EM><br>
|
||||
SIAM Journal on Computing, 1(2):146-160, 1972
|
||||
|
||||
<P></P><DT><A NAME="eppstein97:dynamic_graph">42</a>
|
||||
<DD>David Eppstein, Zvi Galil, and Giuseppe F. Italiano<BR>
|
||||
<EM>Dynamic Graph Algorithms.</EM><br>
|
||||
Chapter 22, CRC Handbook of Algorithms and Theory of Computation, 1997.
|
||||
|
||||
<P></P><DT><A NAME="cuthill69:reducing_bandwith">43</a>
|
||||
<DD>E. Cuthill and J. McKee<BR>
|
||||
<EM>Reducing the bandwidth of sparse symmetric matrices.</EM><br>
|
||||
Proceedings of the 24th National Conference of the ACM, 1969.
|
||||
|
||||
<P></P><DT><A NAME="liu75:anal_cm_rcm">44</a>
|
||||
<DD>J. Liu and A. Sherman<BR>
|
||||
<EM>Comparative analysis of the Cuthill-Mckee and the reverse
|
||||
Cuthill-Mckee ordering algorithms for sparse matrices.</EM><br>
|
||||
SIAM Journal of Numerical Analysis. 13 (1975), pp. 198-213.
|
||||
|
||||
<P></P><DT><A NAME="george71:fem">45</a>
|
||||
<DD>Alan George<BR>
|
||||
<EM>Computer implementation of the finite element method</EM><br>
|
||||
Technical Report STAN-CS-208, Stanford University (1971).
|
||||
|
||||
<P></P><DT><A NAME="fortin96:_graph_iso_prob">46</a>
|
||||
<DD>Scott Fortin<BR>
|
||||
<EM>The Graph Isomorphism Problem</EM><br>
|
||||
TR 96-20, Dept. of Computer Science, University of Alberta (1996)
|
||||
|
||||
<P></P><DT><A NAME="mckay81:_pract_graph_iso">47</a>
|
||||
<DD>Brendan D. McKay<BR>
|
||||
<EM>Practical Graph Isomorphism</EM><br>
|
||||
Congressus Numerantium (1981)
|
||||
|
||||
<P></P><DT><A NAME="reingold77:_combin_algo">48</a>
|
||||
<DD>Reingold, Nievergelt, and Deo<BR>
|
||||
<EM>Combinatorial Algorithms: Theory and Practice</EM><br>
|
||||
Prentice Hall (1977)
|
||||
|
||||
<P></P><DT><A NAME="moore59">49</a>
|
||||
<DD>Edward Moore<BR>
|
||||
<EM>The shortest path through a maze</EM><br>
|
||||
International Symposium on the Theory of Switching (1959)<br>
|
||||
Harvard University Press
|
||||
|
||||
<P></P><DT><A NAME="nuutila95">50</a>
|
||||
<DD>E. Nuutila<BR>
|
||||
<EM>Efficient transitive closure computation in large digraphs</EM><br>
|
||||
PhD Thesis, Helsinki University of Technology, 1995. <br>
|
||||
Acta Polytechnica Scandinavica, Mathematics and Computing in
|
||||
Engineering Series, No. 74.
|
||||
|
||||
<P></P><DT><A NAME="goral79">51</a>
|
||||
<DD>A. Goralcikova and V. Koubek<BR>
|
||||
<EM>A reduct and closure algorithm for graphs</EM><br>
|
||||
In Mathematical Foundations of Computer Science, <br>
|
||||
volume 74 of Lecture Notes in Computer Science, pages 301-307. <br>
|
||||
Springer-Verlag, 1979
|
||||
|
||||
<P></P><DT><A NAME="simon86">52</a>
|
||||
<DD>Klaus Simon<BR>
|
||||
<EM>An Improved Algorithm for Transitive Closure on Acyclic Digraphs</EM><br>
|
||||
Theoretical Computer Science 58<br>
|
||||
Automata, Languages and Programming, 376-386, 1986
|
||||
|
||||
<P></P><DT><A NAME="purdom70">53</a>
|
||||
<DD>P. Purdom<BR>
|
||||
<EM>A Transitive Closure Algorithm</EM><br>
|
||||
BIT, 10, 1970, pp. 76-94.
|
||||
|
||||
<p></p><dt><a name="brandes01">54</a>
|
||||
<dd>Ulrik Brandes<br>
|
||||
<em><a href="http://ella.slis.indiana.edu/~katy/L579/brandes.pdf">A
|
||||
Faster Algorithm for Betweenness Centrality</a></em><br>
|
||||
Journal of Mathematical Sociology 25 (2):163-177, 2001.
|
||||
|
||||
<p></p><dt><a name="freeman77">55</a>
|
||||
<dd>Lindon C. Freeman<br>
|
||||
<em>A Set of Measures of Centrality Based on Betweenness</em><br>
|
||||
Sociometry 40, pp. 35-41, 1977.
|
||||
|
||||
<p></p><dt><a name="anthonisse71">56</a>
|
||||
<dd>J.M. Anthonisse<br>
|
||||
<em>The rush in a directed graph.</em><br>
|
||||
Technical Report BN9/71, Stichting Mahtematisch Centrum, Amsterdam, 1971.
|
||||
|
||||
<p></p><dt><a name="kamada89">57</a>
|
||||
<dd>T. Kamada and S. Kawai<br>
|
||||
<em>An algorithm for drawing general undirected graphs.</em><br>
|
||||
Information Processing Letters, 31, pp. 7-15, 1989.
|
||||
|
||||
<p></p><dt><a name="fruchterman91">58</a>
|
||||
<dd>T. Fruchterman and E. Reingold<br>
|
||||
<em>Graph drawing by force-directed placement.</em><br>
|
||||
Software--Practice & Experience, 21 (11), pp. 1129-1164, 1991.
|
||||
|
||||
<p></p><dt><a name="coleman83">59</a>
|
||||
<dd>Thomas F. Coleman and Jorge J. More<br>
|
||||
<em>Estimation of sparse Jacobian
|
||||
matrices and graph coloring problems.</em><br>
|
||||
Journal of Numerical Analasis V20, pp. 187-209, 1983.
|
||||
|
||||
<p></p><dt><a name="gursoy00">60</a>
|
||||
<dd>Attila Gürsoy and Murat Atun<br>
|
||||
<em>Neighborhood Preserving Load Balancing: A Self-Organizing Approach</em>
|
||||
<br>
|
||||
Euro-Par Parallel Processing, LNCS 1900, pp. 324-41, 2000.
|
||||
|
||||
<p></p><dt><a name="driscoll88">61</a>
|
||||
<dd>James R. Driscoll, Harold N. Gabow, Ruth Shrairman, and Robert E. Tarjan<br>
|
||||
<em>Relaxed Heaps: An alternative for Fibonacci Heaps with applications to parallel computation.</em><br>
|
||||
Communications of the ACM, 31 (11), pp. 1343-1354, November 1988.
|
||||
|
||||
<p></p><dt><a name="king70">62</a>
|
||||
<dd>King, I. P.<br>
|
||||
<em>An automatic reordering scheme for simultaneous equations derived from network analysis.</em><br>
|
||||
Int. J. Numer. Methods Engrg. 2, pp. 523-533, 1970.
|
||||
|
||||
<p></p><dt><a name="edmonds65">64</a>
|
||||
<dd>J. Edmonds<br>
|
||||
<em>Paths, trees, and flowers</em><br>
|
||||
Canadian Journal of Mathematics 17 (1965), pp. 449-467.
|
||||
</dl>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,254 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright 2001-2004 The Trustees of Indiana University.
|
||||
--
|
||||
-- Use, modification and distribution is subject to the Boost Software
|
||||
-- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
-- http://www.boost.org/LICENSE_1_0.txt)
|
||||
--
|
||||
-- Authors: Douglas Gregor
|
||||
-- Jeremy Siek
|
||||
-- Andrew Lumsdaine
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Biconnected Components and Articulation Points</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1>
|
||||
<TT>
|
||||
<img src="figs/python.gif" alt="(Python)"/>
|
||||
<A NAME="sec:biconnected-components">biconnected_components
|
||||
</A>
|
||||
</TT>
|
||||
and
|
||||
<tt>articulation_points</tt>
|
||||
</h1>
|
||||
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template <typename Graph, typename ComponentMap, typename OutputIterator,
|
||||
typename P, typename T, typename R>
|
||||
std::pair<std::size_t, OutputIterator>
|
||||
biconnected_components(const Graph& g, ComponentMap comp, OutputIterator out,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
|
||||
template <typename Graph, typename ComponentMap,
|
||||
typename P, typename T, typename R>
|
||||
std::size_t
|
||||
biconnected_components(const Graph& g, ComponentMap comp,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
|
||||
template <typename Graph, typename OutputIterator,
|
||||
typename P, typename T, typename R>
|
||||
OutputIterator articulation_points(const Graph& g, OutputIterator out,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <typename Graph, typename ComponentMap, typename OutputIterator,
|
||||
typename DiscoverTimeMap, typename LowPointMap>
|
||||
std::pair<std::size_t, OutputIterator>
|
||||
biconnected_components(const Graph& g, ComponentMap comp, OutputIterator out,
|
||||
DiscoverTimeMap discover_time, LowPointMap lowpt);
|
||||
|
||||
template <typename Graph, typename ComponentMap, typename OutputIterator>
|
||||
std::pair<std::size_t, OutputIterator>
|
||||
biconnected_components(const Graph& g, ComponentMap comp, OutputIterator out);
|
||||
|
||||
template <typename Graph, typename ComponentMap>
|
||||
std::size_t biconnected_components(const Graph& g, ComponentMap comp);
|
||||
<a name="sec:articulation_points">
|
||||
template <typename Graph, typename OutputIterator>
|
||||
OutputIterator articulation_points(const Graph& g, OutputIterator out);
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
A connected graph is <i>biconnected</i> if the removal of any single
|
||||
vertex (and all edges incident on that vertex) can not disconnect the
|
||||
graph. More generally, the biconnected components of a graph are the
|
||||
maximal subsets of vertices such that the removal of a vertex from a
|
||||
particular component will not disconnect the component. Unlike
|
||||
connected components, vertices may belong to multiple biconnected
|
||||
components: those vertices that belong to more than one biconnected
|
||||
component are called <em>articulation points</em> or, equivalently,
|
||||
<em>cut vertices</em>. Articulation points are vertices whose removal
|
||||
would increase the number of connected components in the graph. Thus,
|
||||
a graph without articulation points is biconnected. The following
|
||||
figure illustrates the articulation points and biconnected components
|
||||
of a small graph:
|
||||
|
||||
<p><center><img src="figs/biconnected.png"></center>
|
||||
|
||||
<p>Vertices can be present in multiple biconnected components, but each
|
||||
edge can only be contained in a single biconnected component. The
|
||||
output of the <tt>biconnected_components</tt> algorithm records the
|
||||
biconnected component number of each edge in the property map
|
||||
<tt>comp</tt>. Articulation points will be emitted to the (optional)
|
||||
output iterator argument to <tt>biconnected_components</tt>, or can be
|
||||
computed without the use of a biconnected component number map via
|
||||
<tt>articulation_points</tt>. These functions return the number of
|
||||
biconnected components, the articulation point output iterator, or a
|
||||
pair of these quantities, depending on what information was
|
||||
recorded.
|
||||
|
||||
<p>The algorithm implemented is due to Tarjan [<a href="bibliography.html#tarjan72:dfs_and_linear_algo">41</a>].
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/biconnected_components.hpp"><TT>boost/graph/biconnected_components.hpp</TT></a>
|
||||
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
An undirected graph. The graph type must be a model of <a
|
||||
href="VertexListGraph.html">Vertex List Graph</a> and <a
|
||||
href="IncidenceGraph.html">Incidence Graph</a>.<br>
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>ComponentMap c</tt>
|
||||
<blockquote>
|
||||
The algorithm computes how many biconnected components are in the graph,
|
||||
and assigning each component an integer label. The algorithm then
|
||||
records which component each edge in the graph belongs to by
|
||||
recording the component number in the component property map. The
|
||||
<tt>ComponentMap</tt> type must be a model of <a
|
||||
href="../../property_map/WritablePropertyMap.html">Writable Property
|
||||
Map</a>. The value type shouch be an integer type, preferably the same
|
||||
as the <tt>edges_size_type</tt> of the graph. The key type must be
|
||||
the graph's edge descriptor type.<br>
|
||||
<b>Default</b>: <tt>dummy_property_map</tt>.<br>
|
||||
<b>Python</b>: Must be an <tt>edge_int_map</tt> for the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_edge_int_map("bicomponent")</tt>
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>OutputIterator out</tt>
|
||||
<blockquote>
|
||||
The algorithm writes articulation points via this output
|
||||
iterator and returns the resulting iterator.<br>
|
||||
<b>Default</b>: a dummy iterator that ignores values written to it.<br>
|
||||
|
||||
<b>Python</b>: this parameter is not used in Python. Instead, both
|
||||
algorithms return a Python <tt>list</tt> containing the articulation
|
||||
points.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. The type
|
||||
<tt>VertexIndexMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The value type of the map must be an
|
||||
integer type. The vertex descriptor type of the graph needs to be
|
||||
usable as the key type of the map.<br>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>discover_time_map(DiscoverTimeMap discover_time)</tt>
|
||||
<blockquote>
|
||||
The discovery time of each vertex in the depth-first search. The
|
||||
type <tt>DiscoverTimeMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>. The value type of the map must be an integer
|
||||
type. The vertex descriptor type of the graph needs to be usable as
|
||||
the key type of the map.<br>
|
||||
<b>Default</b>: an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>vertices_size_type</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using <tt>get(vertex_index, g)</tt> for
|
||||
the index map.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>lowpoint_map(LowPointMap lowpt)</tt>
|
||||
<blockquote>
|
||||
The low point of each vertex in the depth-first search, which is the
|
||||
smallest vertex reachable from a given vertex with at most one back
|
||||
edge. The type <tt>LowPointMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a>. The value type of the map must be an integer
|
||||
type. The vertex descriptor type of the graph needs to be usable as
|
||||
the key type of the map.<br>
|
||||
<b>Default</b>: an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>vertices_size_type</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using <tt>get(vertex_index, g)</tt> for
|
||||
the index map.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>predecessor_map(PredecessorMap p_map)</tt>
|
||||
<blockquote>
|
||||
The predecessor map is unusable after algorithm's completion.
|
||||
The <tt>PredecessorMap</tt> type
|
||||
must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> whose key and value types are the same as the vertex
|
||||
descriptor type of the graph.<br>
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>vertex_descriptor</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using <tt>get(vertex_index, g)</tt> for
|
||||
the index map.<br>
|
||||
|
||||
<b>Python</b>: Must be a <tt>vertex_vertex_map</tt> for the graph.<br>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>visitor(DFSVisitor vis)</tt>
|
||||
<blockquote>
|
||||
A visitor object that is invoked inside the algorithm at the
|
||||
event-points specified by the <a href="./DFSVisitor.html">DFS
|
||||
Visitor</a> concept. The visitor object is passed by value <a
|
||||
href="#1">[1]</a>. <br> <b>Default:</b>
|
||||
<tt>dfs_visitor<null_visitor></tt><br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a href="DFSVisitor.html#python"><tt>DFSVisitor</tt></a> type of
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity for the biconnected components and articulation
|
||||
points algorithms
|
||||
<i>O(V + E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P> The file <a
|
||||
href="../example/biconnected_components.cpp"><tt>examples/biconnected_components.cpp</tt></a>
|
||||
contains an example of calculating the biconnected components and
|
||||
articulation points of an undirected graph.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2004</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana
|
||||
University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<a href="../../../people/doug_gregor.html">Doug Gregor</a>, Indiana University
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,386 +0,0 @@
|
||||
\documentclass[11pt]{report}
|
||||
|
||||
|
||||
\usepackage[leqno]{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{amsthm}
|
||||
\usepackage{latexsym}
|
||||
\usepackage{jweb}
|
||||
\usepackage{times}
|
||||
\usepackage{graphicx}
|
||||
\usepackage[nolineno]{lgrind}
|
||||
|
||||
\newif\ifpdf
|
||||
\ifx\pdfoutput\undefined
|
||||
\pdffalse
|
||||
\else
|
||||
\pdfoutput=1
|
||||
\pdftrue
|
||||
\fi
|
||||
|
||||
\ifpdf
|
||||
\usepackage[
|
||||
pdftex,
|
||||
colorlinks=true, % change to true for the electronic version
|
||||
linkcolor=blue,filecolor=blue,pagecolor=blue,urlcolor=blue
|
||||
]{hyperref}
|
||||
\newcommand{\myhyperref}[2]{\hyperref[#1]{#2}}
|
||||
\fi
|
||||
|
||||
\newcommand{\mtlfig}[2]{\centerline{\includegraphics*[#2]{#1.pdf}}}
|
||||
|
||||
\newcommand{\Path}{\rightsquigarrow}
|
||||
\newcommand{\ancestor}{\overset{T}{\rightsquigarrow}}
|
||||
\newcommand{\descendant}{\ancestor^{-1}}
|
||||
\newcommand{\backedge}{\overset{B}{\rightarrow}}
|
||||
\newcommand{\edge}{\rightarrow}
|
||||
\DeclareMathOperator{\suchthat}{s.t.}
|
||||
|
||||
\newcommand{\code}[1]{{\small{\em \textbf{#1}}}}
|
||||
\newcommand{\concept}[1]{\textsf{#1}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\title{An Implementation of Biconnected Components}
|
||||
\author{Jeremy Siek}
|
||||
|
||||
\maketitle
|
||||
|
||||
\section{Introduction}
|
||||
|
||||
This paper documents the implementation of the
|
||||
\code{biconnected\_components()} function of the Boost Graph
|
||||
Library. The function was implemented by Jeremy Siek.
|
||||
|
||||
The algorithm used to implement the \code{biconnected\_components()}
|
||||
function is the one based on depth-first search described
|
||||
by Tarjan~\cite{tarjan72:dfs_and_linear_algo}.
|
||||
|
||||
An undirected graph $G = (V,E)$ is \emph{biconnected} if for each
|
||||
triple of distinct vertices $v, w, a \in V$ there is a path $p : v
|
||||
\Path w$ such that $a$ is not on the path $p$. An \emph{articulation
|
||||
point} of $G = (V,E)$ is a vertex $a \in V$ where there are two other
|
||||
distinct vertices $v,w \in V$ such that $a$ is on any path $p:v \Path
|
||||
w$ and there is at least one such path. If $a$ were to be removed from
|
||||
$G$, then $v$ and $w$ would no longer be reachable from each other.
|
||||
So articulation points act as bridges between biconnected components;
|
||||
the only path from one biconnected component to another is through an
|
||||
articulation point.
|
||||
|
||||
The algorithm finds articulation points based on information provided
|
||||
by depth-first search. During a DFS, we label each vertex $v \in G$
|
||||
with its discover time, denoted $d[v]$. During the DFS we also
|
||||
compute the $lowpt(v)$, which is the smallest (in terms of discover
|
||||
time) vertex reachable from $v$ by traversing zero or more DFS-tree
|
||||
edges followed by at most one back edge. Tree edges and back edges can
|
||||
be identified based on discover time because for tree edge $(u,v)$ we
|
||||
have $d[u] < d[v]$ and for back edge $(u,v)$ we have $d[u] >
|
||||
d[v]$. The $lowpt(v)$ is computed for $v$ by taking the minimum
|
||||
$lowpt$ of the vertices to which $v$ is adjacent. The $lowpt(v)$ is
|
||||
computed after the recursive DFS call so the $lowpt$ has already been
|
||||
computed for the adjacent vertices by the time $lowpt(v)$ is computed.
|
||||
|
||||
Now it turns out that $lowpt$ can be used to identify articulation
|
||||
points. Suppose $a,v,w$ are distinct vertices in $G$ such that $(a,v)$
|
||||
is a tree edge and $w$ is not a descendant of $v$. If $d[lowpt(v)]
|
||||
\geq d[a]$, then $a$ is an articulation point and removal of $a$
|
||||
disconnects $v$ and $w$. The reason this works is that if $d[lowpt(v)]
|
||||
\geq d[a]$, then we know all paths starting from $v$ stay within the
|
||||
sub-tree $T_v$ rooted at $v$. If a path were to escape from the
|
||||
sub-tree, then consider the first vertex $w$ in that path outside of
|
||||
$T_v$. $v \Path w$ must be considered for $lowpt(v)$, so $d[lowpt(v)]
|
||||
< d[w]$. Now $d[w] < d[a]$ due the structure of the DFS, so
|
||||
transitively $d[lowpt(v)] < d[a]$.
|
||||
|
||||
\section{The Implementation}
|
||||
|
||||
The implementation consists of a recursive DFS-like function named
|
||||
\code{biconnect()} and the public interface function
|
||||
\code{biconnected\-\_components()}. The \code{Graph} type must be a
|
||||
model of \concept{VertexListGraph} and of \concept{IncidenceGraph}.
|
||||
The result of the algorithm is recorded in the \code{ComponentMap},
|
||||
which maps edges to the biconnected component that they belong to
|
||||
(components are labeled with integers from zero on up). The
|
||||
\code{ComponentMap} type must be a model of
|
||||
\concept{WritablePropertyMap}, which the graph's
|
||||
\code{edge\-\_descriptor} type as the key type and an unsigned integer
|
||||
type as the value type. We do not record which component each vertex
|
||||
belongs to because vertices that are articulation points belong to
|
||||
multiple biconnected components. The number of biconnected components
|
||||
is returned in the \code{num\_components} parameter. The
|
||||
\code{discover\_time} parameter is used internally to keep track of
|
||||
the DFS discover time for each vertex. It must be a
|
||||
\concept{ReadWritePropertyMap} with the graph's
|
||||
\code{vertex\_\-descriptor} type as the key type and an unsigned
|
||||
integer as the value type. The \code{lowpt} parameter is used
|
||||
internally to keep track of the $d[lowpt(v)]$ for each vertex $v$. It
|
||||
must be a \concept{ReadWritePropertyMap} with the graph's
|
||||
\code{vertex\_\-descriptor} type is the key type and the value type is
|
||||
the same unsigned integer type as the value type in the
|
||||
\code{discover\-\_time} map.
|
||||
|
||||
@d Biconnected Components Algorithm
|
||||
@{
|
||||
namespace detail {
|
||||
@<Recursive Biconnect Function@>
|
||||
}
|
||||
|
||||
template <typename Graph, typename ComponentMap,
|
||||
typename DiscoverTimeMap, typename LowPointMap>
|
||||
void biconnected_components
|
||||
(typename graph_traits<Graph>::vertex_descriptor v,
|
||||
typename graph_traits<Graph>::vertex_descriptor u,
|
||||
const Graph& g,
|
||||
ComponentMap comp,
|
||||
std::size_t& num_components,
|
||||
DiscoverTimeMap discover_time,
|
||||
LowPointMap lowpt)
|
||||
{
|
||||
typedef graph_traits<Graph>::vertex_descriptor vertex_t;
|
||||
typedef graph_traits<Graph>::edge_descriptor edge_t;
|
||||
@<Concept checking of type parameters@>
|
||||
typedef typename property_traits<DiscoverTimeMap>::value_type D;
|
||||
num_components = 0;
|
||||
std::size_t dfs_time = 0;
|
||||
std::stack<edge_t> S;
|
||||
@<Initialize discover times to infinity@>
|
||||
@<Process each connected component@>
|
||||
}
|
||||
@}
|
||||
|
||||
\noindent In the following code we use the Boost Concept Checking
|
||||
Library to provide better error messages in the event that the user
|
||||
makes a mistake in the kind of parameter used in the function
|
||||
template.
|
||||
|
||||
@d Concept checking of type parameters
|
||||
@{
|
||||
function_requires< VertexListGraphConcept<Graph> >();
|
||||
function_requires< IncidenceGraphConcept<Graph> >();
|
||||
function_requires< WritablePropertyMapConcept<ComponentMap, edge_t> >();
|
||||
function_requires< ReadWritePropertyMapConcept<DiscoverTimeMap, vertex_t> >();
|
||||
function_requires< ReadWritePropertyMapConcept<LowPointMap, vertex_t> >();
|
||||
@}
|
||||
|
||||
The first step of the algorithm is to initialize the discover times of
|
||||
all the vertices to infinity. This marks the vertices as undiscovered.
|
||||
|
||||
@d Initialize discover times to infinity
|
||||
@{
|
||||
typename graph_traits<Graph>::vertex_iterator wi, wi_end;
|
||||
std::size_t infinity = std::numeric_limits<std::size_t>::max();
|
||||
for (tie(wi, wi_end) = vertices(g); wi != wi_end; ++wi)
|
||||
put(discover_time, *wi, infinity);
|
||||
@}
|
||||
|
||||
\noindent Next we invoke \code{biconnect()} on every vertex in the
|
||||
graph, making sure that all connected components within the graph are
|
||||
searched (\code{biconnect()} only processes a single connected
|
||||
component).
|
||||
|
||||
@d Process each connected component
|
||||
@{
|
||||
for (tie(wi, wi_end) = vertices(g); wi != wi_end; ++wi)
|
||||
if (get(discover_time, *wi) == std::numeric_limits<D>::max())
|
||||
detail::biconnect(*wi, *wi, true,
|
||||
g, comp, num_components,
|
||||
discover_time, dfs_time, lowpt, S);
|
||||
@}
|
||||
|
||||
The recursive \code{biconnect()} function is shown below. The
|
||||
\code{v} parameter is where the DFS is started. The \code{u}
|
||||
parameter is the parent of \code{v} in the DFS-tree if \code{at\_top
|
||||
== false} or if \code{at\_top == true} the \code{u} is not used.
|
||||
\code{S} is a stack of edges that is used to collect all edges in a
|
||||
biconnected component. The way this works is that on ``the way down''
|
||||
edges are pushed into the stack. ``On the way back up'', when an
|
||||
articulation point $v$ is found (identified because $d[lowpt(w)] \geq
|
||||
d[v]$) we know that a contiguous portion of the stack (starting at the
|
||||
top) contains the edges in the sub-tree $T_v$ which is the biconnected
|
||||
component. We therefore pop these edges off of the stack (until we
|
||||
find an edge $e$ where $d[lowpt(source(e))] < d[w]$) and mark them as
|
||||
belonging to the same component. The code below also includes the
|
||||
bookkeeping details such as recording the discover times and computing
|
||||
$lowpt$. When a back edge $(v,w)$ is encountered, we do not use
|
||||
$lowpt(w)$ in calculating $lowpt(v)$ since $lowpt(w)$ has not yet been
|
||||
computed. Also, we ignore the edge $(v,w)$ if $w$ is the parent of $v$
|
||||
in the DFS-tree, meaning that $(w,v)$ has already been examined and
|
||||
categorized as a tree edge (not a back edge).
|
||||
|
||||
@d Recursive Biconnect Function
|
||||
@{
|
||||
template <typename Graph, typename ComponentMap,
|
||||
typename DiscoverTimeMap, typename LowPointMap, typename Stack>
|
||||
void biconnect(typename graph_traits<Graph>::vertex_descriptor v,
|
||||
typename graph_traits<Graph>::vertex_descriptor u,
|
||||
bool at_top,
|
||||
const Graph& g,
|
||||
ComponentMap comp,
|
||||
std::size_t& c,
|
||||
DiscoverTimeMap d,
|
||||
std::size_t& dfs_time,
|
||||
LowPointMap lowpt,
|
||||
Stack& S)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
|
||||
typedef typename property_traits<DiscoverTimeMap>::value_type D;
|
||||
D infinity = std::numeric_limits<D>::max();
|
||||
put(d, v, ++dfs_time);
|
||||
put(lowpt, v, get(d, v));
|
||||
typename graph_traits<Graph>::out_edge_iterator ei, ei_end;
|
||||
for (tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) {
|
||||
vertex_t w = target(*ei, g);
|
||||
if (get(d, w) == infinity) {
|
||||
S.push(*ei);
|
||||
biconnect(w, v, false, g, comp, c, d, dfs_time, lowpt, S);
|
||||
put(lowpt, v, std::min(get(lowpt, v), get(lowpt, w)));
|
||||
if (get(lowpt, w) >= get(d, v)) {
|
||||
@<Record the biconnected component@>
|
||||
}
|
||||
} else if (get(d, w) < get(d, v) && (!at_top && w != u)) {
|
||||
S.push(*ei);
|
||||
put(lowpt, v, std::min(get(lowpt, v), get(d, w)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@}
|
||||
|
||||
\noindent The following is the code for popping the edges of sub-tree
|
||||
$T_v$ off of the stack and recording them as being in the same
|
||||
biconnected component.
|
||||
|
||||
@d Record the biconnected component
|
||||
@{
|
||||
while (d[source(S.top(), g)] >= d[w]) {
|
||||
put(comp, S.top(), c);
|
||||
S.pop();
|
||||
}
|
||||
put(comp, S.top(), c);
|
||||
S.pop();
|
||||
++c;
|
||||
@}
|
||||
|
||||
|
||||
\section{Appendix}
|
||||
|
||||
@o biconnected-components.hpp
|
||||
@{
|
||||
// Copyright (c) Jeremy Siek 2001
|
||||
//
|
||||
// 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.
|
||||
|
||||
// NOTE: this final is generated by libs/graph/doc/biconnected_components.w
|
||||
|
||||
#ifndef BOOST_GRAPH_BICONNECTED_COMPONENTS_HPP
|
||||
#define BOOST_GRAPH_BICONNECTED_COMPONENTS_HPP
|
||||
|
||||
#include <stack>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <boost/graph/graph_concepts.hpp>
|
||||
#include <boost/property_map.hpp>
|
||||
|
||||
namespace boost {
|
||||
@<Biconnected Components Algorithm@>
|
||||
} // namespace boost
|
||||
|
||||
#endif BOOST_GRAPH_BICONNECTED_COMPONENTS_HPP
|
||||
@}
|
||||
|
||||
Figure~\ref{fig:bcc} shows the graph used in the following example and
|
||||
the edges are labeled by biconnected component number, as computed by
|
||||
the algorithm.
|
||||
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\mtlfig{bcc}{width=3.0in}
|
||||
\caption{The biconnected components.}
|
||||
\label{fig:bcc}
|
||||
\end{figure}
|
||||
|
||||
|
||||
@o biconnected-components.cpp
|
||||
@{
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <boost/graph/biconnected_components.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
|
||||
namespace boost {
|
||||
struct edge_component_t {
|
||||
enum { num = 555 };
|
||||
typedef edge_property_tag kind;
|
||||
} edge_component;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost;
|
||||
typedef adjacency_list<vecS, vecS, undirectedS,
|
||||
no_property, property<edge_component_t, std::size_t> > graph_t;
|
||||
typedef graph_traits<graph_t>::vertex_descriptor vertex_t;
|
||||
graph_t g(9);
|
||||
add_edge(0, 5, g); add_edge(0, 1, g); add_edge(0, 6, g);
|
||||
add_edge(1, 2, g); add_edge(1, 3, g); add_edge(1, 4, g);
|
||||
add_edge(2, 3, g);
|
||||
add_edge(4, 5, g);
|
||||
add_edge(6, 8, g); add_edge(6, 7, g);
|
||||
add_edge(7, 8, g);
|
||||
|
||||
std::size_t c = 0;
|
||||
std::vector<std::size_t> discover_time(num_vertices(g));
|
||||
std::vector<vertex_t> lowpt(num_vertices(g));
|
||||
property_map<graph_t, edge_component_t>::type
|
||||
component = get(edge_component, g);
|
||||
biconnected_components(0, 8, g, component,
|
||||
c, &discover_time[0], &lowpt[0]);
|
||||
|
||||
std::cout << "graph A {\n"
|
||||
<< " node[shape=\"circle\"]\n";
|
||||
|
||||
graph_traits<graph_t>::edge_iterator ei, ei_end;
|
||||
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
std::cout << source(*ei, g) << " -- " << target(*ei, g)
|
||||
<< "[label=\"" << component[*ei] << "\"]\n";
|
||||
std::cout << "}\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@}
|
||||
|
||||
|
||||
|
||||
% \paragraph{Definition.} A \emph{palm tree} $P$ is a directed graph that
|
||||
% consists of two disjoint sets of edges, denoted by $v \rightarrow w$
|
||||
% and $v \backedge w$ respectively, with the following properties:
|
||||
|
||||
% \begin{enumerate}
|
||||
|
||||
% \item The subgraph $T$ containing the edges $v \rightarrow w$ is a
|
||||
% spanning tree of $P$.
|
||||
|
||||
% \item $\backedge \; \subseteq \descendant$. That is, each edge of $P$
|
||||
% that is not in $T$ connects a vertex to one of its ancestors in $T$.
|
||||
% \end{enumerate}
|
||||
|
||||
|
||||
|
||||
\bibliographystyle{abbrv}
|
||||
\bibliography{jtran,ggcl,optimization,generic-programming,cad}
|
||||
|
||||
\end{document}
|
||||
|
||||
% LocalWords: Biconnected Siek biconnected Tarjan undirected DFS lowpt num dfs
|
||||
% LocalWords: biconnect VertexListGraph IncidenceGraph ComponentMap namespace
|
||||
% LocalWords: WritablePropertyMap ReadWritePropertyMap typename LowPointMap wi
|
||||
% LocalWords: DiscoverTimeMap const comp typedef VertexListGraphConcept max ei
|
||||
% LocalWords: IncidenceGraphConcept WritablePropertyMapConcept iterator bool
|
||||
% LocalWords: ReadWritePropertyMapConcept hpp ifndef endif bcc cpp struct enum
|
||||
% LocalWords: adjacency vecS undirectedS jtran ggcl
|
||||
@@ -1,338 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000, 2001
|
||||
--
|
||||
-- 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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:bfs">
|
||||
<img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>breadth_first_search</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template <class Graph, class P, class T, class R>
|
||||
void breadth_first_search(Graph& G,
|
||||
typename graph_traits<Graph>::vertex_descriptor s,
|
||||
const bgl_named_params<P, T, R>& params);
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <class Graph, class Buffer, class BFSVisitor,
|
||||
class ColorMap>
|
||||
void breadth_first_search(const Graph& g,
|
||||
typename graph_traits<Graph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color);
|
||||
</PRE>
|
||||
|
||||
|
||||
<p>
|
||||
The <tt>breadth_first_search()</tt> function performs a breadth-first
|
||||
traversal [<a href="./bibliography.html#moore59">49</a>] of a directed
|
||||
or undirected graph. A breadth-first traversal visits vertices that
|
||||
are closer to the source before visiting vertices that are further
|
||||
away. In this context ``distance'' is defined as the number of edges
|
||||
in the shortest path from the source vertex. The
|
||||
<tt>breadth_first_search()</tt> function can be used to compute the
|
||||
shortest path from the source to all reachable vertices and the
|
||||
resulting shortest-path distances. For more definitions related to BFS
|
||||
see section <a href="./graph_theory_review.html#sec:bfs-algorithm">
|
||||
Breadth-First Search</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
BFS uses two data structures to to implement the traversal: a color
|
||||
marker for each vertex and a queue. White vertices are undiscovered
|
||||
while gray vertices are discovered but have undiscovered adjacent
|
||||
vertices. Black vertices are discovered and are adjacent to only other
|
||||
black or gray vertices. The algorithm proceeds by removing a vertex
|
||||
</i>u</i> from the queue and examining each out-edge <i>(u,v)</i>. If an
|
||||
adjacent vertex <i>v</i> is not already discovered, it is colored gray and
|
||||
placed in the queue. After all of the out-edges are examined, vertex
|
||||
<i>u</i> is colored black and the process is repeated. Pseudo-code for the
|
||||
BFS algorithm is a listed below.
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
BFS(<i>G</i>, <i>s</i>)
|
||||
<b>for</b> each vertex <i>u in V[G]</i>
|
||||
<i>color[u] :=</i> WHITE
|
||||
<i>d[u] := infinity</i>
|
||||
<i>p[u] := u</i>
|
||||
<b>end for</b>
|
||||
<i>color[s] :=</i> GRAY
|
||||
<i>d[s] := 0</i>
|
||||
ENQUEUE(<i>Q</i>, <i>s</i>)
|
||||
<b>while</b> (<i>Q != Ø</i>)
|
||||
<i>u :=</i> DEQUEUE(Q)
|
||||
<b>for</b> each vertex <i>v in Adj[u]</i>
|
||||
<b>if</b> (<i>color[v] =</i> WHITE)
|
||||
<i>color[v] :=</i> GRAY
|
||||
<i>d[v] := d[u] + 1</i>
|
||||
<i>p[v] := u</i>
|
||||
ENQUEUE(<i>Q</i>, <i>v</i>)
|
||||
<b>else</b>
|
||||
<b>if</b> (<i>color[v] =</i> GRAY)
|
||||
...
|
||||
<b>else</b>
|
||||
...
|
||||
<b>end for</b>
|
||||
<i>color[u] :=</i> BLACK
|
||||
<b>end while</b>
|
||||
return (<i>d</i>, <i>p</i>)
|
||||
</pre>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
|
||||
initialize vertex <i>u</i>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
discover vertex <i>s</i>
|
||||
|
||||
examine vertex <i>u</i>
|
||||
examine edge <i>(u,v)</i>
|
||||
<i>(u,v)</i> is a tree edge
|
||||
|
||||
|
||||
|
||||
discover vertex <i>v</i>
|
||||
<i>(u,v)</i> is a non-tree edge
|
||||
|
||||
<i>(u,v)</i> has a gray target
|
||||
|
||||
<i>(u,v)</i> has a black target
|
||||
|
||||
finish vertex <i>u</i>
|
||||
</pre>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
The <tt>breadth_first_search()</tt> function can be extended with
|
||||
user-defined actions that will be called a certain event points. The
|
||||
actions must be provided in the form of a visitor object, that is, an
|
||||
object who's type meets the requirements for a <a
|
||||
href="./BFSVisitor.html">BFS Visitor</a>. In the above pseudo-code,
|
||||
the event points are the labels on the right. Also a description of
|
||||
each event point is given below. By default, the
|
||||
<tt>breadth_first_search()</tt> function does not carry out any
|
||||
actions, not even recording distances or predecessors. However these
|
||||
can be easily added using the <a
|
||||
href="./distance_recorder.html"><tt>distance_recorder</tt></a> and <a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>
|
||||
event visitors.
|
||||
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/breadth_first_search.hpp"><TT>boost/graph/breadth_first_search.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>Graph& g</tt>
|
||||
<blockquote>
|
||||
A directed or undirected graph. The graph type must
|
||||
be a model of <a href="./VertexListGraph.html">Vertex List Graph</a>
|
||||
and <a href="./IncidenceGraph.html">Incidence Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
<blockquote>
|
||||
The source vertex where the search is started.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>root_vertex</tt>.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>visitor(BFSVisitor vis)</tt>
|
||||
<blockquote>
|
||||
A visitor object that is invoked inside the algorithm at the
|
||||
event-points specified by the <a href="BFSVisitor.html">BFS
|
||||
Visitor</a> concept. The visitor object is passed by value <a
|
||||
href="#1">[1]</a>.<br> <b>Default:</b>
|
||||
<tt>bfs_visitor<null_visitor></tt> <br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a href="BFSVisitor.html#python"><tt>BFSVisitor</tt></a> type of the graph.
|
||||
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>color_map(ColorMap color)</tt>
|
||||
<blockquote>
|
||||
This is used by the algorithm to keep track of its progress through
|
||||
the graph. The user need not initialize the color map before calling
|
||||
<tt>breadth_first_search()</tt> since the algorithm initializes the
|
||||
color of every vertex to white at the start of the algorihtm. If you
|
||||
need to perform multiple breadth-first searches on a graph (for
|
||||
example, if there are some disconnected components) then use the <a
|
||||
href="./breadth_first_visit.html"><tt>breadth_first_visit()</tt></a>
|
||||
function and do your own color initialization.
|
||||
|
||||
<p>The type <tt>ColorMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> and its key type must be the graph's vertex
|
||||
descriptor type and the value type of the color map must model
|
||||
<a href="./ColorValue.html">ColorValue</a>.<br>
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>default_color_type</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.<br>
|
||||
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This parameter is only necessary when the
|
||||
default color property map is used. The type <tt>VertexIndexMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>. The value type of the map must be an integer type. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the map.<br>
|
||||
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>buffer(Buffer& Q)</tt>
|
||||
<blockquote>
|
||||
The queue used to determine the order in which vertices will be
|
||||
discovered. If a FIFO queue is used, then the traversal will
|
||||
be according to the usual BFS ordering. Other types of queues
|
||||
can be used, but the traversal order will be different.
|
||||
For example Dijkstra's algorithm can be implemented
|
||||
using a priority queue. The type <tt>Buffer</tt> must be a model of
|
||||
<a href="./Buffer.html">Buffer</a>.<br> The <tt>value_type</tt>
|
||||
of the buffer must be the <tt>vertex_descriptor</tt> type for the graph.<br>
|
||||
<b>Default:</b> <tt>boost::queue</tt><br>
|
||||
|
||||
<b>Python</b>: The buffer must derive from the <a
|
||||
href="./Buffer.html">Buffer</a> type for the graph.
|
||||
|
||||
</blockquote>
|
||||
|
||||
|
||||
<H3><A NAME="SECTION001330300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E + V)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>vis.initialize_vertex(v, g)</tt></b> is invoked on every vertex
|
||||
before the start of the search.
|
||||
|
||||
<li><b><tt>vis.examine_vertex(u, g)</tt></b>r is invoked in each
|
||||
vertex as it is removed from the queue.
|
||||
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b> is invoked on every out-edge
|
||||
of each vertex immediately after the vertex is removed from the queue.
|
||||
|
||||
<li><b><tt>vis.tree_edge(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>examine_edge()</tt>) if the edge is a tree edge. The
|
||||
target vertex of edge <tt>e</tt> is discovered at this time.
|
||||
|
||||
<li><b><tt>vis.discover_vertex(u, g)</tt></b> is invoked the first time the
|
||||
algorithm encounters vertex <i>u</i>. All vertices closer to the
|
||||
source vertex have been discovered, and vertices further from the
|
||||
source have not yet been discovered.
|
||||
|
||||
<li><b><tt>vis.non_tree_edge(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>examine_edge()</tt>) if the edge is not a tree edge.
|
||||
|
||||
<li><b><tt>vis.gray_target(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>non_tree_edge()</tt>) if the target vertex is colored gray at the
|
||||
time of examination. The color gray indicates that
|
||||
the vertex is currently in the queue.
|
||||
|
||||
<li><b><tt>vis.black_target(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>non_tree_edge()</tt>) if the target vertex is colored black at the
|
||||
time of examination. The color black indicates that the
|
||||
vertex is no longer in the queue.
|
||||
|
||||
<li><b><tt>vis.finish_vertex(u, g)</tt></b> is invoked after all of the out
|
||||
edges of <i>u</i> have been examined and all of the adjacent vertices
|
||||
have been discovered.
|
||||
|
||||
</ul>
|
||||
|
||||
<H3><A NAME="SECTION001330400000000000000">
|
||||
Example</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The example in <a
|
||||
href="../example/bfs-example.cpp"><TT>example/bfs-example.cpp</TT></a>
|
||||
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 file
|
||||
<a href="../example/bfs-example2.cpp"><TT>example/bfs-example2.cpp</TT></a>
|
||||
contains the same example, except that the <tt>adacency_list</tt>
|
||||
class used has <tt>VertexList</tt> and <tt>EdgeList</tt> set
|
||||
to <tt>listS</tt>.
|
||||
</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>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p><a name="1">[1]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,193 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000, 2001
|
||||
--
|
||||
-- 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 Visit</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:bfv"><img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>breadth_first_visit</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class P, class T, class R>
|
||||
void breadth_first_visit(IncidenceGraph& G,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
const bgl_named_params<P, T, R>& params);
|
||||
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./Buffer.html">Buffer</a>, class <a href="./BFSVisitor.html">BFSVisitor</a>, class ColorMap>
|
||||
void breadth_first_visit
|
||||
(const IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
</PRE>
|
||||
|
||||
This function is basically the same as <tt>breadth_first_search()</tt>
|
||||
except that the color markers are not initialized in the
|
||||
algorithm. The user is responsible for making sure the color for every
|
||||
vertex is white before calling the algorithm. With this difference,
|
||||
the graph type is only required to be an <a
|
||||
href="./IncidenceGraph.html">Incidence Graph</a> instead of a <a
|
||||
href="./VertexListGraph.html">Vertex List Graph</a>. Also, this
|
||||
difference allows for more flexibility in the color property map. For
|
||||
example, one could use a map that only implements a partial function
|
||||
on the vertices, which could be more space efficient when the search
|
||||
only reaches a small portion of the graph.
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/breadth_first_search.hpp"><TT>boost/graph/breadth_first_search.hpp</TT></a>
|
||||
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>IncidenceGraph& g</tt>
|
||||
<blockquote>
|
||||
A directed or undirected graph. The graph type must
|
||||
be a model of <a href="./IncidenceGraph.html">Incidence Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
<blockquote>
|
||||
The source vertex where the search is started.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>root_vertex</tt>.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>visitor(BFSVisitor vis)</tt>
|
||||
<blockquote>
|
||||
A visitor object that is invoked inside the algorithm at the
|
||||
event-points specified by the <a href="BFSVisitor.html">BFS
|
||||
Visitor</a> concept. The visitor object is passed by value <a
|
||||
href="#1">[1]</a>.<br> <b>Default:</b>
|
||||
<tt>bfs_visitor<null_visitor></tt><br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a href="BFSVisitor.html#python"><tt>BFSVisitor</tt></a> type of the graph.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>color_map(ColorMap color)</tt>
|
||||
<blockquote>
|
||||
This is used by the algorithm to keep track of its progress through
|
||||
the graph. The type <tt>ColorMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> and its key type must be the graph's vertex
|
||||
descriptor type and the value type of the color map must model
|
||||
<a href="./ColorValue.html">ColorValue</a>.<br>
|
||||
<b>Default:</b> <tt>get(vertex_color, g)</tt><br>
|
||||
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>buffer(Buffer& Q)</tt>
|
||||
<blockquote>
|
||||
The queue used to determine the order in which vertices will be
|
||||
discovered. If a FIFO queue is used, then the traversal will
|
||||
be according to the usual BFS ordering. Other types of queues
|
||||
can be used, but the traversal order will be different.
|
||||
For example Dijkstra's algorithm can be implemented
|
||||
using a priority queue. The type <tt>Buffer</tt> must be a model of
|
||||
<a href="./Buffer.html">Buffer</a>.<br>
|
||||
<b>Default:</b> <tt>boost::queue</tt><br>
|
||||
|
||||
<b>Python</b>: The buffer must derive from the <a
|
||||
href="./Buffer.html">Buffer</a> type for the graph.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<H3><A NAME="SECTION001330300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>vis.initialize_vertex(v, g)</tt></b> is invoked on every vertex
|
||||
before the start of the search.
|
||||
|
||||
<li><b><tt>vis.examine_vertex(u, g)</tt></b>r is invoked in each
|
||||
vertex as it is removed from the queue.
|
||||
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b> is invoked on every out-edge
|
||||
of each vertex immediately after the vertex is removed from the queue.
|
||||
|
||||
<li><b><tt>vis.tree_edge(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>examine_edge()</tt>) if the edge is a tree edge. The
|
||||
target vertex of edge <tt>e</tt> is discovered at this time.
|
||||
|
||||
<li><b><tt>vis.discover_vertex(u, g)</tt></b> is invoked the first time the
|
||||
algorithm encounters vertex <i>u</i>. All vertices closer to the
|
||||
source vertex have been discovered, and vertices further from the
|
||||
source have not yet been discovered.
|
||||
|
||||
<li><b><tt>vis.non_tree_edge(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>examine_edge()</tt>) if the edge is not a tree edge.
|
||||
|
||||
<li><b><tt>vis.gray_target(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>non_tree_edge()</tt>) if the target vertex is colored gray at the
|
||||
time of examination. The color gray indicates that
|
||||
the vertex is currently in the queue.
|
||||
|
||||
<li><b><tt>vis.black_target(e, g)</tt></b> is invoked (in addition to
|
||||
<tt>non_tree_edge()</tt>) if the target vertex is colored black at the
|
||||
time of examination. The color black indicates that the
|
||||
vertex is no longer in the queue.
|
||||
|
||||
<li><b><tt>vis.finish_vertex(u, g)</tt></b> is invoked after all of the out
|
||||
edges of <i>u</i> have been examined and all of the adjacent vertices
|
||||
have been discovered.
|
||||
|
||||
</ul>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./breadth_first_search.html"><tt>breadth_first_search()</tt></a>,
|
||||
<a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>, and
|
||||
<a href="./depth_first_search.html"><tt>depth_first_search()</tt></a>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p><a name="1">[1]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
178
doc/bundles.html
@@ -1,178 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<!--
|
||||
-- Copyright Doug Gregor 2004. Use, modification and
|
||||
-- distribution is subject to the Boost Software License, Version
|
||||
-- 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
-- http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
-- For more information, see http://www.boost.org
|
||||
-->
|
||||
<head>
|
||||
<title>Bundled Properties</title>
|
||||
</head>
|
||||
|
||||
<body BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86"/>
|
||||
<h1>Bundled Properties</h1>
|
||||
|
||||
<p>Class templates <code><a
|
||||
href="adjacency_list.html">adjacency_list</a></code> and
|
||||
<code><a href="adjacency_matrix.html">adjacency_matrix</a></code> support
|
||||
the introduction of named properties via <a
|
||||
href="using_adjacency_list.html#sec:adjacency-list-properties">internal
|
||||
properties</a>. However, this method is cumbersome in many uses,
|
||||
where it would be more intuitive to just specify a structure or
|
||||
class that contains internal properties for edges or
|
||||
vertices. Bundled properties allow one to use
|
||||
<code>adjacency_list</code> and <code>adjacency_matrix</code> in this
|
||||
manner, providing a simple
|
||||
way to introduce and access any number of internal properties
|
||||
for vertices and edges.</p>
|
||||
|
||||
<p>One can introduce bundled properties into an
|
||||
either graph type by providing a user-defined class
|
||||
type for the <code>VertexProperties</code> or
|
||||
<code>EdgeProperties</code> template arguments. The user-defined
|
||||
class may alternatively be placed at the end of a
|
||||
<code>property</code> list, replacing the (implicit)
|
||||
<code>boost::no_property</code> argument.</p>
|
||||
|
||||
<h2>Example: Route planning</h2>
|
||||
<p>Consider the implementation of a simple route planner that
|
||||
should find the shortest directions from one city to another
|
||||
via a set of highways. The vertices of the graph are cities,
|
||||
and we may wish to store several bits of information about the
|
||||
city within each vertex:</p>
|
||||
<pre>
|
||||
struct City
|
||||
{
|
||||
string name;
|
||||
int population;
|
||||
vector<int> zipcodes;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>The edges in the graph represent highways, which also have
|
||||
several interesting attributes:</p>
|
||||
|
||||
<pre>
|
||||
struct Highway
|
||||
{
|
||||
string name;
|
||||
double miles;
|
||||
int speed_limit;
|
||||
int lanes;
|
||||
bool divided;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>Without bundled properties, translating this example directly
|
||||
into an instantiation of <code>adjacency_list</code> would
|
||||
involve several custom properties and would result in a type
|
||||
like this:</p>
|
||||
<pre>
|
||||
typedef boost::adjacency_list<
|
||||
boost::listS, boost::vecS, boost::bidirectionalS,
|
||||
// Vertex properties
|
||||
boost::property<boost::vertex_name_t, std::string,
|
||||
boost::property<population_t, int,
|
||||
boost::property<zipcodes_t, std::vector<int> > > >,
|
||||
// Edge properties
|
||||
boost::property<boost::edge_name_t, std::string,
|
||||
boost::property<boost::edge_length_t, double,
|
||||
boost::property<edge_speed_limit_t, int,
|
||||
boost::property<edge_lanes_t, int,
|
||||
boost::property<edge_divided, bool> > > > > >
|
||||
Map;
|
||||
</pre>
|
||||
|
||||
<p>With bundled properties, we can directly use the
|
||||
<code>City</code> and <code>Highway</code> structures:</p>
|
||||
<pre>
|
||||
typedef boost::adjacency_list<
|
||||
boost::listS, boost::vecS, boost::bidirectionalS,
|
||||
City, Highway> Map;
|
||||
</pre>
|
||||
|
||||
<h2>Accessing bundled properties</h2>
|
||||
<p>To access a bundled property for a particular edge or vertex,
|
||||
subscript your graph with the descriptor of the edge or vertex
|
||||
whose bundled property you wish to access. For instance:</p>
|
||||
<pre>
|
||||
Map map; // load the map
|
||||
Map::vertex_descriptor v = *vertices(map).first;
|
||||
map[v].name = "Troy";
|
||||
map[v].population = 49170;
|
||||
map[v].zipcodes.push_back(12180);
|
||||
Map::edge_descriptor e = *out_edges(v, map).first;
|
||||
map[e].name = "I-87";
|
||||
map[e].miles = 10;
|
||||
map[e].speed_limit = 65;
|
||||
map[e].lanes = 4;
|
||||
map[e].divided = true;
|
||||
</pre>
|
||||
|
||||
<h2>Properties maps from bundled properties</h2>
|
||||
<p>Often one needs to create a property map from an internal
|
||||
property for use in a generic algorithm. For instance, using the
|
||||
graph without bundled properties we might invoke <a
|
||||
href="dijkstra_shortest_paths.html">Dijkstra's shortest
|
||||
paths</a> algorithm like this:</p>
|
||||
<pre>
|
||||
vector<double> distances(num_vertices(map));
|
||||
dijkstra_shortest_paths(map, from,
|
||||
weight_map(get(edge_length, map))
|
||||
.distance_map(make_iterator_property_map(distances.begin(),
|
||||
get(vertex_index, map))));
|
||||
</pre>
|
||||
|
||||
<p>With bundled properties, we can just pass a <em>member pointer</em>
|
||||
as the property for <code>get</code>. The equivalent example
|
||||
using bundled properties is:</p>
|
||||
<pre>
|
||||
vector<double> distances(num_vertices(map));
|
||||
dijkstra_shortest_paths(map, from,
|
||||
weight_map(get(<font color="#ff0000">&Highway::miles</font>, map))
|
||||
.distance_map(make_iterator_property_map(distances.begin(),
|
||||
get(vertex_index, map))));
|
||||
</pre>
|
||||
|
||||
<p>The type of the returned property map is <code>property_map<Map, int Highway::*>::type</code>
|
||||
or <code>property_map<Map, int Highway::*>::const_type</code>, depending on whether the graph
|
||||
<code>map</code> is non-constant or constant.
|
||||
|
||||
<p> You may also access the entire vertex or edge bundle as a property map
|
||||
using the <code>vertex_bundle</code> or <code>edge_bundle</code> properties,
|
||||
respectively. For instance, the property map returned by <code>get(vertex_bundle, map)</code> is
|
||||
an <a href="../../property_map/LvaluePropertyMap.html">Lvalue Property Map</a> providing access to the
|
||||
<code>City</code> values stored in each vertex.
|
||||
|
||||
<h2>Getting the type of bundled properties</h2>
|
||||
|
||||
<p>To get the type of the vertex or edge bundle for a given graph
|
||||
type <tt>Graph</tt>, you can use the trait
|
||||
classes <tt>vertex_bundle_type</tt>
|
||||
and <tt>edge_bundle_type</tt>. The
|
||||
type <tt>vertex_bundle_type<Graph>::type</tt> will be the
|
||||
type bundled with vertices (or <tt>no_vertex_bundle</tt> if the
|
||||
graph supports bundles but no vertex bundle
|
||||
exists). Likewise, <tt>edge_bundle_type<Graph>::type</tt>
|
||||
will be the type bundled with edges (or <tt>no_edge_bundle</tt> if
|
||||
no edge bundle exists).</p>
|
||||
|
||||
<h2>Compatibility</h2> <p>Bundled properties will only work
|
||||
properly on compilers that support class template partial
|
||||
specialization.</p>
|
||||
|
||||
<hr>
|
||||
Copyright © 2004 <a href="../../../people/doug_gregor.html">Doug Gregor</a>.
|
||||
<address><a href="mailto:gregod@cs.rpi.edu"></a></address>
|
||||
<!-- Created: Fri May 7 09:59:21 EDT 2004 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Fri May 7 10:56:01 EDT 2004
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,122 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<h2>Boost Graph Library Challenge and To-Do Items</h2>
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Dynamic graph algorithms such as described in <a
|
||||
href="http://citeseer.ist.psu.edu/eppstein99dynamic.html">Dynamic Graph
|
||||
Algorithms</a> and <a
|
||||
href="http://citeseer.ist.psu.edu/alberts98software.html">A Software
|
||||
Library of Dynamic Graph Algorithms</a>.
|
||||
|
||||
<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>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>disjoint_sets</tt> </li>
|
||||
</ul>
|
||||
|
||||
<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>Rewrite the Qhull algorithm using the Boost Graph Library (this is
|
||||
high difficulty challenge). Or, for a more manageable challenge,
|
||||
write an interface for Qhull with the BGL. <a
|
||||
href="http://www.geom.umn.edu/locate/qhull">Qhull</a> computes the
|
||||
convex hull, Delaunay triangulation, Voronoi diagram, and halfspace
|
||||
intersection about a point. Qhull runs in 2-d, 3-d, 4-d, and higher
|
||||
dimensions. Qhull is used for collision detection, animation, plate
|
||||
tectonics, 3-d modeling, robot motion planning, and other <a
|
||||
href="http://www.geom.umn.edu/~bradb/qhull-news.html#use">applications</a>.
|
||||
It is currently difficult to use from a C++ program.
|
||||
|
||||
</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. There are a few, but
|
||||
more are needed. The example provide a sanity check but do not
|
||||
provide full coverage.</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>
|
||||
|
||||
<li>Further testing of the <tt>subgraph</tt> class and add more
|
||||
features.</li>
|
||||
|
||||
<li>Implement a minimum-cost maximum-flow algorithm.</li>
|
||||
|
||||
<li>Make the <tt>type</tt> of all (internal) property maps convertible to the <tt>const_type</tt> of the property maps.<li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,44 +0,0 @@
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Function template circle_graph_layout</title></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table cellpadding="2" width="100%"><td valign="top"><img src="../../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td><td align="center"><a href="../../../index.htm">Home</a></td><td align="center"><a href="../../libraries.htm">Libraries</a></td><td align="center"><a href="../../../people/people.htm">People</a></td><td align="center"><a href="../../../more/faq.htm">FAQ</a></td><td align="center"><a href="../../../more/index.htm">More</a></td></table><hr><div class="refentry" lang="en"><a name="id103562-bb"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><img src="figs/python.gif" alt="(Python)"/><span class="refentrytitle">Function template circle_graph_layout</span></h2><p>boost::circle_graph_layout — Layout the graph with the vertices at the points of a regular n-polygon. </p></div><h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2><div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
|
||||
<span class="bold"><b>template</b></span><<span class="bold"><b>typename</b></span> VertexListGraph, <span class="bold"><b>typename</b></span> PositionMap, <span class="bold"><b>typename</b></span> Radius>
|
||||
<span class="type"><span class="bold"><b>void</b></span></span> circle_graph_layout(<span class="bold"><b>const</b></span> VertexListGraph & g, PositionMap position,
|
||||
Radius radius);</pre></div><div class="refsect1" lang="en"><a name="id821794"></a><h2>Where Defined</h2><a href="../../../boost/graph/circle_layout.hpp">boost/graph/circle_layout.hpp</a><h2>Description</h2><p>The distance from the center of the polygon to each point is determined by the <tt class="computeroutput">radius</tt> parameter. The <tt class="computeroutput">position</tt> parameter must be an Lvalue Property Map whose value type is a class type containing <tt class="computeroutput">x</tt> and <tt class="computeroutput">y</tt> members that will be set to the <tt class="computeroutput">x</tt> and <tt class="computeroutput">y</tt> coordinates.
|
||||
|
||||
<h2>Parameters</h2>
|
||||
IN: <tt>const VertexListGraph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied. The type
|
||||
<tt>VertexListGraph</tt> must be a model of <a
|
||||
href="VertexListGraph.html">Vertex List Graph</a>.<br>
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>PositionMap position</tt>
|
||||
<blockquote>
|
||||
This property map is used to store the position of each vertex. The
|
||||
type <tt>PositionMap</tt> must be a model of <a
|
||||
href="../../property_map/WritablePropertyMap.html">Writable Property
|
||||
Map</a>, with the graph's edge descriptor type as its key type. The
|
||||
value type of this property map should be assignable from the
|
||||
type <tt>Radius</tt>. <br>
|
||||
|
||||
<b>Python</b>: The position map must be a <tt>vertex_point2d_map</tt> for
|
||||
the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_vertex_point2d_map("position")</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Radius radius</tt>
|
||||
<blockquote>
|
||||
This is the radius of the circle on which points will be layed
|
||||
out. It must be compatible with <tt>double</tt>.<br>
|
||||
</blockquote>
|
||||
|
||||
</p></div></div><table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr><td align="left"></td><td align="right"><small></small></td></tr></table><hr>
|
||||
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<A HREF="../../../people/doug_gregor.html">Douglas Gregor</A>, Indiana University (dgregor -at- cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (lums -at- osl.iu.edu)
|
||||
</TD></TR></TABLE>
|
||||
</body></html>
|
||||
@@ -1,156 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2000-2001
|
||||
--
|
||||
-- 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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
|
||||
<H1>
|
||||
<A NAME="sec:connected-components">
|
||||
<img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>connected_components</TT></A>
|
||||
</H1>
|
||||
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template <class VertexListGraph, class ComponentMap, class P, class T, class R>
|
||||
typename property_traits<ComponentMap>::value_type
|
||||
connected_components(VertexListGraph& G, ComponentMap comp,
|
||||
const bgl_named_params<P, T, R>& params = <i>all defaults</i>);
|
||||
|
||||
<i>// there is not a non-named parameter version of this function</i>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <TT>connected_components()</TT> functions compute the connected
|
||||
components of an undirected graph using a DFS-based approach. A
|
||||
<b><I>connected component</I></b> of an undirected graph is a set of
|
||||
vertices that are all reachable from each other. If the connected
|
||||
components need to be maintained while a graph is growing the
|
||||
disjoint-set based approach of function <a
|
||||
href="./incremental_components.html">
|
||||
<TT>incremental_components()</TT></a> is faster. For ``static'' graphs
|
||||
this DFS-based approach is faster [<A
|
||||
HREF="bibliography.html#clr90">8</A>].
|
||||
|
||||
<P>
|
||||
The output of the algorithm is recorded in the component property map
|
||||
<TT>comp</TT>, which will contain numbers giving the component number
|
||||
assigned to each vertex. The total number of components is the return
|
||||
value of the function.
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/connected_components.hpp"><TT>boost/graph/connected_components.hpp</TT></a>
|
||||
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
An undirected graph. The graph type must be a model of <a
|
||||
href="VertexListGraph.html">Vertex List Graph</a> and <a
|
||||
href="IncidenceGraph.html">Incidence Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>ComponentMap c</tt>
|
||||
<blockquote>
|
||||
The algorithm computes how many connected components are in the graph,
|
||||
and assigning each component an integer label. The algorithm then
|
||||
records which component each vertex in the graph belongs to by
|
||||
recording the component number in the component property map. The
|
||||
<tt>ComponentMap</tt> type must be a model of <a
|
||||
href="../../property_map/WritablePropertyMap.html">Writable Property
|
||||
Map</a>. The value type shouch be an integer type, preferably the same
|
||||
as the <tt>vertices_size_type</tt> of the graph. The key type must be
|
||||
the graph's vertex descriptor type.<br>
|
||||
|
||||
<b>Python</b>: Must be an <tt>vertex_int_map</tt> for the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_vertex_int_map("component")</tt>
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
UTIL: <tt>color_map(ColorMap color)</tt>
|
||||
<blockquote>
|
||||
This is used by the algorithm to keep track of its progress through
|
||||
the graph. The type <tt>ColorMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> and its key type must be the graph's vertex
|
||||
descriptor type and the value type of the color map must model
|
||||
<a href="./ColorValue.html">ColorValue</a>.<br>
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>default_color_type</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.<br>
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This parameter is only necessary when the
|
||||
default color property map is used. The type <tt>VertexIndexMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>. The value type of the map must be an integer type. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the map.<br>
|
||||
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity for the connected components algorithm is also
|
||||
<i>O(V + E)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./strong_components.html"><tt>strong_components()</tt></a>
|
||||
and <a href="./incremental_components.html"><tt>incremental_components()</tt></a>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
The file <a
|
||||
href="../example/connected_components.cpp"><tt>examples/connected_components.cpp</tt></a>
|
||||
contains an example of calculating the connected components of an
|
||||
undirected graph.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,187 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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_check/concept_check.htm">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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,116 +0,0 @@
|
||||
<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: Copy Graph</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><TT>copy_graph</TT></H1>
|
||||
|
||||
<PRE>
|
||||
template <class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./MutableGraph.html">MutableGraph</a>>
|
||||
void copy_graph(const VertexListGraph& G, MutableGraph& G_copy,
|
||||
const bgl_named_params<P, T, R>& params = <i>all defaults</i>)
|
||||
</PRE>
|
||||
|
||||
This function copies all of the vertices and edges from graph
|
||||
<tt>G</tt> into <tt>G_copy</tt>. Also, it copies the vertex and edge
|
||||
properties, either by using the <tt>vertex_all</tt> and
|
||||
<tt>edge_all</tt> property maps, or by user-supplied copy functions.
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/copy.hpp"><TT>boost/graph/copy.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<H3>Parameters</H3>
|
||||
|
||||
IN: <tt>const VertexListGraph& G</tt>
|
||||
<blockquote>
|
||||
A directed or undirected graph. The graph type must be a model of <a href="./VertexListGraph.html">Vertex List Graph</a>.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>MutableGraph& G_copy</tt>
|
||||
<blockquote>
|
||||
The resulting copy of the graph. The graph type must be a model of <a
|
||||
href="./MutableGraph.html">Mutable Graph</a>.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>vertex_copy(VertexCopier vc)</tt>
|
||||
<blockquote>
|
||||
This is a <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> that copies the properties of a vertex in the original graph
|
||||
into the corresponding vertex in the copy.<br>
|
||||
|
||||
<b>Default:</b> <tt>vertex_copier<VertexListGraph, MutableGraph></tt>
|
||||
which uses the property tag <tt>vertex_all</tt> to access a property
|
||||
map from the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>edge_copy(EdgeCopier ec)</tt>
|
||||
<blockquote>
|
||||
This is a <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> that copies the properties of an edge in the original graph
|
||||
into the corresponding edge in the copy.<br>
|
||||
|
||||
<b>Default:</b> <tt>edge_copier<VertexListGraph, MutableGraph></tt>
|
||||
which uses the property tag <tt>edge_all</tt> to access a property
|
||||
map from the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
The vertex index map type must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">Readable Property
|
||||
Map</a> and must map the vertex descriptors of <tt>G</tt> to the
|
||||
integers from 0 to <tt>num_vertices(G)</tt>.<br>
|
||||
|
||||
<b>Default:</b> <tt>get(vertex_index, G)</tt>
|
||||
</blockquote>
|
||||
|
||||
|
||||
UTIL/OUT: <tt>orig_to_copy(Orig2CopyMap c)</tt>
|
||||
<blockquote>
|
||||
This maps vertices in the original graph to vertices in the copy.
|
||||
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of the output graph's vertex descriptor type of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.
|
||||
</blockquote>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(V + E)</i>.
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,251 +0,0 @@
|
||||
<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: Cuthill-Mckee Ordering</Title>
|
||||
</Head>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>cuthill_mckee_ordering</TT>
|
||||
</H1>
|
||||
|
||||
|
||||
<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">color, degree</TD>
|
||||
</TR>
|
||||
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
|
||||
<TD ALIGN="LEFT">time: <i>O(m log(m)|V|)</i> where <i>m = max { degree(v) | v in V }</i> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
|
||||
<pre>
|
||||
(1)
|
||||
template <class IncidenceGraph, class OutputIterator,
|
||||
class ColorMap, class DegreeMap>
|
||||
OutputIterator
|
||||
cuthill_mckee_ordering(const IncidenceGraph& g,
|
||||
typename graph_traits<Graph>::vertex_descriptor s,
|
||||
OutputIterator inverse_permutation,
|
||||
ColorMap color, DegreeMap degree)
|
||||
|
||||
(2)
|
||||
template <class VertexListGraph, class OutputIterator>
|
||||
OutputIterator
|
||||
cuthill_mckee_ordering(const VertexIndexMap& G, OutputIterator inverse_permutation);
|
||||
|
||||
template <class VertexListGraph, class OutputIterator, class VertexIndexMap>
|
||||
OutputIterator
|
||||
cuthill_mckee_ordering(const VertexIndexMap& G, OutputIterator inverse_permutation,
|
||||
VertexIndexMap index_map);
|
||||
|
||||
template <class VertexListGraph, class OutputIterator,
|
||||
class ColorMap, class DegreeMap>
|
||||
OutputIterator
|
||||
cuthill_mckee_ordering(const VertexListGraph& G, OutputIterator inverse_permutation,
|
||||
ColorMap color, DegreeMap degree)
|
||||
|
||||
(3)
|
||||
template <class IncidenceGraph, class OutputIterator,
|
||||
class ColorMap, class DegreeMap>
|
||||
OutputIterator
|
||||
cuthill_mckee_ordering(const IncidenceGraph& g,
|
||||
std::deque< typename
|
||||
graph_traits<Graph>::vertex_descriptor > vertex_queue,
|
||||
OutputIterator inverse_permutation,
|
||||
ColorMap color, DegreeMap degree)
|
||||
</pre>
|
||||
|
||||
The goal of the Cuthill-Mckee (and reverse Cuthill-Mckee) ordering
|
||||
algorithm[<A
|
||||
HREF="bibliography.html#george81:__sparse_pos_def">14</A>, <A
|
||||
HREF="bibliography.html#cuthill69:reducing_bandwith">43</A>, <a
|
||||
href="bibliography.html#liu75:anal_cm_rcm">44</a>, <a
|
||||
href="bibliography.html#george71:fem">45</a> ] is to reduce the <a
|
||||
href="./bandwidth.html">bandwidth</a> of a graph by reordering the
|
||||
indices assigned to each vertex. The Cuthill-Mckee ordering algorithm
|
||||
works by a local minimization of the i-th bandwidths. The vertices are
|
||||
basically assigned a breadth-first search order, except that at each
|
||||
step, the adjacent vertices are placed in the queue in order of
|
||||
increasing degree.
|
||||
|
||||
<p>
|
||||
Version 1 of the algorithm lets the user choose the ``starting
|
||||
vertex'', version 2 finds a good starting vertex using the
|
||||
pseudo-peripheral pair heuristic (among each component), while version 3
|
||||
contains the starting nodes for each vertex in the deque. The choice of the
|
||||
``starting vertex'' can have a significant effect on the quality of the
|
||||
ordering. For versions 2 and 3, <tt>find_starting_vertex</tt> will be called
|
||||
for each component in the graph, increasing run time significantly.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The output of the algorithm are the vertices in the new ordering.
|
||||
Depending on what kind of output iterator you use, you can get either
|
||||
the Cuthill-Mckee ordering or the reverse Cuthill-McKee ordering. For
|
||||
example, if you store the output into a vector using the vector's
|
||||
reverse iterator, then you get the reverse Cuthill-McKee ordering.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
std::vector<vertex_descriptor> inv_perm(num_vertices(G));
|
||||
cuthill_mckee_ordering(G, inv_perm.rbegin(), ...);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Either way, storing the output into a vector gives you the
|
||||
permutation from the new ordering to the old ordering.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
inv_perm[new_index[u]] == u
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Often times, it is the opposite permutation that you want, the
|
||||
permutation from the old index to the new index. This can easily be
|
||||
computed in the following way.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
for (size_type i = 0; i != inv_perm.size(); ++i)
|
||||
perm[old_index[inv_perm[i]]] = i;
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
For version 1:
|
||||
|
||||
<ul>
|
||||
|
||||
<li> <tt>IncidenceGraph& g</tt> (IN) <br>
|
||||
An undirected graph. The graph's type must be a model of <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
|
||||
<li> <tt>vertex_descriptor s</tt>  (IN) <br>
|
||||
The starting vertex.<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
|
||||
<li> <tt>OutputIterator inverse_permutation</tt>  (OUT) <br>
|
||||
The new vertex ordering. The vertices are written to the <a
|
||||
href="http://www.sgi.com/tech/stl/OutputIterator.html">output
|
||||
iterator</a> in their new order.<br>
|
||||
<b>Python</b>: This parameter is unused in Python. The new vertex
|
||||
ordering is returned as a Python <tt>list</tt>.
|
||||
|
||||
<li> <tt>ColorMap color_map</tt>  (WORK) <br>
|
||||
Used internally to keep track of the progress of the algorithm
|
||||
(to avoid visiting the same vertex twice).<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
|
||||
<li> <tt>DegreeMap degree_map</tt>  (IN) <br>
|
||||
This must map vertices to their degree.<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</ul>
|
||||
|
||||
|
||||
For version 2:
|
||||
|
||||
<ul>
|
||||
|
||||
<li> <tt>VertexListGraph& g</tt> (IN) <br>
|
||||
An undirected graph. The graph's type must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a>.<br>
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
|
||||
<li> <tt><a href="http://www.sgi.com/tech/stl/OutputIterator.html">
|
||||
OutputIterator</a> inverse_permutation</tt>  (OUT) <br>
|
||||
The new vertex ordering. The vertices are written to the
|
||||
output iterator in their new order.<br>
|
||||
<b>Python</b>: This parameter is unused in Python. The new vertex
|
||||
ordering is returned as a Python <tt>list</tt>.
|
||||
|
||||
<li> <tt>ColorMap color_map</tt>  (WORK) <br>
|
||||
Used internally to keep track of the progress of the algorithm
|
||||
(to avoid visiting the same vertex twice).<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
|
||||
<li> <tt>DegreeMap degree_map</tt>  (IN) <br>
|
||||
This must map vertices to their degree.<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</ul>
|
||||
|
||||
|
||||
For version 3:
|
||||
|
||||
<ul>
|
||||
|
||||
<li> <tt>IncidenceGraph& g</tt> (IN) <br>
|
||||
An undirected graph. The graph's type must be a model of <a
|
||||
href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
|
||||
<li> <tt> std::deque< typename graph_traits<Graph>::vertex_descriptor > vertex_queue </tt>  (IN) <br>
|
||||
The deque containing the starting vertices for each component.<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
|
||||
<li> <tt>OutputIterator inverse_permutation</tt>  (OUT) <br>
|
||||
The new vertex ordering. The vertices are written to the <a
|
||||
href="http://www.sgi.com/tech/stl/OutputIterator.html">output
|
||||
iterator</a> in their new order.<br>
|
||||
<b>Python</b>: This parameter is unused in Python. The new vertex
|
||||
ordering is returned as a Python <tt>list</tt>.
|
||||
|
||||
<li> <tt>ColorMap color_map</tt>  (WORK) <br>
|
||||
Used internally to keep track of the progress of the algorithm
|
||||
(to avoid visiting the same vertex twice).<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
|
||||
<li> <tt>DegreeMap degree_map</tt>  (IN) <br>
|
||||
This must map vertices to their degree.<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
See <a
|
||||
href="../example/cuthill_mckee_ordering.cpp"><tt>example/cuthill_mckee_ordering.cpp</tt></a>.
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./bandwidth.html">bandwidth</tt></a>,
|
||||
and <tt>degree_property_map</tt> in <tt>boost/graph/properties.hpp</tt>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,326 +0,0 @@
|
||||
<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: Directed Acyclic Graph Shortest Paths</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:dag_shortest_paths"></A>
|
||||
<img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>dag_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named paramter version</i>
|
||||
template <class VertexListGraph, class Param, class Tag, class Rest>
|
||||
void dag_shortest_paths(const VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
const bgl_named_params<Param,Tag,Rest>& params)
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <class VertexListGraph, class DijkstraVisitor,
|
||||
class DistanceMap, class WeightMap, class ColorMap,
|
||||
class PredecessorMap,
|
||||
class Compare, class Combine,
|
||||
class DistInf, class DistZero>
|
||||
void dag_shortest_paths(const VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
DistanceMap distance, WeightMap weight, ColorMap color,
|
||||
PredecessorMap pred, DijkstraVisitor vis,
|
||||
Compare compare, Combine combine, DistInf inf, DistZero zero)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This algorithm [<A HREF="bibliography.html#clr90">8</A>] solves
|
||||
the single-source shortest-paths problem on a weighted, directed
|
||||
acyclic graph (DAG). This algorithm is more efficient for DAG's
|
||||
than either the Dijkstra or Bellman-Ford algorithm.
|
||||
Use breadth-first search instead of this algorithm
|
||||
when all edge weights are equal to one. For the definition of the
|
||||
shortest-path problem see Section <A
|
||||
HREF="graph_theory_review.html#sec:shortest-paths-algorithms">Shortest-Paths
|
||||
Algorithms</A> for some background to the shortest-path problem.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
There are two main options for obtaining output from the
|
||||
<tt>dag_shortest_paths()</tt> function. If you provide a
|
||||
distance property map through the <tt>distance_map()</tt> parameter
|
||||
then the shortest distance from the source vertex to every other
|
||||
vertex in the graph will be recorded in the distance map. Also you can
|
||||
record the shortest paths tree in a predecessor map: for each vertex
|
||||
<i>u in V</i>, <i>p[u]</i> will be the predecessor of <i>u</i> in
|
||||
the shortest paths tree (unless <i>p[u] = u</i>, in which case <i>u</i> is
|
||||
either the source or a vertex unreachable from the source). In
|
||||
addition to these two options, the user can provide there own
|
||||
custom-made visitor that can takes actions during any of the
|
||||
algorithm's event points.</P>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/dag_shortest_paths.hpp"><tt>boost/graph/dag_shortest_paths.hpp</tt></a>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>const VertexListGraph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied.
|
||||
The type <tt>VertexListGraph</tt> must be a model of \concept{VertexListGraph}.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
<blockquote>
|
||||
The source vertex. All distance will be calculated from this vertex,
|
||||
and the shortest paths tree will be rooted at this vertex.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>root_vertex</tt>.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>weight_map(WeightMap w_map)</tt>
|
||||
<blockquote>
|
||||
The weight or ``length'' of each edge in the graph.
|
||||
The type <tt>WeightMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</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.<br>
|
||||
<b>Default:</b> <tt>get(edge_weight, g)</tt><br>
|
||||
<b>Python</b>: Must be an <tt>edge_double_map</tt> for the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_edge_double_map("weight")</tt>
|
||||
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This is necessary for efficient updates of the
|
||||
heap data structure when an edge is relaxed. The type
|
||||
<tt>VertexIndexMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The value type of the map must be an
|
||||
integer type. The vertex descriptor type of the graph needs to be
|
||||
usable as the key type of the map.<br>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>predecessor_map(PredecessorMap p_map)</tt>
|
||||
<blockquote>
|
||||
The predecessor map records the edges in the minimum spanning
|
||||
tree. Upon completion of the algorithm, the edges <i>(p[u],u)</i>
|
||||
for all <i>u in V</i> are in the minimum spanning tree. If <i>p[u] =
|
||||
u</i> then <i>u</i> is either the source vertex or a vertex that is
|
||||
not reachable from the source. The <tt>PredecessorMap</tt> type
|
||||
must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> which key and vertex types the same as the vertex
|
||||
descriptor type of the graph.<br>
|
||||
<b>Default:</b> <tt>dummy_property_map</tt><br>
|
||||
<b>Python</b>: Must be a <tt>vertex_vertex_map</tt> for the graph.<br>
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>distance_map(DistanceMap d_map)</tt>
|
||||
<blockquote>
|
||||
The shortest path weight from the source vertex <tt>s</tt> to each
|
||||
vertex in the graph <tt>g</tt> is recorded in this property map. The
|
||||
shortest path weight is the sum of the edge weights along the
|
||||
shortest path. The type <tt>DistanceMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</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 is the element type of a <a
|
||||
href="./Monoid.html">Monoid</tt> formed with the <tt>combine</tt>
|
||||
function object and the <tt>zero</tt> object for the identity
|
||||
element. Also the distance value type must have a <a
|
||||
href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
StrictWeakOrdering</a> provided by the <tt>compare</tt> function
|
||||
object.<br>
|
||||
<b>Default:</b> <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of the <tt>WeightMap</tt>'s value type of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.<br>
|
||||
|
||||
<b>Python</b>: Must be a <tt>vertex_double_map</tt> for the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_compare(CompareFunction cmp)</tt>
|
||||
<blockquote>
|
||||
This function is use to compare distances to determine which vertex
|
||||
is closer to the source vertex. The <tt>CompareFunction</tt> type
|
||||
must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryPredicate.html">Binary
|
||||
Predicate</a> and have argument types that match the value type of
|
||||
the <tt>DistanceMap</tt> property map.<br>
|
||||
|
||||
<b>Default:</b>
|
||||
<tt>std::less<D></tt> with <tt>D=typename
|
||||
property_traits<DistanceMap>::value_type</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_combine(CombineFunction cmb)</tt>
|
||||
<blockquote>
|
||||
This function is used to combine distances to compute the distance
|
||||
of a path. The <tt>CombineFunction</tt> type must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary
|
||||
Function</a>. The first argument type of the binary function must
|
||||
match the value type of the <tt>DistanceMap</tt> property map and
|
||||
the second argument type must match the value type of the
|
||||
<tt>WeightMap</tt> property map. The result type must be the same
|
||||
type as the distance value type.<br>
|
||||
|
||||
<b>Default:</b> <tt>std::plus<D></tt> with
|
||||
<tt>D=typename property_traits<DistanceMap>::value_type</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_inf(D inf)</tt>
|
||||
<blockquote>
|
||||
The <tt>inf</tt> object must be the greatest value of any <tt>D</tt> object.
|
||||
That is, <tt>compare(d, inf) == true</tt> for any <tt>d != inf</tt>.
|
||||
The type <tt>D</tt> is the value type of the <tt>DistanceMap</tt>.<br>
|
||||
<b>Default:</b> <tt>std::numeric_limits<D>::max()</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_zero(D zero)</tt>
|
||||
<blockquote>
|
||||
The <tt>zero</tt> value must be the identity element for the
|
||||
<a href="./Monoid.html">Monoid</a> formed by the distance values
|
||||
and the <tt>combine</tt> function object.
|
||||
The type \code{D} is the value type of the \code{DistanceMap}
|
||||
<b>Default:</b> <tt>D()</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>color_map(ColorMap c_map)</tt>
|
||||
<blockquote>
|
||||
This is used during the execution of the algorithm to mark the
|
||||
vertices. The vertices start out white and become gray when they are
|
||||
inserted in the queue. They then turn black when they are removed
|
||||
from the queue. At the end of the algorithm, vertices reachable from
|
||||
the source vertex will have been colored black. All other vertices
|
||||
will still be white. The type <tt>ColorMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</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">Color Value</a>.<br>
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a <tt>std::vector</tt>
|
||||
of <tt>default_color_type</tt> of size <tt>num_vertices(g)</tt> and
|
||||
using the <tt>i_map</tt> for the index map.<br>
|
||||
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>visitor(DijkstraVisitor v)</tt>
|
||||
<blockquote>
|
||||
Use this to specify actions that you would like to happen
|
||||
during certain event points within the algorithm.
|
||||
The type <tt>DijkstraVisitor</tt> must be a model of the
|
||||
<a href="./DijkstraVisitor.html">Dijkstra Visitor</a> concept.
|
||||
The visitor object is passed by value <a
|
||||
href="#1">[1]</a>.<br>
|
||||
<b>Default:</b> <tt>dijkstra_visitor<null_visitor></tt><br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a
|
||||
href="DijkstraVisitor.html#python"><tt>DijkstraVisitor</tt></a> type
|
||||
of the graph.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(V + E)</i>.
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>vis.initialize_vertex(u, g)</tt></b>
|
||||
is invoked on each vertex in the graph before the start of the
|
||||
algorithm.
|
||||
<li><b><tt>vis.examine_vertex(u, g)</tt></b>
|
||||
is invoked on a vertex as it is added to set <i>S</i>.
|
||||
At this point we know that <i>(p[u],u)</i>
|
||||
is a shortest-paths tree edge so
|
||||
<i>d[u] = delta(s,u) = d[p[u]] + w(p[u],u)</i>. Also, the distances
|
||||
of the examined vertices is monotonically increasing
|
||||
<i>d[u<sub>1</sub>] <= d[u<sub>2</sub>] <= d[u<sub>n</sub>]</i>.
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b>
|
||||
is invoked on each out-edge of a vertex immediately after it has
|
||||
been added to set <i>S</i>.
|
||||
<li><b><tt>vis.edge_relaxed(e, g)</tt></b>
|
||||
is invoked on edge <i>(u,v)</i> if <i>d[u] + w(u,v) < d[v]</i>.
|
||||
The edge <i>(u,v)</i> that participated in the last
|
||||
relaxation for vertex <i>v</i> is an edge in the shortest paths tree.
|
||||
<li><b><tt>vis.discover_vertex(v, g)</tt></b>
|
||||
is invoked on vertex <i>v</i> when the edge
|
||||
<i>(u,v)</i> is examined and <i>v</i> is WHITE. Since
|
||||
a vertex is colored GRAY when it is discovered,
|
||||
each reacable vertex is discovered exactly once.
|
||||
<li><b><tt>vis.edge_not_relaxed(e, g)</tt></b>
|
||||
is invoked if the edge is not relaxed (see above).
|
||||
<li><b><tt>vis.finish_vertex(u, g)</tt></b>
|
||||
is invoked on a vertex after all of its out edges have
|
||||
been examined.
|
||||
</ul>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
See <a href="../example/dag_shortest_paths.cpp">
|
||||
<TT>example/dag_shortest_paths.cpp</TT></a> for an example of using this
|
||||
algorithm.
|
||||
|
||||
<H3>Notes</H3>
|
||||
|
||||
<p><a name="1">[1]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
224
doc/default.css
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
:Author: David Goodger
|
||||
:Contact: goodger@users.sourceforge.net
|
||||
:date: $Date$
|
||||
:version: $Revision$
|
||||
:copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
*/
|
||||
|
||||
.first {
|
||||
margin-top: 0 }
|
||||
|
||||
.last {
|
||||
margin-bottom: 0 }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.attention, div.caution, div.danger, div.error, div.hint,
|
||||
div.important, div.note, div.tip, div.warning, div.admonition {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.hint p.admonition-title, div.important p.admonition-title,
|
||||
div.note p.admonition-title, div.tip p.admonition-title,
|
||||
div.admonition p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
font-size: smaller }
|
||||
|
||||
div.sidebar {
|
||||
margin-left: 1em ;
|
||||
border: medium outset ;
|
||||
padding: 0em 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr {
|
||||
width: 75% }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font-family: serif ;
|
||||
font-size: 100% }
|
||||
|
||||
pre.line-block {
|
||||
font-family: serif ;
|
||||
font-size: 100% }
|
||||
|
||||
pre.literal-block, pre.doctest-block {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em ;
|
||||
background-color: #eeeeee }
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.option-argument {
|
||||
font-style: italic }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
table {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.citation {
|
||||
border-left: solid thin gray ;
|
||||
padding-left: 0.5ex }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid thin black ;
|
||||
padding-left: 0.5ex }
|
||||
|
||||
td, th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
th.docinfo-name, th.field-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap }
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
font-size: 100% }
|
||||
|
||||
tt {
|
||||
background-color: #eeeeee }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
@@ -1,314 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:depth-first-search"></A><img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>depth_first_search</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template <class Graph, class class P, class T, class R>
|
||||
void depth_first_search(Graph& G,
|
||||
const bgl_named_params<P, T, R>& params);
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <class Graph, class <a href="DFSVisitor.html">DFSVisitor</a>, class ColorMap>
|
||||
void depth_first_search(const Graph& g, DFSVisitor vis, ColorMap color)
|
||||
|
||||
template <class Graph, class <a href="DFSVisitor.html">DFSVisitor</a>, class ColorMap>
|
||||
void depth_first_search(const Graph& g, DFSVisitor vis, ColorMap color,
|
||||
typename graph_traits<Graph>::vertex_descriptor start)
|
||||
|
||||
</PRE>
|
||||
|
||||
<p>
|
||||
The <tt>depth_first_search()</tt> function performs a depth-first
|
||||
traversal of the vertices in a directed graph. When
|
||||
possible, a depth-first traversal chooses a vertex adjacent to the
|
||||
current vertex to visit next. If all adjacent vertices have already
|
||||
been discovered, or there are no adjacent vertices, then the algorithm
|
||||
backtracks to the last vertex that had undiscovered neighbors. Once
|
||||
all reachable vertices have been visited, the algorithm selects from
|
||||
any remaining undiscovered vertices and continues the traversal. The
|
||||
algorithm finishes when all vertices have been visited. Depth-first
|
||||
search is useful for categorizing edges in a graph, and for imposing
|
||||
an ordering on the vertices. Section <a
|
||||
href="./graph_theory_review.html#sec:dfs-algorithm">Depth-First
|
||||
Search</a> describes the various properties of DFS and walks through
|
||||
an example.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Similar to BFS, color markers are used to keep track of which vertices
|
||||
have been discovered. White marks vertices that have yet to be
|
||||
discovered, gray marks a vertex that is discovered but still has
|
||||
vertices adjacent to it that are undiscovered. A black vertex is
|
||||
discovered vertex that is not adjacent to any white vertices.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
The <tt>depth_first_search()</tt> function invokes user-defined
|
||||
actions at certain event-points within the algorithm. This provides a
|
||||
mechanism for adapting the generic DFS algorithm to the many
|
||||
situations in which it can be used. In the pseudo-code below, the
|
||||
event points for DFS are indicated in by the triangles and labels on
|
||||
the right. The user-defined actions must be provided in the form of a
|
||||
visitor object, that is, an object whose type meets the requirements
|
||||
for a <a href="./DFSVisitor.html">DFS Visitor</a>. In the pseudo-code
|
||||
we show the algorithm computing predecessors <i>p</i>, discover time
|
||||
<i>d</i> and finish time <i>t</i>. By default, the
|
||||
<tt>depth_first_search()</tt> function does not compute these
|
||||
properties, however there are pre-defined visitors such as <a
|
||||
href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>
|
||||
and <a href="./time_stamper.html"><tt>time_stamper</tt></a> that can
|
||||
be used to do this.
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
DFS(<i>G</i>)
|
||||
<b>for</b> each vertex <i>u in V</i>
|
||||
<i>color[u] :=</i> WHITE
|
||||
<i>p[u] = u</i>
|
||||
<b>end for</b>
|
||||
<i>time := 0</i>
|
||||
<b>if</b> there is a starting vertex <i>s</i>
|
||||
<b>call</b> DFS-VISIT(<i>G</i>, <i>s</i>)
|
||||
<b>for</b> each vertex <i>u in V</i>
|
||||
<b>if</b> <i>color[u] =</i> WHITE
|
||||
<b>call</b> DFS-VISIT(<i>G</i>, <i>u</i>)
|
||||
<b>end for</b>
|
||||
return (<i>p</i>,<i>d_time</i>,<i>f_time</i>) <br>
|
||||
DFS-VISIT(<i>G</i>, <i>u</i>)
|
||||
<i>color[u] :=</i> GRAY
|
||||
<i>d_time[u] := time := time + 1</i>
|
||||
<b>for</b> each <i>v in Adj[u]</i>
|
||||
<b>if</b> (<i>color[v] =</i> WHITE)
|
||||
<i>p[v] = u</i>
|
||||
<b>call</b> DFS-VISIT(<i>G</i>, <i>v</i>)
|
||||
<b>else if</b> (<i>color[v] =</i> GRAY)
|
||||
<i>...</i>
|
||||
<b>else if</b> (<i>color[v] =</i> BLACK)
|
||||
<i>...</i>
|
||||
<b>end for</b>
|
||||
<i>color[u] :=</i> BLACK
|
||||
<i>f_time[u] := time := time + 1</i>
|
||||
<pre>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
-
|
||||
-
|
||||
initialize vertex <i>u</i>
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
start vertex <i>s</i>
|
||||
-
|
||||
-
|
||||
start vertex <i>u</i>
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
discover vertex <i>u</i>
|
||||
-
|
||||
examine edge <i>(u,v)</i>
|
||||
-
|
||||
<i>(u,v)</i> is a tree edge
|
||||
-
|
||||
-
|
||||
<i>(u,v)</i> is a back edge
|
||||
-
|
||||
<i>(u,v)</i> is a cross or forward edge
|
||||
-
|
||||
finish vertex <i>u</i>
|
||||
-
|
||||
</pre>
|
||||
</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>Parameters</h3>
|
||||
|
||||
IN: <tt>Graph& g</tt>
|
||||
<blockquote>
|
||||
A directed graph. The graph type must
|
||||
be a model of <a href="./IncidenceGraph.html">Incidence Graph</a>
|
||||
and <a href="./VertexListGraph.html">Vertex List Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>visitor(DFSVisitor vis)</tt>
|
||||
<blockquote>
|
||||
A visitor object that is invoked inside the algorithm at the
|
||||
event-points specified by the <a href="./DFSVisitor.html">DFS
|
||||
Visitor</a> concept. The visitor object is passed by value <a
|
||||
href="#1">[1]</a>. <br> <b>Default:</b>
|
||||
<tt>dfs_visitor<null_visitor></tt><br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a href="DFSVisitor.html#python"><tt>DFSVisitor</tt></a> type of
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>color_map(ColorMap color)</tt>
|
||||
<blockquote>
|
||||
This is used by the algorithm to keep track of its progress through
|
||||
the graph. The type <tt>ColorMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> and its key type must be the graph's vertex
|
||||
descriptor type and the value type of the color map must model
|
||||
<a href="./ColorValue.html">ColorValue</a>.<br>
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
</tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of <tt>default_color_type</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.<br>
|
||||
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>root_vertex(typename
|
||||
graph_traits<VertexListGraph>::vertex_descriptor start)</tt>
|
||||
<blockquote>
|
||||
This specifies the vertex that the depth-first search should
|
||||
originate from. The type is the type of a vertex descriptor for the
|
||||
given graph.<br>
|
||||
<b>Default:</b> <tt>*vertices(g).first</tt><br>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This parameter is only necessary when the
|
||||
default color property map is used. The type <tt>VertexIndexMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>. The value type of the map must be an integer type. The
|
||||
vertex descriptor type of the graph needs to be usable as the key
|
||||
type of the map.<br>
|
||||
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION001340300000000000000">
|
||||
Complexity</A>
|
||||
</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(E + V)</i>.
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><b><tt>vis.initialize_vertex(s, g)</tt></b> is invoked on every
|
||||
vertex of the graph before the start of the graph search.
|
||||
|
||||
<li><b><tt>vis.start_vertex(s, g)</tt></b> is invoked on the source
|
||||
vertex once before the start of the search.
|
||||
|
||||
<li><b><tt>vis.discover_vertex(u, g)</tt></b> is invoked when a vertex
|
||||
is encountered for the first time.
|
||||
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b> is invoked on every out-edge
|
||||
of each vertex after it is discovered.
|
||||
|
||||
<li><b><tt>vis.tree_edge(e, g)</tt></b> is invoked on each edge as it
|
||||
becomes a member of the edges that form the search tree. If you
|
||||
wish to record predecessors, do so at this event point.
|
||||
|
||||
<li><b><tt>vis.back_edge(e, g)</tt></b> is invoked on the back edges in
|
||||
the graph.
|
||||
|
||||
<li><b><tt>vis.forward_or_cross_edge(e, g)</tt></b> is invoked on
|
||||
forward or cross edges in the graph. In an undirected graph this
|
||||
method is never called.
|
||||
|
||||
<li><b><tt>vis.finish_vertex(u, g)</tt></b> is 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).
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
The example in <a href="../example/dfs-example.cpp">
|
||||
<TT>examples/dfs-example.cpp</TT></a> shows DFS applied to the graph in
|
||||
<A HREF="./graph_theory_review.html#fig:dfs-example">Figure 1</A>.
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./depth_first_visit.html"><tt>depth_first_visit</tt></a>
|
||||
<a href="./undirected_dfs.html"><tt>undirected_dfs</tt></a>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p><a name="1">[1]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,148 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H2><A NAME="sec:dfs"></A>
|
||||
<img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>depth_first_visit</TT>
|
||||
</H2>
|
||||
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>, class ColorMap>
|
||||
void depth_first_visit(IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
DFSVisitor& vis, ColorMap color)
|
||||
|
||||
template <class <a href="./IncidenceGraph.html">IncidenceGraph</a>, class <a href="./DFSVisitor.html">DFSVisitor</a>, class ColorMap,
|
||||
class TerminatorFunc>
|
||||
void depth_first_visit(IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
DFSVisitor& vis, ColorMap color, TerminatorFunc func = TerminatorFunc())
|
||||
</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>The second variant can be used, for example, to find all marked vertices
|
||||
reachable from a start vertex by a path which does not contain any another
|
||||
marked vertices.
|
||||
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Where Defined:</h3>
|
||||
|
||||
<a href="../../../boost/graph/depth_first_search.hpp"><TT>boost/graph/depth_first_search.hpp</TT></a>
|
||||
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN <tt>IncidenceGraph& g</tt>
|
||||
<blockquote>
|
||||
A directed or undirected graph. The graph's type must be a model of
|
||||
<a href="./IncidenceGraph.html">Incidence Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
<blockquote>
|
||||
The source vertex from which to start the search.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>root_vertex</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>DFSVisitor visitor</tt>
|
||||
<blockquote>
|
||||
A visitor object that is invoked inside the algorithm at the
|
||||
event-points specified by the <a href="./DFSVisitor.html">DFS
|
||||
Visitor</a> concept. The visitor object is passed by value <a
|
||||
href="#1">[1]</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a href="DFSVisitor.html#python"><tt>DFSVisitor</tt></a> type of
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>ColorMap color</tt>
|
||||
<blockquote>
|
||||
This is used by the algorithm to keep track of its progress through
|
||||
the graph. The type <tt>ColorMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> and its key type must be the graph's vertex
|
||||
descriptor type and the value type of the color map map must model
|
||||
<a href="./ColorValue.html">Color Value</a>.<br>
|
||||
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>TerminatorFunc func</tt>
|
||||
<blockquote>
|
||||
A function object callable with two parameters - the descriptor of
|
||||
vertex and the graph instance - and returning bool. The call is made
|
||||
immediately after call to 'discover_vertex' visitor
|
||||
event. If <tt>true</tt> is returned, the out edges of the vertex are
|
||||
not examined, as if they don't exist.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
<P>
|
||||
|
||||
<h3>Complexity</h3>
|
||||
|
||||
Time complexity is <i>O(E)</i>.
|
||||
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p><a name="1">[1]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,115 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,442 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:dijkstra"></A><img src="figs/python.gif" alt="(Python)"/>
|
||||
<TT>dijkstra_shortest_paths</TT>
|
||||
</H1>
|
||||
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template <typename Graph, typename P, typename T, typename R>
|
||||
void
|
||||
dijkstra_shortest_paths(Graph& g,
|
||||
typename graph_traits<Graph>::vertex_descriptor s,
|
||||
const bgl_named_params<P, T, R>& params);
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <typename Graph, typename <a href="DijkstraVisitor.html">DijkstraVisitor</a>,
|
||||
typename PredecessorMap, typename DistanceMap,
|
||||
typename WeightMap, typename VertexIndexMap, typename <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">CompareFunction</a>, typename <a href="http://www.sgi.com/tech/stl/BinaryFunction.html">CombineFunction</a>,
|
||||
typename DistInf, typename DistZero>
|
||||
void dijkstra_shortest_paths
|
||||
(const Graph& g,
|
||||
typename graph_traits<Graph>::vertex_descriptor s,
|
||||
PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
|
||||
VertexIndexMap index_map,
|
||||
CompareFunction compare, CombineFunction combine, DistInf inf, DistZero zero,
|
||||
DijkstraVisitor vis)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
This algorithm [<A HREF="bibliography.html#dijkstra59">10</A>,<A
|
||||
HREF="bibliography.html#clr90">8</A>] solves the single-source
|
||||
shortest-paths problem on a weighted, directed or undirected graph for
|
||||
the case where all edge weights are nonnegative. Use the Bellman-Ford
|
||||
algorithm for the case when some edge weights are negative. Use
|
||||
breadth-first search instead of Dijkstra's algorithm when all edge
|
||||
weights are equal to one. For the definition of the shortest-path
|
||||
problem see Section <A
|
||||
HREF="graph_theory_review.html#sec:shortest-paths-algorithms">Shortest-Paths
|
||||
Algorithms</A> for some background to the shortest-path problem.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
There are two main options for obtaining output from the
|
||||
<tt>dijkstra_shortest_paths()</tt> function. If you provide a
|
||||
distance property map through the <tt>distance_map()</tt> parameter
|
||||
then the shortest distance from the source vertex to every other
|
||||
vertex in the graph will be recorded in the distance map. Also you can
|
||||
record the shortest paths tree in a predecessor map: for each vertex
|
||||
<i>u in V</i>, <i>p[u]</i> will be the predecessor of <i>u</i> in
|
||||
the shortest paths tree (unless <i>p[u] = u</i>, in which case <i>u</i> is
|
||||
either the source or a vertex unreachable from the source). In
|
||||
addition to these two options, the user can provide there own
|
||||
custom-made visitor that can takes actions during any of the
|
||||
algorithm's event points.</P>
|
||||
|
||||
<P>
|
||||
Dijkstra's algorithm finds all the shortest paths from the source
|
||||
vertex to every other vertex by iteratively ``growing'' the set of
|
||||
vertices <i>S</i> to which it knows the shortest path. At each step of
|
||||
the algorithm, the next vertex added to <i>S</i> is determined by a
|
||||
priority queue. The queue contains the vertices in <i>V - S</i><a
|
||||
href="#1">[1]</a> prioritized by their distance label, which is the
|
||||
length of the shortest path seen so far for each vertex. The vertex
|
||||
<i>u</i> at the top of the priority queue is then added to <i>S</i>,
|
||||
and each of its out-edges is relaxed: if the distance to <i>u</i> plus
|
||||
the weight of the out-edge <i>(u,v)</i> is less than the distance
|
||||
label for <i>v</i> then the estimated distance for vertex <i>v</i> is
|
||||
reduced. The algorithm then loops back, processing the next vertex at
|
||||
the top of the priority queue. The algorithm finishes when the
|
||||
priority queue is empty.
|
||||
</P>
|
||||
<P>
|
||||
The algorithm uses color markers (white, gray, and black) to keep
|
||||
track of which set each vertex is in. Vertices colored black are in
|
||||
<i>S</i>. Vertices colored white or gray are in <i>V-S</i>. White vertices have
|
||||
not yet been discovered and gray vertices are in the priority queue.
|
||||
By default, the algorithm will allocate an array to store a color
|
||||
marker for each vertex in the graph. You can provide you own storage
|
||||
and access for colors with the <tt>color_map()</tt> parameter.
|
||||
</P>
|
||||
<p>
|
||||
The following is the pseudo-code for Dijkstra's single-source shortest
|
||||
paths algorithm. <i>w</i> is the edge weight, <i>d</i> is the distance label,
|
||||
and <i>p</i> is the predecessor of each vertex which is used to encode
|
||||
the shortest paths tree. <i>Q</i> is a priority queue that supports the
|
||||
DECREASE-KEY operation. The visitor event points for the algorithm are
|
||||
indicated by the labels on the right.
|
||||
</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
DIJKSTRA(<i>G</i>, <i>s</i>, <i>w</i>)
|
||||
<b>for</b> each vertex <i>u in V</i>
|
||||
<i>d[u] := infinity</i>
|
||||
<i>p[u] := u</i>
|
||||
<i>color[u] :=</i> WHITE
|
||||
<b>end for</b>
|
||||
<i>color[s] := </i>GRAY
|
||||
<i>d[s] := 0</i>
|
||||
INSERT(<i>Q</i>, <i>s</i>)
|
||||
<b>while</b> (<i>Q != Ø</i>)
|
||||
<i>u :=</i> EXTRACT-MIN(<i>Q</i>)
|
||||
<i>S := S U { u }</i>
|
||||
<b>for</b> each vertex <i>v in Adj[u]</i>
|
||||
<b>if</b> (<i>w(u,v) + d[u] < d[v]</i>)
|
||||
<i>d[v] := w(u,v) + d[u]</i>
|
||||
<i>p[v] := u</i>
|
||||
<b>if</b> (<i>color[v] =</i> WHITE)
|
||||
<i>color[v] :=</i> GRAY
|
||||
INSERT(<i>Q</i>, <i>v</i>)
|
||||
<b>else if</b> (<i>color[v] =</i> GRAY)
|
||||
DECREASE-KEY(<i>Q</i>, <i>v</i>)
|
||||
<b>else</b>
|
||||
<i>...</i>
|
||||
<b>end for</b>
|
||||
<i>color[u] :=</i> BLACK
|
||||
<b>end while</b>
|
||||
return (<i>d</i>, <i>p</i>)
|
||||
</pre>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<pre>
|
||||
|
||||
initialize vertex <i>u</i>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
discover vertex <i>s</i>
|
||||
|
||||
examine vertex <i>u</i>
|
||||
|
||||
examine edge <i>(u,v)</i>
|
||||
|
||||
edge <i>(u,v)</i> relaxed
|
||||
|
||||
|
||||
|
||||
discover vertex <i>v</i>
|
||||
|
||||
|
||||
|
||||
edge <i>(u,v)</i> not relaxed
|
||||
|
||||
finish vertex <i>u</i>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/dijkstra_shortest_paths.hpp"><tt>boost/graph/dijkstra_shortest_paths.hpp</tt></a>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied.
|
||||
The type <tt>Graph</tt> must be a model of
|
||||
<a href="./VertexListGraph.html">Vertex List Graph</a>
|
||||
and <a href="./IncidenceGraph.html">Incidence Graph</a>.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
<blockquote>
|
||||
The source vertex. All distance will be calculated from this vertex,
|
||||
and the shortest paths tree will be rooted at this vertex.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>root_vertex</tt>.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>weight_map(WeightMap w_map)</tt>
|
||||
<blockquote>
|
||||
The weight or ``length'' of each edge in the graph. The weights
|
||||
must all be non-negative, and the algorithm will throw a
|
||||
<a href="./exception.html#negative_edge"><tt>negative_edge</tt></a>
|
||||
exception is one of the edges is negative.
|
||||
The type <tt>WeightMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The edge descriptor type of
|
||||
the graph needs to be usable as the key type for the weight
|
||||
map. The value type for this map must be
|
||||
the same as the value type of the distance map.<br>
|
||||
<b>Default:</b> <tt>get(edge_weight, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Must be an <tt>edge_double_map</tt> for the graph.<br>
|
||||
<b>Python default</b>: <tt>graph.get_edge_double_map("weight")</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(g))</tt>. This is necessary for efficient updates of the
|
||||
heap data structure [<A
|
||||
HREF="bibliography.html#driscoll88">61</A>] when an edge is relaxed.
|
||||
The type
|
||||
<tt>VertexIndexMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadablePropertyMap.html">Readable Property Map</a>. The value type of the map must be an
|
||||
integer type. The vertex descriptor type of the graph needs to be
|
||||
usable as the key type of the map.<br>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>predecessor_map(PredecessorMap p_map)</tt>
|
||||
<blockquote>
|
||||
The predecessor map records the edges in the minimum spanning
|
||||
tree. Upon completion of the algorithm, the edges <i>(p[u],u)</i>
|
||||
for all <i>u in V</i> are in the minimum spanning tree. If <i>p[u] =
|
||||
u</i> then <i>u</i> is either the source vertex or a vertex that is
|
||||
not reachable from the source. The <tt>PredecessorMap</tt> type
|
||||
must be a <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> whose key and value types are the same as the vertex
|
||||
descriptor type of the graph.<br>
|
||||
<b>Default:</b> <tt>dummy_property_map</tt><br>
|
||||
|
||||
<b>Python</b>: Must be a <tt>vertex_vertex_map</tt> for the graph.<br>
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>distance_map(DistanceMap d_map)</tt>
|
||||
<blockquote>
|
||||
The shortest path weight from the source vertex <tt>s</tt> to each
|
||||
vertex in the graph <tt>g</tt> is recorded in this property map. The
|
||||
shortest path weight is the sum of the edge weights along the
|
||||
shortest path. The type <tt>DistanceMap</tt> must be a model of <a
|
||||
href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</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 is the element type of a <a
|
||||
href="./Monoid.html">Monoid</a> formed with the <tt>combine</tt>
|
||||
function object and the <tt>zero</tt> object for the identity
|
||||
element. Also the distance value type must have a <a
|
||||
href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">
|
||||
StrictWeakOrdering</a> provided by the <tt>compare</tt> function
|
||||
object.<br>
|
||||
<b>Default:</b> <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a
|
||||
<tt>std::vector</tt> of the <tt>WeightMap</tt>'s value type of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.<br>
|
||||
|
||||
<b>Python</b>: Must be a <tt>vertex_double_map</tt> for the graph.<br>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_compare(CompareFunction cmp)</tt>
|
||||
<blockquote>
|
||||
This function is use to compare distances to determine which vertex
|
||||
is closer to the source vertex. The <tt>CompareFunction</tt> type
|
||||
must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryPredicate.html">Binary
|
||||
Predicate</a> and have argument types that match the value type of
|
||||
the <tt>DistanceMap</tt> property map.<br>
|
||||
|
||||
<b>Default:</b>
|
||||
<tt>std::less<D></tt> with <tt>D=typename
|
||||
property_traits<DistanceMap>::value_type</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_combine(CombineFunction cmb)</tt>
|
||||
<blockquote>
|
||||
This function is used to combine distances to compute the distance
|
||||
of a path. The <tt>CombineFunction</tt> type must be a model of <a
|
||||
href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary
|
||||
Function</a>. The first argument type of the binary function must
|
||||
match the value type of the <tt>DistanceMap</tt> property map and
|
||||
the second argument type must match the value type of the
|
||||
<tt>WeightMap</tt> property map. The result type must be the same
|
||||
type as the distance value type.<br>
|
||||
|
||||
<b>Default:</b> <tt>std::plus<D></tt> with
|
||||
<tt>D=typename property_traits<DistanceMap>::value_type</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_inf(D inf)</tt>
|
||||
<blockquote>
|
||||
The <tt>inf</tt> object must be the greatest value of any <tt>D</tt> object.
|
||||
That is, <tt>compare(d, inf) == true</tt> for any <tt>d != inf</tt>.
|
||||
The type <tt>D</tt> is the value type of the <tt>DistanceMap</tt>.<br>
|
||||
<b>Default:</b> <tt>std::numeric_limits<D>::max()</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>distance_zero(D zero)</tt>
|
||||
<blockquote>
|
||||
The <tt>zero</tt> value must be the identity element for the
|
||||
<a href="./Monoid.html">Monoid</a> formed by the distance values
|
||||
and the <tt>combine</tt> function object.
|
||||
The type <tt>D</tt> is the value type of the <tt>DistanceMap</tt>.<br>
|
||||
<b>Default:</b> <tt>D()</tt>with
|
||||
<tt>D=typename property_traits<DistanceMap>::value_type</tt><br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
UTIL/OUT: <tt>color_map(ColorMap c_map)</tt>
|
||||
<blockquote>
|
||||
This is used during the execution of the algorithm to mark the
|
||||
vertices. The vertices start out white and become gray when they are
|
||||
inserted in the queue. They then turn black when they are removed
|
||||
from the queue. At the end of the algorithm, vertices reachable from
|
||||
the source vertex will have been colored black. All other vertices
|
||||
will still be white. The type <tt>ColorMap</tt> must be a model of
|
||||
<a href="../../property_map/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</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">Color Value</a>.<br>
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a <tt>std::vector</tt>
|
||||
of <tt>default_color_type</tt> of size <tt>num_vertices(g)</tt> and
|
||||
using the <tt>i_map</tt> for the index map.<br>
|
||||
|
||||
<b>Python</b>: The color map must be a <tt>vertex_color_map</tt> for
|
||||
the graph.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>visitor(DijkstraVisitor v)</tt>
|
||||
<blockquote>
|
||||
Use this to specify actions that you would like to happen
|
||||
during certain event points within the algorithm.
|
||||
The type <tt>DijkstraVisitor</tt> must be a model of the
|
||||
<a href="./DijkstraVisitor.html">Dijkstra Visitor</a> concept.
|
||||
The visitor object is passed by value <a
|
||||
href="#2">[2]</a>.<br>
|
||||
<b>Default:</b> <tt>dijkstra_visitor<null_visitor></tt><br>
|
||||
|
||||
<b>Python</b>: The parameter should be an object that derives from
|
||||
the <a
|
||||
href="DijkstraVisitor.html#python"><tt>DijkstraVisitor</tt></a> type
|
||||
of the graph.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<H3>Complexity</H3>
|
||||
|
||||
<P>
|
||||
The time complexity is <i>O(V log V)</i>.
|
||||
|
||||
|
||||
<h3>Visitor Event Points</h3>
|
||||
|
||||
<ul>
|
||||
<li><b><tt>vis.initialize_vertex(u, g)</tt></b>
|
||||
is invoked on each vertex in the graph before the start of the
|
||||
algorithm.
|
||||
<li><b><tt>vis.examine_vertex(u, g)</tt></b>
|
||||
is invoked on a vertex as it is removed from the priority queue
|
||||
and added to set <i>S</i>. At this point we know that <i>(p[u],u)</i>
|
||||
is a shortest-paths tree edge so
|
||||
<i>d[u] = delta(s,u) = d[p[u]] + w(p[u],u)</i>. Also, the distances
|
||||
of the examined vertices is monotonically increasing
|
||||
<i>d[u<sub>1</sub>] <= d[u<sub>2</sub>] <= d[u<sub>n</sub>]</i>.
|
||||
<li><b><tt>vis.examine_edge(e, g)</tt></b>
|
||||
is invoked on each out-edge of a vertex immediately after it has
|
||||
been added to set <i>S</i>.
|
||||
<li><b><tt>vis.edge_relaxed(e, g)</tt></b>
|
||||
is invoked on edge <i>(u,v)</i> if <i>d[u] + w(u,v) < d[v]</i>.
|
||||
The edge <i>(u,v)</i> that participated in the last
|
||||
relaxation for vertex <i>v</i> is an edge in the shortest paths tree.
|
||||
<li><b><tt>vis.discover_vertex(v, g)</tt></b>
|
||||
is invoked on vertex <i>v</i> when the edge
|
||||
<i>(u,v)</i> is examined and <i>v</i> is WHITE. Since
|
||||
a vertex is colored GRAY when it is discovered,
|
||||
each reacable vertex is discovered exactly once. This
|
||||
is also when the vertex is inserted into the priority queue.
|
||||
<li><b><tt>vis.edge_not_relaxed(e, g)</tt></b>
|
||||
is invoked if the edge is not relaxed (see above).
|
||||
<li><b><tt>vis.finish_vertex(u, g)</tt></b>
|
||||
is invoked on a vertex after all of its out edges have
|
||||
been examined.
|
||||
</ul>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<P>
|
||||
See <a href="../example/dijkstra-example.cpp">
|
||||
<TT>example/dijkstra-example.cpp</TT></a> for an example of using Dijkstra's
|
||||
algorithm.
|
||||
|
||||
<H3>Notes</H3>
|
||||
|
||||
<a name="1">[1]</a>
|
||||
The algorithm used here saves a little space by not putting all <i>V -
|
||||
S</i> vertices in the priority queue at once, but instead only those
|
||||
vertices in <i>V - S</i> that are discovered and therefore have a
|
||||
distance less than infinity.
|
||||
|
||||
<p><a name="2">[2]</a>
|
||||
Since the visitor parameter is passed by value, if your visitor
|
||||
contains state then any changes to the state during the algorithm
|
||||
will be made to a copy of the visitor object, not the visitor object
|
||||
passed in. Therefore you may want the visitor to hold this state by
|
||||
pointer or reference.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,129 +0,0 @@
|
||||
<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: dijkstra_visitor</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<pre>
|
||||
dijkstra_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="./DijkstraVisitor.html">DijkstraVisitor</a>.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
This is an excerpt from <a
|
||||
href="../example/dave.cpp"><tt>examples/dave.cpp</tt></a>
|
||||
where the <tt>copy_graph</tt> single-event visitor
|
||||
is used to create a copy the shortest-paths search-tree calculated
|
||||
by Dijkstra's algorithm.
|
||||
|
||||
<pre>
|
||||
boost::dijkstra_shortest_paths
|
||||
(G, vertex(a, G),
|
||||
distance_map(make_iterator_property_map(distance.begin(), vertex_id, distance[0])).
|
||||
predecessor_map(make_iterator_property_map(parent.begin(), vertex_id, parent[0])).
|
||||
visitor(make_dijkstra_visitor(copy_graph(G_copy, on_examine_edge()))));
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./DijkstraVisitor.html">Dijkstra Visitor</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/dijkstra_shortest_paths.hpp">
|
||||
<TT>boost/graph/dijkstra_shortest_paths.hpp</TT></a>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
This class implements all of the member functions required by <a
|
||||
href="./DijkstraVisitor.html">DijkstraVisitor</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>
|
||||
dijkstra_visitor<EventVisitorList><br>
|
||||
make_dijkstra_visitor(EventVisitorList ev_list);
|
||||
</tt></td><td>
|
||||
Returns the event visitor list adapted to be a Dijkstra 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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,186 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
<!-- LocalWords: DistanceMap EventTag EventVisitor map bfs dfs const Siek
|
||||
-->
|
||||
<!-- LocalWords: EventVisitorList WritablePropertyMap Univ Quan
|
||||
-->
|
||||
<!-- LocalWords: Lumsdaine
|
||||
-->
|
||||
@@ -1,225 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
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/tech/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-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,244 +0,0 @@
|
||||
<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: Edmunds-Karp Maximum Flow</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1><A NAME="sec:edmunds_karp_max_flow">
|
||||
<TT>edmunds_karp_max_flow</TT>
|
||||
</H1>
|
||||
|
||||
<PRE>
|
||||
<i>// named paramter version</i>
|
||||
template <class <a href="./Graph.html">Graph</a>, class P, class T, class R>
|
||||
typename detail::edge_capacity_value<Graph, P, T, R>::value_type
|
||||
edmunds_karp_max_flow(Graph& g,
|
||||
typename graph_traits<Graph>::vertex_descriptor src,
|
||||
typename graph_traits<Graph>::vertex_descriptor sink,
|
||||
const bgl_named_params<P, T, R>& params = <i>all defaults</i>)
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template <class <a href="./Graph.html">Graph</a>,
|
||||
class CapacityEdgeMap, class ResidualCapacityEdgeMap,
|
||||
class ReverseEdgeMap, class ColorMap, class PredEdgeMap>
|
||||
typename property_traits<CapacityEdgeMap>::value_type
|
||||
edmunds_karp_max_flow(Graph& g,
|
||||
typename graph_traits<Graph>::vertex_descriptor src,
|
||||
typename graph_traits<Graph>::vertex_descriptor sink,
|
||||
CapacityEdgeMap cap, ResidualCapacityEdgeMap res, ReverseEdgeMap rev,
|
||||
ColorMap color, PredEdgeMap pred)
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The <tt>edmunds_karp_max_flow()</tt> function calculates the maximum flow
|
||||
of a network. See Section <a
|
||||
href="./graph_theory_review.html#sec:network-flow-algorithms">Network
|
||||
Flow Algorithms</a> for a description of maximum flow. The calculated
|
||||
maximum flow will be the return value of the function. The function
|
||||
also calculates the flow values <i>f(u,v)</i> for all <i>(u,v)</i> in
|
||||
<i>E</i>, which are returned in the form of the residual capacity
|
||||
<i>r(u,v) = c(u,v) - f(u,v)</i>.
|
||||
|
||||
<p>
|
||||
There are several special requirements on the input graph and property
|
||||
map parameters for this algorithm. First, the directed graph
|
||||
<i>G=(V,E)</i> that represents the network must be augmented to
|
||||
include the reverse edge for every edge in <i>E</i>. That is, the
|
||||
input graph should be <i>G<sub>in</sub> = (V,{E U
|
||||
E<sup>T</sup>})</i>. The <tt>ReverseEdgeMap</tt> argument <tt>rev</tt>
|
||||
must map each edge in the original graph to its reverse edge, that is
|
||||
<i>(u,v) -> (v,u)</i> for all <i>(u,v)</i> in <i>E</i>. The
|
||||
<tt>CapacityEdgeMap</tt> argument <tt>cap</tt> must map each edge in
|
||||
<i>E</i> to a positive number, and each edge in <i>E<sup>T</sup></i>
|
||||
to 0.
|
||||
|
||||
<p>
|
||||
The algorithm is due to <a
|
||||
href="./bibliography.html#edmonds72:_improvements_netflow">Edmonds and
|
||||
Karp</a>, though we are using the variation called the ``labeling
|
||||
algorithm'' described in <a
|
||||
href="./bibliography.html#ahuja93:_network_flows">Network Flows</a>.
|
||||
|
||||
<p>
|
||||
This algorithm provides a very simple and easy to implement solution to
|
||||
the maximum flow problem. However, there are several reasons why this
|
||||
algorithm is not as good as the <a
|
||||
href="./push_relabel_max_flow.html"><tt>push_relabel_max_flow()</tt></a>
|
||||
algorithm.
|
||||
|
||||
<ul>
|
||||
<li>In the non-integer capacity case, the time complexity is <i>O(V
|
||||
E<sup>2</sup>)</i> which is worse than the time complexity of the
|
||||
push-relabel algorithm <i>O(V<sup>2</sup>E<sup>1/2</sup>)</i>
|
||||
for all but the sparsest of graphs.</li>
|
||||
|
||||
<li>In the integer capacity case, if the capacity bound <i>U</i> is
|
||||
very large then the algorithm will take a long time.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/edmunds_karp_max_flow.hpp"><TT>boost/graph/edmunds_karp_max_flow.hpp</TT></a>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>Graph& g</tt>
|
||||
<blockquote>
|
||||
A directed graph. The
|
||||
graph's type must be a model of <a
|
||||
href="./VertexListGraph.html">VertexListGraph</a> and <a href="./IncidenceGraph.html">IncidenceGraph</a> For each edge
|
||||
<i>(u,v)</i> in the graph, the reverse edge <i>(v,u)</i> must also
|
||||
be in the graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor src</tt>
|
||||
<blockquote>
|
||||
The source vertex for the flow network graph.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor sink</tt>
|
||||
<blockquote>
|
||||
The sink vertex for the flow network graph.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
|
||||
IN: <tt>capacity_map(CapacityEdgeMap cap)</tt>
|
||||
<blockquote>
|
||||
The edge capacity property map. The type must be a model of a
|
||||
constant <a
|
||||
href="../../property_map/LvaluePropertyMap.html">Lvalue Property Map</a>. The
|
||||
key type of the map must be the graph's edge descriptor type.<br>
|
||||
<b>Default:</b> <tt>get(edge_capacity, g)</tt>
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>residual_capacity_map(ResidualCapacityEdgeMap res)</tt>
|
||||
<blockquote>
|
||||
This maps edges to their residual capacity. The type must be a model
|
||||
of a mutable <a
|
||||
href="../../property_map/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</a>. The key type of the map must be the graph's edge descriptor
|
||||
type.<br>
|
||||
<b>Default:</b> <tt>get(edge_residual_capacity, g)</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>reverse_edge_map(ReverseEdgeMap rev)</tt>
|
||||
<blockquote>
|
||||
An edge property map that maps every edge <i>(u,v)</i> in the graph
|
||||
to the reverse edge <i>(v,u)</i>. The map must be a model of
|
||||
constant <a href="../../property_map/LvaluePropertyMap.html">Lvalue
|
||||
Property Map</a>. The key type of the map must be the graph's edge
|
||||
descriptor type.<br>
|
||||
<b>Default:</b> <tt>get(edge_reverse, g)</tt>
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>color_map(ColorMap color)</tt>
|
||||
<blockquote>
|
||||
Used by the algorithm to keep track of progress during the
|
||||
breadth-first search stage. At the end of the algorithm, the white
|
||||
vertices define the minimum cut set. The map must be a model of
|
||||
mutable <a
|
||||
href="../../property_map/LvaluePropertyMap.html">Lvalue Property Map</a>.
|
||||
The key type of the map should be the graph's vertex descriptor type, and
|
||||
the value type must be a model of <a
|
||||
href="./ColorValue.html">ColorValue</a>.<br>
|
||||
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a <tt>std::vector</tt>
|
||||
of <tt>default_color_type</tt> of size <tt>num_vertices(g)</tt> and
|
||||
using the <tt>i_map</tt> for the index map.
|
||||
</blockquote>
|
||||
|
||||
UTIL: <tt>predecessor_map(PredEdgeMap pred)</tt>
|
||||
<blockquote>
|
||||
Use by the algorithm to store augmenting paths. The map must be a
|
||||
model of mutable <a
|
||||
href="../../property_map/LvaluePropertyMap.html">Lvalue Property Map</a>.
|
||||
The key type must be the graph's vertex descriptor type and the
|
||||
value type must be the graph's edge descriptor type.<br>
|
||||
|
||||
<b>Default:</b> an <a
|
||||
href="../../property_map/iterator_property_map.html">
|
||||
<tt>iterator_property_map</tt></a> created from a <tt>std::vector</tt>
|
||||
of edge descriptors of size <tt>num_vertices(g)</tt> and
|
||||
using the <tt>i_map</tt> for the index map.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<blockquote>
|
||||
Maps each vertex of the graph to a unique integer in the range
|
||||
<tt>[0, num_vertices(g))</tt>. This property map is only needed
|
||||
if the default for the color or predecessor map is used.
|
||||
The vertex index map must be a model of <a
|
||||
href="../../property_map/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<br>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt>
|
||||
</blockquote>
|
||||
|
||||
|
||||
<h3>Complexity</h3>
|
||||
|
||||
The time complexity is <i>O(V E<sup>2</sup>)</i> in the general case
|
||||
or <i>O(V E U)</i> if capacity values are integers bounded by
|
||||
some constant <i>U</i>.
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
The program in <a
|
||||
href="../example/edmunds-karp-eg.cpp"><tt>example/edmunds-karp-eg.cpp</tt></a>
|
||||
reads an example maximum flow problem (a graph with edge capacities)
|
||||
from a file in the DIMACS format and computes the maximum flow.
|
||||
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./push_relabel_max_flow.html"><tt>push_relabel_max_flow()</tt></a>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
<!-- LocalWords: HTML Siek Edmunds BGCOLOR ffffff ee VLINK ALINK ff IMG SRC
|
||||
-->
|
||||
<!-- LocalWords: gif ALT BR sec edmunds karp TT DIV CELLPADDING TR TD PRE lt
|
||||
-->
|
||||
<!-- LocalWords: typename VertexListGraph CapacityEdgeMap ReverseEdgeMap gt
|
||||
-->
|
||||
<!-- LocalWords: ResidualCapacityEdgeMap VertexIndexMap src rev ColorMap pred
|
||||
-->
|
||||
<!-- LocalWords: PredEdgeMap tt href html hpp ul li nbsp br LvaluePropertyMap
|
||||
-->
|
||||
<!-- LocalWords: num ColorValue DIMACS cpp pre config iostream dimacs int std
|
||||
-->
|
||||
<!-- LocalWords: namespace vecS directedS cout endl iter ei HR valign nowrap
|
||||
-->
|
||||
<!-- LocalWords: jeremy siek htm Univ mailto jsiek lsc edu
|
||||
p -->
|
||||
106
doc/eg1-iso.cpp
@@ -1,106 +0,0 @@
|
||||
// Boost.Graph library isomorphism test
|
||||
|
||||
// Copyright (C) 2001 Douglas Gregor (gregod@cs.rpi.edu)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
//
|
||||
// Revision History:
|
||||
//
|
||||
// 29 Nov 2001 Jeremy Siek
|
||||
// Changed to use Boost.Random.
|
||||
// 29 Nov 2001 Doug Gregor
|
||||
// Initial checkin.
|
||||
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/isomorphism.hpp>
|
||||
//#include "isomorphism-v3.hpp"
|
||||
#include <boost/property_map.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
|
||||
enum { a, b, c, d, e, f, g, h };
|
||||
enum { _1, _2, _3, _4, _5, _6, _7, _8 };
|
||||
|
||||
void test_isomorphism()
|
||||
{
|
||||
typedef adjacency_list<vecS, vecS, bidirectionalS> GraphA;
|
||||
typedef adjacency_list<vecS, vecS, bidirectionalS> GraphB;
|
||||
|
||||
char a_names[] = "abcdefgh";
|
||||
char b_names[] = "12345678";
|
||||
|
||||
GraphA Ga(8);
|
||||
add_edge(a, d, Ga);
|
||||
add_edge(a, h, Ga);
|
||||
add_edge(b, c, Ga);
|
||||
add_edge(b, e, Ga);
|
||||
add_edge(c, f, Ga);
|
||||
add_edge(d, a, Ga);
|
||||
add_edge(d, h, Ga);
|
||||
add_edge(e, b, Ga);
|
||||
add_edge(f, b, Ga);
|
||||
add_edge(f, e, Ga);
|
||||
add_edge(g, d, Ga);
|
||||
add_edge(g, f, Ga);
|
||||
add_edge(h, c, Ga);
|
||||
add_edge(h, g, Ga);
|
||||
|
||||
GraphB Gb(8);
|
||||
add_edge(_1, _6, Gb);
|
||||
add_edge(_2, _1, Gb);
|
||||
add_edge(_2, _5, Gb);
|
||||
add_edge(_3, _2, Gb);
|
||||
add_edge(_3, _4, Gb);
|
||||
add_edge(_4, _2, Gb);
|
||||
add_edge(_4, _3, Gb);
|
||||
add_edge(_5, _4, Gb);
|
||||
add_edge(_5, _6, Gb);
|
||||
add_edge(_6, _7, Gb);
|
||||
add_edge(_6, _8, Gb);
|
||||
add_edge(_7, _8, Gb);
|
||||
add_edge(_8, _1, Gb);
|
||||
add_edge(_8, _7, Gb);
|
||||
|
||||
|
||||
std::vector<std::size_t> in_degree_A(num_vertices(Ga));
|
||||
boost::detail::compute_in_degree(Ga, &in_degree_A[0]);
|
||||
|
||||
std::vector<std::size_t> in_degree_B(num_vertices(Gb));
|
||||
boost::detail::compute_in_degree(Gb, &in_degree_B[0]);
|
||||
|
||||
degree_vertex_invariant<std::size_t*, GraphA>
|
||||
invariantA(&in_degree_A[0], Ga);
|
||||
degree_vertex_invariant<std::size_t*, GraphB>
|
||||
invariantB(&in_degree_B[0], Gb);
|
||||
|
||||
std::vector<graph_traits<GraphB>::vertex_descriptor> f(num_vertices(Ga));
|
||||
|
||||
bool ret = isomorphism(Ga, Gb, &f[0], invariantA, invariantB,
|
||||
(invariantB.max)(),
|
||||
get(vertex_index, Ga), get(vertex_index, Gb));
|
||||
assert(ret == true);
|
||||
|
||||
for (std::size_t i = 0; i < num_vertices(Ga); ++i)
|
||||
std::cout << "f(" << a_names[i] << ")=" << b_names[f[i]] << std::endl;
|
||||
|
||||
BOOST_TEST(verify_isomorphism(Ga, Gb, &f[0]));
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_isomorphism();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) The Trustees of Indiana University
|
||||
--
|
||||
-- Use, modification and distribution is subject to the Boost Software
|
||||
-- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
-- http://www.boost.org/LICENSE_1_0.txt)
|
||||
--
|
||||
-- Authors: Douglas Gregor
|
||||
-- Andrew Lumsdaine
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Erdös-Renyi Generator</Title>
|
||||
<script language="JavaScript" type="text/JavaScript">
|
||||
<!--
|
||||
function address(host, user) {
|
||||
var atchar = '@';
|
||||
var thingy = user+atchar+host;
|
||||
thingy = '<a hre' + 'f=' + "mai" + "lto:" + thingy + '>' + user+atchar+host + '</a>';
|
||||
document.write(thingy);
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<tt>erdos_renyi_iterator</tt>
|
||||
|
||||
<br>
|
||||
|
||||
<PRE>
|
||||
template<typename RandomGenerator, typename Graph>
|
||||
class erdos_renyi_iterator
|
||||
{
|
||||
public:
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef std::pair<vertices_size_type, vertices_size_type> value_type;
|
||||
typedef const value_type& reference;
|
||||
typedef const value_type* pointer;
|
||||
typedef void difference_type;
|
||||
|
||||
erdos_renyi_iterator();
|
||||
erdos_renyi_iterator(RandomGenerator& gen, vertices_size_type n,
|
||||
double probability = 0.0, bool allow_self_loops = false);
|
||||
// Iterator operations
|
||||
reference operator*() const;
|
||||
pointer operator->() const;
|
||||
erdos_renyi_iterator& operator++();
|
||||
erdos_renyi_iterator operator++(int);
|
||||
bool operator==(const erdos_renyi_iterator& other) const;
|
||||
bool operator!=(const erdos_renyi_iterator& other) const;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<p> This class template implements a generator for Erdöos-Renyi
|
||||
graphs, suitable for initializing an <a
|
||||
href="adjacency_list.html"><tt>adjacency_list</tt></a> or other graph
|
||||
structure with iterator-based initialization. An Erdöos-Renyi
|
||||
graph <em>G = (n, p)</em> is a graph with <em>n</em> vertices
|
||||
that. The probability of having an edge <em>(u, v)</em> in <em>G</em>
|
||||
is <em>p</em> for any vertices <em>u</em> and <em>v</em>. Typically,
|
||||
there are no self-loops, but the generator can optionally introduce
|
||||
self-loops with probability <em>p</em>.</p>
|
||||
|
||||
<p>Erdös-Renyi graphs typically exhibit very little
|
||||
structure. For this reason, they are rarely useful in modeling
|
||||
real-world problems. However, they are often used when determining
|
||||
the theoretical complexity of complex graph algorithms.</p>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<a href="../../../boost/graph/erdos_renyi_generator.hpp"><tt>boost/graph/erdos_renyi_generator.hpp</tt></a>
|
||||
|
||||
<h3>Constructors</h3>
|
||||
|
||||
<a name="default-constructor"/>
|
||||
<pre>erdos_renyi_iterator();</pre>
|
||||
<blockquote>
|
||||
Constructs a past-the-end iterator.
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
erdos_renyi_iterator(RandomGenerator& gen, vertices_size_type n,
|
||||
double probability = 0.0, bool allow_self_loops =
|
||||
false);
|
||||
</pre>
|
||||
<blockquote>
|
||||
Constructs an Erdös-Renyi generator iterator that creates a
|
||||
graph with <tt>n</tt> vertices and edges with probability
|
||||
<tt>probability</tt>. Probabilities are drawn from the random number
|
||||
generator <tt>gen</tt>. Self-loops are permitted only when
|
||||
<tt>allow_self_loops</tt> is <tt>true</tt>.
|
||||
</blockquote>
|
||||
|
||||
<H3>Example</H3>
|
||||
|
||||
<pre>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/erdos_renyi_generator.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
|
||||
typedef boost::adjacency_list<> Graph;
|
||||
typedef boost::erdos_renyi_iterator<boost::minstd_rand, Graph> ERGen;
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::minstd_rand gen;
|
||||
// Create graph with 100 nodes and edges with probability 0.05
|
||||
Graph g(ERGen(gen, 100, 0.05), ERGen(), 100);
|
||||
return 0;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2005</TD><TD>
|
||||
<A HREF="../../../people/doug_gregor.html">Doug Gregor</A>, Indiana University (<script language="Javascript">address("cs.indiana.edu", "dgregor")</script>)<br>
|
||||
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
|
||||
Indiana University (<script language="Javascript">address("osl.iu.edu", "lums")</script>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,50 +0,0 @@
|
||||
<HTML>
|
||||
<!--
|
||||
-- Copyright (c) Jeremy Siek 2002
|
||||
--
|
||||
-- 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: Exceptions</Title>
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1><a href="../../../boost/graph/exception.hpp"><tt>boost/graph/exception.hpp</tt></a></h1>
|
||||
|
||||
<P>
|
||||
The BGL defines several exception classes for reporting errors from
|
||||
BGL algorithms. Many of the BGL algorithms place certain requirements
|
||||
on the input graph. If these requirements are not met then the
|
||||
algorithm can not successfully complete, and instead throws the
|
||||
appropriate exception.
|
||||
</P>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre>
|
||||
struct <a name="bad_graph">bad_graph</a> : public invalid_argument {
|
||||
bad_graph(const string& what_arg);
|
||||
};
|
||||
struct <a name="not_a_dag">not_a_dag</a> : public bad_graph {
|
||||
not_a_dag();
|
||||
};
|
||||
struct <a name="negative_edge">negative_edge</a> : public bad_graph {
|
||||
negative_edge();
|
||||
};
|
||||
struct <a name="negative_cycle">negative_cycle</a> : public bad_graph {
|
||||
negative_cycle();
|
||||
};
|
||||
struct <a name="not_connected">not_connected</a> : public bad_graph {
|
||||
not_connected();
|
||||
};
|
||||
</pre>
|
||||
156
doc/faq.html
@@ -1,156 +0,0 @@
|
||||
<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="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<h1>Frequently Asked Questions</h1>
|
||||
|
||||
<ol>
|
||||
|
||||
<li>
|
||||
How do I perform an early exit from an algorithm such as BFS?<br>
|
||||
|
||||
<p>
|
||||
Create a visitor that throws an exception when you want to cut off the
|
||||
search, then put your call to <tt>breadth_first_search</tt> inside of
|
||||
an appropriate try/catch block. This strikes many programmers as a
|
||||
misuse of exceptions, however, much thought was put into the decision
|
||||
to have exceptions has the preferred way to exit early. See boost
|
||||
email discussions for more details.
|
||||
</p>
|
||||
|
||||
<li>
|
||||
Why is the visitor parameter passed by value rather than reference
|
||||
in the various BGL algorithms?<br>
|
||||
|
||||
<p>
|
||||
One of the usage scenarios that we wanted to support with the
|
||||
algorithms was creating visitor objects on the fly, within the
|
||||
argument list of the call to the graph algorithm. In this situation,
|
||||
the visitor object is a temporary object. Now there is a truly
|
||||
unfortunate rule in the C++ standard that says a temporary cannot be
|
||||
bound to a non-const reference parameter. So we had to decide whether
|
||||
we wanted to support this kind of usage and call-by-value, or not and
|
||||
call-by-reference. We chose call-by-value, following in the footsteps
|
||||
of the STL (which passes functors by value). The disadvantage of this
|
||||
decision is that if your visitor contains state and changes that state
|
||||
during the algorithm, the change will be made to a copy of the visitor
|
||||
object, not the visitor object passed in. Therefore you may want the
|
||||
visitor to hold this state by pointer or reference.
|
||||
</p>
|
||||
|
||||
<li>Why does the BGL interface use friend functions (or free functions)
|
||||
instead of member functions?<br>
|
||||
<p>
|
||||
For the most part, the differences between member functions and free
|
||||
functions are syntactic, and not very important, though people can get
|
||||
religious about them. However, we had one technical reason for
|
||||
favoring free functions. A programmer can overload a free function for
|
||||
a type coming from a 3rd party without modifying the source
|
||||
code/definition of that type. There are several uses of this in the
|
||||
BGL. For example, Stanford GraphBase and LEDA graphs can both be used
|
||||
in BGL algorithms because of overloads in <tt>stanford_graph.hpp</tt>
|
||||
and <tt>leda_graph.hpp</tt>. One can even use
|
||||
<tt>std::vector<std::list></tt> as a graph due to the overloads
|
||||
in <tt>vector_as_graph.hpp</tt>.
|
||||
</p>
|
||||
<p>
|
||||
Of course, there is a way to adapt 3rd party classes into an interface
|
||||
with member functions. You create an adaptor class. However, the
|
||||
disadvantage of an adaptor class (compared to overloaded functions) is
|
||||
that one has to physically wrap and unwrap the objects as they go
|
||||
into/out of BGL algorithms. So the overloaded function route is more
|
||||
convenient. Granted, this is not a huge difference, but since there
|
||||
weren't other strong reasons, it was enough for us to choose free
|
||||
functions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Our religious reason for choosing free functions is to send the message
|
||||
that BGL is a generic library, and not a traditional object-oriented
|
||||
library. OO was hip in the 80s and 90s, but its time we moved beyond!
|
||||
</p>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li>How do I create a graph where the edges are sorted/ordered? <br>
|
||||
<p>The example <a href="../example/ordered_out_edges.cpp">
|
||||
<tt>ordered_out_edges.cpp</tt></a> shows how to do this.</p>
|
||||
</li>
|
||||
|
||||
<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/concept_check.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>
|
||||
<!-- LocalWords: gif ALT BGL std const STL GraphBase LEDA BFS stanford hpp OO
|
||||
-->
|
||||
<!-- LocalWords: leda cpp VertexList vecS listS undirectedS num cnt struct
|
||||
-->
|
||||
<!-- LocalWords: enum
|
||||
-->
|
||||
@@ -1,40 +0,0 @@
|
||||
# -*- 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
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 968 B |
@@ -1,59 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 800 B |
@@ -1,31 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 947 B |
@@ -1,35 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 3.9 KiB |
@@ -1,45 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 744 B |
|
Before Width: | Height: | Size: 492 B |
@@ -1,72 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -1,50 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 2.3 KiB |
@@ -1,73 +0,0 @@
|
||||
#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
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -1,17 +0,0 @@
|
||||
graph A {
|
||||
node[shape="circle"]
|
||||
B [ style="filled", fillcolor="red" ];
|
||||
G [ style="filled", fillcolor="red" ];
|
||||
A [ style="filled", fillcolor="red" ];
|
||||
A -- F[label="1"]
|
||||
A -- B[label="1"]
|
||||
A -- G[label="3"]
|
||||
B -- C[label="0"]
|
||||
B -- D[label="0"]
|
||||
B -- E[label="1"]
|
||||
C -- D[label="0"]
|
||||
E -- F[label="1"]
|
||||
G -- I[label="2"]
|
||||
G -- H[label="2"]
|
||||
H -- I[label="2"]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 786 B |