Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b7a1afe21 | |||
| 8a38567538 | |||
| 862c7637cd | |||
| bd4c4438ba | |||
| a84b41c331 | |||
| eae116a598 | |||
| 88a4583d32 | |||
| ea9d3f00eb | |||
| 3233baf282 | |||
| a942726d30 | |||
| d4865f0d49 | |||
| 08f2f509b0 | |||
| 835b65bd17 | |||
| 06f8e40a12 | |||
| d6a48882b1 | |||
| 53842df1cb | |||
| 69fb3ed70c | |||
| eb36987fec | |||
| ce5aba9799 | |||
| ae1242ca4a | |||
| 7b548b372f | |||
| afab978e75 | |||
| aec5b30a0f | |||
| 9d0640b614 |
@@ -11,53 +11,18 @@ project boost/graph
|
||||
: source-location ../src
|
||||
;
|
||||
|
||||
local optional_sources ;
|
||||
local optional_reqs ;
|
||||
|
||||
if [ modules.peek : EXPAT_INCLUDE ] && [ modules.peek : EXPAT_LIBPATH ]
|
||||
{
|
||||
local EXPAT_INCLUDE = [ modules.peek : EXPAT_INCLUDE ] ;
|
||||
local EXPAT_LIBPATH = [ modules.peek : EXPAT_LIBPATH ] ;
|
||||
|
||||
if --debug-configuration in [ modules.peek : ARGV ]
|
||||
{
|
||||
ECHO "Expat include directory: $(EXPAT_INCLUDE)" ;
|
||||
ECHO "Expat library directory: $(EXPAT_LIBPATH)" ;
|
||||
}
|
||||
|
||||
alias graphml
|
||||
: graphml.cpp
|
||||
: # requirements
|
||||
: # default built
|
||||
: # usage requirements
|
||||
<include>$(EXPAT_INCLUDE)
|
||||
<library-path>$(EXPAT_LIBPATH)
|
||||
<find-shared-library>expat
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
message graphml
|
||||
: "warning: Graph library does not contain optional GraphML reader."
|
||||
: "note: to enable GraphML support, set EXPAT_INCLUDE and EXPAT_LIBPATH to the"
|
||||
: "note: directories containing the Expat headers and libraries, respectively."
|
||||
;
|
||||
}
|
||||
explicit graphml ;
|
||||
|
||||
lib boost_graph
|
||||
:
|
||||
read_graphviz_new.cpp
|
||||
graphml
|
||||
graphml.cpp
|
||||
:
|
||||
<library>../../regex/build//boost_regex
|
||||
<define>BOOST_GRAPH_NO_LIB=1
|
||||
<link>shared:<define>BOOST_GRAPH_DYN_LINK=1
|
||||
# # Intel compiler ICEs if we turn optimization on
|
||||
<toolset>intel-vc71-win-9.1:<optimization>off
|
||||
# Without these flags, MSVC 7.1 and 8.0 crash
|
||||
# User reports that VC++ 8.0 does not fail anymore, so that is removed
|
||||
<toolset>msvc-7.1:<cxxflags>-GR-
|
||||
<toolset>msvc-8.0:<cxxflags>-GR-
|
||||
:
|
||||
:
|
||||
;
|
||||
|
||||
boost-install boost_graph ;
|
||||
|
||||
@@ -49,7 +49,7 @@ taken during the graph search.
|
||||
|
||||
<TR>
|
||||
<TD><tt>g</tt></TD>
|
||||
<TD>An object of type <tt>G</tt>.</TD>
|
||||
<TD>An object of type <tt>const G&</tt>.</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
@@ -118,7 +118,7 @@ OPEN list.
|
||||
<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
|
||||
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>.
|
||||
@@ -160,7 +160,7 @@ assert(compare(combine(d_u, w_e), d_s));
|
||||
<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
|
||||
Upon examination, if an edge is not relaxed (see above) then this
|
||||
method is invoked.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -171,7 +171,7 @@ method is invoked.
|
||||
<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
|
||||
``rediscovered'' via a more efficient path and is re-added to the
|
||||
OPEN list.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -181,8 +181,8 @@ OPEN list.
|
||||
<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.
|
||||
This is invoked on a vertex when it is added to the CLOSED list. This
|
||||
happens after all of its out-edges have been examined.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ edges for undirected graphs.
|
||||
<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
|
||||
This is invoked on the subset of non-tree edges whose target vertex is
|
||||
colored gray at the time of examination. The color gray indicates
|
||||
that the vertex is currently in the queue.
|
||||
</td>
|
||||
@@ -151,7 +151,7 @@ that the vertex is currently in the queue.
|
||||
<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
|
||||
This is invoked on the subset of non-tree edges whose target vertex is
|
||||
colored black at the time of examination. The color black indicates
|
||||
that the vertex has been removed from the queue.
|
||||
</td>
|
||||
|
||||
@@ -116,8 +116,8 @@ this method is invoked.
|
||||
<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
|
||||
After <tt>num_vertices(g)</tt> iterations through the edge set
|
||||
of the graph are completed, one last iteration is made to test whether
|
||||
each edge was minimized. If the edge is minimized then this function
|
||||
is invoked.
|
||||
</td>
|
||||
|
||||
@@ -157,7 +157,7 @@ undirected graph this method is never called.
|
||||
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
|
||||
the <tt>finish_vertex</tt> function is called on <tt>u</tt> after
|
||||
all the out-edges of <tt>u</tt> have been examined.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
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
|
||||
EventVisitors 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.
|
||||
|
||||
@@ -91,7 +91,7 @@ Now we can pass the resulting visitor object into
|
||||
color.begin());
|
||||
</pre>
|
||||
|
||||
For creating a list of more than two event visitors, nest calls to
|
||||
For creating a list of more than two event visitors, you can nest calls to
|
||||
<tt>std::make_pair</tt> in the following way:
|
||||
|
||||
<pre>
|
||||
|
||||
@@ -22,7 +22,7 @@ PropertyGraph
|
||||
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
|
||||
to identify which property is being accessed. The graph provides a
|
||||
function which returns a property map object.
|
||||
|
||||
<P>
|
||||
|
||||
@@ -37,7 +37,7 @@ href="#fig:adj-list-graph">Figure 1</a> shows an adjacency list
|
||||
representation of a directed graph.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:adj-list-graph"></A><A NAME="1509"></A>
|
||||
<DIV ALIGN="center"><A NAME="fig:adj-list-graph"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG> Adjacency List Representation of a Directed Graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/adj-matrix-graph2.gif" width="386" height="284"></TD>
|
||||
@@ -67,7 +67,7 @@ href="#fig:undir-adj-list-graph">Figure 2</a> shows an adjacency list
|
||||
representation of an undirected graph.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:undir-adj-list-graph"></A><A NAME="1509"></A>
|
||||
<DIV ALIGN="center"><A NAME="fig:undir-adj-list-graph"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 2:</STRONG> Adjacency List Representation of an Undirected Graph.</CAPTION>
|
||||
<TR><TD><IMG SRC="./figs/undir-adj-matrix-graph2.gif" width="260" height="240"></TD>
|
||||
@@ -763,8 +763,10 @@ std::pair<edge_descriptor, bool>
|
||||
edge(vertex_descriptor u, vertex_descriptor v,
|
||||
const adjacency_list& g)
|
||||
</pre>
|
||||
Returns an edge connecting vertex <tt>u</tt> to vertex <tt>v</tt> in
|
||||
graph <tt>g</tt>.
|
||||
If an edge from vertex <tt>u</tt> to vertex <tt>v</tt> exists, return a pair
|
||||
containing one such edge and <tt>true</tt>. If there are no edges between
|
||||
<tt>u</tt> and <tt>v</tt>, return a pair with an arbitrary edge descriptor and
|
||||
<tt>false</tt>.
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ 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>
|
||||
<DIV ALIGN="center"><A NAME="fig:adj-matrix-graph"></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>
|
||||
@@ -72,7 +72,7 @@ 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>
|
||||
<DIV ALIGN="center"><A NAME="fig:undir-adj-matrix-graph"></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>
|
||||
|
||||
@@ -22,13 +22,22 @@
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// Named parameter interface</i>
|
||||
<i>// Named parameter interfaces</i>
|
||||
template <typename VertexListGraph,
|
||||
typename AStarHeuristic,
|
||||
typename P, typename T, typename R>
|
||||
void
|
||||
astar_search
|
||||
(VertexListGraph &g,
|
||||
(const VertexListGraph &g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
<a href="AStarHeuristic.html">AStarHeuristic</a> h, const bgl_named_params<P, T, R>& params);
|
||||
|
||||
template <typename VertexListGraph,
|
||||
typename AStarHeuristic,
|
||||
typename P, typename T, typename R>
|
||||
void
|
||||
astar_search_no_init
|
||||
(const VertexListGraph &g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
<a href="AStarHeuristic.html">AStarHeuristic</a> h, const bgl_named_params<P, T, R>& params);
|
||||
|
||||
@@ -42,7 +51,7 @@ template <typename VertexListGraph, typename AStarHeuristic,
|
||||
typename CostInf, typename CostZero>
|
||||
inline void
|
||||
astar_search
|
||||
(VertexListGraph &g,
|
||||
(const VertexListGraph &g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
AStarHeuristic h, AStarVisitor vis,
|
||||
PredecessorMap predecessor, CostMap cost,
|
||||
@@ -52,7 +61,7 @@ astar_search
|
||||
CostInf inf, CostZero zero);
|
||||
|
||||
<i>// Version that does not initialize property maps (used for implicit graphs)</i>
|
||||
template <typename VertexListGraph, typename AStarHeuristic,
|
||||
template <typename IncidenceGraph, typename AStarHeuristic,
|
||||
typename <a href="AStarVisitor.html">AStarVisitor</a>, typename PredecessorMap,
|
||||
typename CostMap, typename DistanceMap,
|
||||
typename WeightMap, typename ColorMap,
|
||||
@@ -61,14 +70,18 @@ template <typename VertexListGraph, typename AStarHeuristic,
|
||||
typename CostInf, typename CostZero>
|
||||
inline void
|
||||
astar_search_no_init
|
||||
(VertexListGraph &g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
(const IncidenceGraph &g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
AStarHeuristic h, AStarVisitor vis,
|
||||
PredecessorMap predecessor, CostMap cost,
|
||||
DistanceMap distance, WeightMap weight,
|
||||
ColorMap color, VertexIndexMap index_map,
|
||||
CompareFunction compare, CombineFunction combine,
|
||||
CostInf inf, CostZero zero);
|
||||
|
||||
<b>Note that the index_map and color parameters are swapped in
|
||||
astar_search_no_init() relative to astar_search(); the named parameter
|
||||
interfaces are not affected.</b>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
@@ -107,14 +120,17 @@ 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
|
||||
useful for searching large state spaces -- in game-playing 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. Please note that
|
||||
<tt>astar_search_no_init()</tt> must be used for implicit graphs; the basic
|
||||
<tt>astar_search()</tt> function requires a graph that models
|
||||
<a href="VertexListGraph.html"><tt>VertexListGraph</tt></a>.
|
||||
the <a href="VertexListGraph.html">Vertex List Graph</a> concept. Both
|
||||
versions
|
||||
also require the graph type to model the <a
|
||||
href="IncidenceGraph.html">Incidence Graph</a> concept.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
@@ -225,12 +241,21 @@ finish vertex <i>u</i>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
IN: <tt>VertexListGraph& g</tt>
|
||||
IN: <tt>const VertexListGraph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied. The type
|
||||
The graph object on which the algorithm will be applied for <tt>astar_search()</tt>. The type
|
||||
<tt>VertexListGraph</tt> must be a model of the <a
|
||||
href="VertexListGraph.html">
|
||||
Vertex List Graph</a> concept.
|
||||
Vertex List Graph</a> and <a href="IncidenceGraph.html">Incidence Graph</a>
|
||||
concepts.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>const IncidenceGraph& g</tt>
|
||||
<blockquote>
|
||||
The graph object on which the algorithm will be applied for <tt>astar_search_no_init()</tt>. The type
|
||||
<tt>IncidenceGraph</tt> must be a model of the
|
||||
<a href="IncidenceGraph.html">Incidence Graph</a>
|
||||
concept.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>vertex_descriptor s</tt>
|
||||
@@ -278,7 +303,7 @@ IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt>.
|
||||
Note: if you use this default, make sure your graph has
|
||||
an internal <tt>vertex_index</tt> property. For example,
|
||||
<tt>adjacenty_list</tt> with <tt>VertexList=listS</tt> does
|
||||
<tt>adjacency_list</tt> with <tt>VertexList=listS</tt> does
|
||||
not have an internal <tt>vertex_index</tt> property.
|
||||
</blockquote>
|
||||
|
||||
@@ -315,8 +340,8 @@ UTIL/OUT: <tt>distance_map(DistanceMap d_map)</tt>
|
||||
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
|
||||
<b>Default:</b> <tt>shared_array_property_map</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>
|
||||
@@ -341,9 +366,9 @@ UTIL/OUT: <tt>rank_map(CostMap c_map)</tt>
|
||||
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
|
||||
<b>Default:</b> <tt>shared_array_property_map</tt>
|
||||
with the same value type as the
|
||||
<tt>DistanceMap</tt>, and of size <tt>num_vertices(g)</tt>, and using
|
||||
the <tt>i_map</tt> for the index map.
|
||||
</blockquote>
|
||||
|
||||
@@ -363,10 +388,10 @@ UTIL/OUT: <tt>color_map(ColorMap c_map)</tt>
|
||||
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.
|
||||
<b>Default:</b> <tt>shared_array_property_map</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>
|
||||
@@ -458,7 +483,7 @@ The time complexity is <i>O((E + V) log V)</i>.
|
||||
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>.
|
||||
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(e, g)</tt></b>
|
||||
|
||||
@@ -61,7 +61,7 @@ clustering based on edge betweenness centrality.</p>
|
||||
<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=
|
||||
step it computes 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
|
||||
|
||||
@@ -22,7 +22,7 @@ bellman_visitor<EventVisitorList>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
href="./EventVisitor.html">EventVisitor</a>s (constructed using
|
||||
<tt>std::pair</tt>) into a <a
|
||||
href="./BellmanFordVisitor.html">BellmanFordVisitor</a>.
|
||||
|
||||
@@ -63,7 +63,7 @@ with <tt>std::pair</tt>.
|
||||
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.
|
||||
href="./EventVisitor.html">EventVisitor</a> in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ bfs_visitor<EventVisitorList>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
href="./EventVisitor.html">EventVisitor</a>s (constructed using
|
||||
<tt>std::pair</tt>) into a <a href="./BFSVisitor.html">BFSVisitor</a>.
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ with <tt>std::pair</tt>.
|
||||
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.
|
||||
href="./EventVisitor.html">EventVisitor</a> in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ 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.
|
||||
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>
|
||||
@@ -409,7 +409,7 @@ PhD thesis, Cornell University, September 2003.
|
||||
<p></p><dt><a name="boykov-kolmogorov04">69</a>
|
||||
<dd>Yuri Boykov and Vladimir Kolmogorov<br>
|
||||
<em><a href="http://www.csd.uwo.ca/faculty/yuri/Abstracts/pami04-abs.html">An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision</a></em><br>
|
||||
In IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 26, no. 9, pp. 1124-1137, Sept. 2004.
|
||||
In <em>IEEE Transactions on Pattern Analysis and Machine Intelligence</em>, vol. 26, no. 9, pp. 1124-1137, Sept. 2004.
|
||||
|
||||
<p></p><dt><a name="boyermyrvold04">70</a>
|
||||
<dd>John M. Boyer and Wendy J. Myrvold<br>
|
||||
@@ -432,6 +432,12 @@ How to Draw a Planar Graph on a Grid
|
||||
</em><br>
|
||||
Combinatorica 10: 41-51, 1990.
|
||||
|
||||
<P></P><DT><A NAME="wilson96generating">73</A>
|
||||
<DD>
|
||||
David Bruce Wilson
|
||||
<BR><em>Generating random spanning trees more quickly than the cover time</em>.
|
||||
ACM Symposium on the Theory of Computing, pp. 296-303, 1996.
|
||||
|
||||
</dl>
|
||||
|
||||
<br>
|
||||
|
||||
@@ -239,6 +239,15 @@ href="../example/biconnected_components.cpp"><tt>examples/biconnected_components
|
||||
contains an example of calculating the biconnected components and
|
||||
articulation points of an undirected graph.
|
||||
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-15">
|
||||
<TITLE>Boost Graph Library: Boykov-Kolmogorov Maximum Flow</TITLE>
|
||||
<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.0 (Linux)">
|
||||
<META NAME="CREATED" CONTENT="20060820;17315200">
|
||||
<META NAME="CHANGEDBY" CONTENT="Stephan Diederich">
|
||||
<META NAME="CHANGED" CONTENT="20060820;23125100">
|
||||
<!--
|
||||
// Copyright (c) 2006 Stephan Diederich
|
||||
//
|
||||
// This documentation may be used under either of the following two licences:
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE. OF SUCH DAMAGE.
|
||||
//
|
||||
// Or:
|
||||
//
|
||||
// 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)
|
||||
-->
|
||||
<STYLE>
|
||||
<!--
|
||||
TD P { color: #000000 }
|
||||
H1 { color: #000000 }
|
||||
P { color: #000000 }
|
||||
PRE { color: #000000 }
|
||||
H3 { color: #000000 }
|
||||
BLOCKQUOTE { color: #000000 }
|
||||
A:link { color: #0000ee }
|
||||
A:visited { color: #551a8b }
|
||||
-->
|
||||
</STYLE>
|
||||
</HEAD>
|
||||
<BODY LANG="de-DE" TEXT="#000000" LINK="#0000ee" VLINK="#551a8b" BGCOLOR="#ffffff" DIR="LTR">
|
||||
<P><IMG SRC="../../../boost.png" NAME="Grafik1" ALT="C++ Boost" ALIGN=BOTTOM WIDTH=277 HEIGHT=86 BORDER=0>
|
||||
</P>
|
||||
<H1><A NAME="sec:boykov_kolmogorov_max_flow"></A><TT>boykov_kolmogorov_max_flow</TT>
|
||||
</H1>
|
||||
<PRE><I>// named parameter version</I>
|
||||
template <class Graph, class P, class T, class R>
|
||||
typename property_traits<typename property_map<Graph, edge_capacity_t>::const_type>::value_type
|
||||
boykov_kolmogorov_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 Graph, class CapacityEdgeMap, class ResidualCapacityEdgeMap, class ReverseEdgeMap,
|
||||
class PredecessorMap, class ColorMap, class DistanceMap, class IndexMap>
|
||||
typename property_traits<CapacityEdgeMap>::value_type
|
||||
boykov_kolmogorov_max_flow(Graph& g,
|
||||
CapacityEdgeMap cap,
|
||||
ResidualCapacityEdgeMap res_cap,
|
||||
ReverseEdgeMap rev_map,
|
||||
PredecessorMap pre_map,
|
||||
ColorMap color,
|
||||
DistanceMap dist,
|
||||
IndexMap idx,
|
||||
typename graph_traits <Graph>::vertex_descriptor src,
|
||||
typename graph_traits <Graph >::vertex_descriptor sink)</PRE><P>
|
||||
<FONT SIZE=3>Additional overloaded versions for non-named parameters
|
||||
are provided (without DistanceMap/ColorMap/DistanceMap; for those
|
||||
iterator_property_maps with the provided index map are used)</FONT></P>
|
||||
<P>The <TT>boykov_kolmogorov_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>
|
||||
<P><B>Requirements:</B><BR>The directed graph <I>G=(V,E)</I> that
|
||||
represents the network must include a 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>.
|
||||
</P>
|
||||
|
||||
<P>Remarks: While the push-relabel method states that each edge in <I>E<SUP>T</SUP></I>
|
||||
has to have capacity of 0, the reverse edges for this algorithm ARE
|
||||
allowed to carry capacities. If there are already reverse edges in
|
||||
the input Graph <I><FONT FACE="Courier New, monospace">G</FONT></I>,
|
||||
those can be used. This can halve the amount of edges and will
|
||||
noticeably increase the performance.</P>
|
||||
|
||||
<P>
|
||||
<B>Algorithm description:</B><BR>The Boykov-Kolmogorov max-flow (or often
|
||||
BK max-flow) algorithm is a variety of the augmenting-path algorithm. Standard
|
||||
augmenting path algorithms find shortest paths from source to sink vertex and
|
||||
augment them by substracting the bottleneck capacity found on that path from the
|
||||
residual capacities of each edge and adding it to the total flow. Additionally
|
||||
the minimum capacity is added to the residual capacity of the reverse edges. If
|
||||
no more paths in the residual-edge tree are found, the algorithm terminates.
|
||||
Instead of finding a new shortest path from source to sink in the graph in each
|
||||
iteration, the Boykov-Kolmogorov algorithm keeps the already found paths as
|
||||
follows:</P>
|
||||
|
||||
<P>The algorithm builds up two search trees, a source-tree and a
|
||||
sink-tree. Each vertex has a label (stored in <I>ColorMap</I>) to
|
||||
which tree it belongs and a status-flag if this vertex is active or
|
||||
passive. In the beginning of the algorithm only the source and the
|
||||
sink are colored (source==black, sink==white) and have active status.
|
||||
All other vertices are colored gray. The algorithm consists of three
|
||||
phases:</P>
|
||||
<P><I>grow-phase</I>: In this phase active vertices are allowed to
|
||||
acquire neighbor vertices that are connected through an edge that has
|
||||
a capacity-value greater than zero. Acquiring means that those vertices
|
||||
become active and belong now to the search tree of the current
|
||||
active vertex. If there are no more valid connections to neighbor
|
||||
vertices, the current vertex becomes passive and the grow phase
|
||||
continues with the next active vertex. The grow phase terminates if
|
||||
there are no more active vertices left or a vertex discovers a vertex
|
||||
from the other search tree through an unsaturated edge. In this case
|
||||
a path from source to sink is found.</P>
|
||||
<P><I>augment-phase</I>: This phase augments the path that was found
|
||||
in the grow phase. First it finds the bottleneck capacity of the
|
||||
found path, and then it updates the residual-capacity of the edges
|
||||
from this path by substracting the bottleneck capacity from the
|
||||
residual capacity. Furthermore the residual capacity of the reverse
|
||||
edges are updated by adding the bottleneck capacity. This phase can
|
||||
destroy the built up search trees, as it creates at least one
|
||||
saturated edge. That means, that the search trees collapse to
|
||||
forests, because a condition for the search trees is, that each
|
||||
vertex in them has a valid (=non-saturated) connection to a terminal.</P>
|
||||
<P><I>adoption-phase</I>: Here the search trees are reconstructed. A
|
||||
simple solution would be to mark all vertices coming after the first
|
||||
orphan in the found path free vertices (gray). A more sophisticated
|
||||
solution is to give those orphans new parents: The neighbor vertices
|
||||
are checked if they have a valid connection to the same terminal like
|
||||
this vertex had (a path with unsaturated edges). If there is one,
|
||||
this vertex becomes the new parent of the current orphan and this
|
||||
forest is re-included into the search tree. If no new valid parent is
|
||||
found, this vertex becomes a free vertex (marked gray), and it's
|
||||
children become orphans. The adoption phase terminates if there are
|
||||
no more orphans.</P>
|
||||
<P><IMG SRC="figs/bk_max_flow.gif" NAME="Grafik2" ALIGN=LEFT WIDTH=827 HEIGHT=311 BORDER=0><BR CLEAR=LEFT><B>Details:</B></P>
|
||||
<UL>
|
||||
<LI><P>Marking heuristics: A timestamp is stored for each vertex
|
||||
which shows in which iteration of the algorithm the distance to the
|
||||
corresponding terminal was calculated.
|
||||
</P>
|
||||
<UL>
|
||||
<LI><P>This distance is used and gets calculated in the
|
||||
adoption-phase. In order to find a valid new parent for an orphan,
|
||||
the possible parent is checked for a connection to the terminal to
|
||||
which tree it belongs. If there is such a connection, the path is
|
||||
tagged with the current time-stamp, and the distance value. If
|
||||
another orphan has to find a parent and it comes across a vertex
|
||||
with a current timestamp, this information is used.</P>
|
||||
<LI><P>The distance is also used in the grow-phase. If a vertex
|
||||
comes across another vertex of the same tree while searching for
|
||||
new vertices, the other's distance is compared to its distance. If
|
||||
it is smaller, that other vertex becomes the new parent of the
|
||||
current. This can decrease the length of the search paths, and so
|
||||
amount of adoptions.</P>
|
||||
</UL>
|
||||
<LI><P>Ordering of orphans: As described above, the augment-phase
|
||||
and the adoption phase can create orphans. The orphans the
|
||||
augment-phase generates, are ordered according to their distance to
|
||||
the terminals (smallest first). This combined with the
|
||||
distance/timestamp heuristics results in the possibility for not
|
||||
having to recheck terminal-connections too often. New orphans which
|
||||
are generated in adoption phase are processed before orphans from
|
||||
the main queue for the same reason.</P>
|
||||
</UL>
|
||||
<P><BR><B>Implementation notes:</B></P>
|
||||
<P>The algorithm is mainly implemented as described by Boykov and Kolmogorov in
|
||||
[<a href="bibliography.html#boykov-kolmogorov04">69</a>]. An extended version
|
||||
can be found in the PhD Thesis of Kolmogorov [<A HREF="bibliography.html#kolmogorov03">68</a>].
|
||||
The following changes are made to improve performance:</P>
|
||||
<UL>
|
||||
<LI>initialization: the algorithm first augments all paths from
|
||||
source->sink and all paths from source->VERTEX->sink. This
|
||||
improves especially graph-cuts used in image vision where nearly
|
||||
each vertex has a source and sink connect. During this step, all
|
||||
vertices that have an unsaturated connection from source are added
|
||||
to the active vertex list and so the source is not.</LI>
|
||||
<LI>active vertices: Boykov-Kolmogorov uses two lists for active nodes
|
||||
and states that new active vertices are added to the rear of the
|
||||
second. Fetching an active vertex is done from the beginning of the
|
||||
first list. If the first list is empty, it is exchanged by the
|
||||
second. This implementation uses just one list.</LI>
|
||||
<LI>grow-phase: In the grow phase the first vertex in the
|
||||
active-list is taken and all outgoing edges are checked if they are
|
||||
unsaturated. This decreases performance for graphs with high-edge
|
||||
density. This implementation stores the last accessed edge and
|
||||
continues with it, if the first vertex in the active-list is the
|
||||
same one as during the last grow-phase.</LI>
|
||||
</UL>
|
||||
<H3>Where Defined</H3>
|
||||
<P><TT><A HREF="../../../boost/graph/boykov_kolmogorov_max_flow.hpp">boost/graph/boykov_kolmogorov_max_flow.hpp</A></TT>
|
||||
</P>
|
||||
<H3>Parameters</H3>
|
||||
<P>IN: <TT>Graph& g</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A directed graph. The graph's type must be a model of
|
||||
<A HREF="VertexListGraph.html">Vertex List Graph</A>, <A HREF="EdgeListGraph.html">Edge
|
||||
List Graph</A> and <A HREF="IncidenceGraph.html">Incidence Graph</A>.
|
||||
For each edge <I>(u,v)</I> in the graph, the reverse edge <I>(v,u)</I>
|
||||
must also be in the graph. Performance of the algorithm will be slightly
|
||||
improved if the graph type also models <a href="AdjacencyMatrix.html">Adjacency
|
||||
Matrix</a>.
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>vertex_descriptor src</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The source vertex for the flow network graph.
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>vertex_descriptor sink</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The sink vertex for the flow network graph.
|
||||
</BLOCKQUOTE>
|
||||
<H3>Named Parameters</H3>
|
||||
<P>IN: <TT>edge_capacity(EdgeCapacityMap cap)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The edge capacity property map. The type must be a model
|
||||
of a constant <A HREF="../../property_map/doc/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>
|
||||
<P>OUT: <TT>edge_residual_capacity(ResidualCapacityEdgeMap res)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The edge residual capacity property map. The type must be
|
||||
a model of a mutable <A HREF="../../property_map/doc/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>
|
||||
<P>IN: <TT>edge_reverse(ReverseEdgeMap rev)</TT>
|
||||
</P>
|
||||
<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/doc/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>
|
||||
<P>UTIL: <TT>vertex_predecessor(PredecessorMap pre_map)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A vertex property map that stores the edge to the vertex'
|
||||
predecessor. The map must be a model of mutable <A HREF="../../property_map/doc/LvaluePropertyMap.html">Lvalue
|
||||
Property Map</A>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_predecessor, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>OUT/UTIL: <TT>vertex_color(ColorMap color)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A vertex property map that stores a color for edge
|
||||
vertex. If the color of a vertex after running the algorithm is black
|
||||
the vertex belongs to the source tree else it belongs to the
|
||||
sink-tree (used for minimum cuts). The map must be a model of mutable
|
||||
<A HREF="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</A>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_color, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>UTIL: <TT>vertex_distance(DistanceMap dist)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A vertex property map that stores the distance to the
|
||||
corresponding terminal. It's a utility-map for speeding up the
|
||||
algorithm. The map must be a model of mutable <A HREF="../../property_map/doc/LvaluePropertyMap.html">Lvalue
|
||||
Property Map</A>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_distance, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>vertex_index(VertexIndexMap index_map)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>Maps each vertex of the graph to a unique integer in the
|
||||
range <TT>[0, num_vertices(g))</TT>. The map must be a model of
|
||||
constant <A HREF="../../property_map/doc/LvaluePropertyMap.html">LvaluePropertyMap</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>Example</H3>
|
||||
<P>This reads an example maximum flow problem (a graph with edge
|
||||
capacities) from a file in the DIMACS format (<TT><A HREF="../example/max_flow.dat">example/max_flow.dat</A></TT>).
|
||||
The source for this example can be found in
|
||||
<TT><A HREF="../example/boykov_kolmogorov-eg.cpp">example/boykov_kolmogorov-eg.cpp</A></TT>.
|
||||
</P>
|
||||
<PRE>#include <boost/config.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
|
||||
#include <boost/graph/read_dimacs.hpp>
|
||||
#include <boost/graph/graph_utility.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
typedef adjacency_list_traits < vecS, vecS, directedS > Traits;
|
||||
typedef adjacency_list < vecS, vecS, directedS,
|
||||
property < vertex_name_t, std::string,
|
||||
property < vertex_index_t, long,
|
||||
property < vertex_color_t, boost::default_color_type,
|
||||
property < vertex_distance_t, long,
|
||||
property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
|
||||
|
||||
property < edge_capacity_t, long,
|
||||
property < edge_residual_capacity_t, long,
|
||||
property < edge_reverse_t, Traits::edge_descriptor > > > > Graph;
|
||||
|
||||
Graph g;
|
||||
property_map < Graph, edge_capacity_t >::type
|
||||
capacity = get(edge_capacity, g);
|
||||
property_map < Graph, edge_residual_capacity_t >::type
|
||||
residual_capacity = get(edge_residual_capacity, g);
|
||||
property_map < Graph, edge_reverse_t >::type rev = get(edge_reverse, g);
|
||||
Traits::vertex_descriptor s, t;
|
||||
read_dimacs_max_flow(g, capacity, rev, s, t);
|
||||
|
||||
std::vector<default_color_type> color(num_vertices(g));
|
||||
std::vector<long> distance(num_vertices(g));
|
||||
long flow = boykov_kolmogorov_max_flow(g ,s, t);
|
||||
|
||||
std::cout << "c The total flow:" << std::endl;
|
||||
std::cout << "s " << flow << std::endl << std::endl;
|
||||
|
||||
std::cout << "c flow values:" << std::endl;
|
||||
graph_traits < Graph >::vertex_iterator u_iter, u_end;
|
||||
graph_traits < Graph >::out_edge_iterator ei, e_end;
|
||||
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
|
||||
for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
|
||||
if (capacity[*ei] > 0)
|
||||
std::cout << "f " << *u_iter << " " << target(*ei, g) << " "
|
||||
<< (capacity[*ei] - residual_capacity[*ei]) << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}</PRE><P>
|
||||
The output is:
|
||||
</P>
|
||||
<PRE>c The total flow:
|
||||
s 13
|
||||
|
||||
c flow values:
|
||||
f 0 6 3
|
||||
f 0 1 0
|
||||
f 0 2 10
|
||||
f 1 5 1
|
||||
f 1 0 0
|
||||
f 1 3 0
|
||||
f 2 4 4
|
||||
f 2 3 6
|
||||
f 2 0 0
|
||||
f 3 7 5
|
||||
f 3 2 0
|
||||
f 3 1 1
|
||||
f 4 5 4
|
||||
f 4 6 0
|
||||
f 5 4 0
|
||||
f 5 7 5
|
||||
f 6 7 3
|
||||
f 6 4 0
|
||||
f 7 6 0
|
||||
f 7 5 0</PRE><H3>
|
||||
See Also</H3>
|
||||
<P STYLE="margin-bottom: 0cm">
|
||||
<TT><A HREF="edmonds_karp_max_flow.html">edmonds_karp_max_flow()</A></TT>,
|
||||
<TT><A HREF="push_relabel_max_flow.html">push_relabel_max_flow()</A></TT>.
|
||||
</P>
|
||||
<HR>
|
||||
<TABLE CELLPADDING=2 CELLSPACING=2>
|
||||
<TR VALIGN=TOP>
|
||||
<TD>
|
||||
<P>Copyright © 2006</P>
|
||||
</TD>
|
||||
<TD>
|
||||
<P>Stephan Diederich, University
|
||||
Mannheim(<A HREF="mailto:diederich@ti.uni-manheim.de">diederich@ti.uni-manheim.de</A>)</P>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<P><BR><BR>
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -49,17 +49,6 @@ function address(host, user) {
|
||||
applications or for very large graphs that you do not need to
|
||||
change.</p>
|
||||
|
||||
<p>There are two interfaces to the compressed sparse row graph. The
|
||||
old interface requires that all out edges from a single vertex are
|
||||
sorted by target, and does not support construction of the graph from
|
||||
unsorted arrays of sources and targets. The new interface has these
|
||||
new constructors, but does not support incremental construction of the
|
||||
graph or the <tt>edge_range()</tt> and <tt>edge()</tt> functions. The
|
||||
old interface is the default, but will be removed in a later version of
|
||||
Boost. To select the new interface, add <tt>#define
|
||||
BOOST_GRAPH_USE_NEW_CSR_INTERFACE</tt> before including
|
||||
<tt><boost/graph/compressed_sparse_row_graph.hpp></tt>.</p>
|
||||
|
||||
<p>The CSR format stores vertices and edges in separate arrays,
|
||||
with the indices into these arrays corresponding to the identifier
|
||||
for the vertex or edge, respectively. The edge array is sorted by
|
||||
@@ -79,8 +68,8 @@ function address(host, user) {
|
||||
the <a href="#template-parms">template parameters</a>. The
|
||||
<tt>Directed</tt> template parameter controls whether one edge direction
|
||||
(the default) or both directions are stored. A directed CSR graph has
|
||||
<tt>Directed</tt> = <tt>directedS</tt> and a bidirectional CSR graph (only
|
||||
supported with the new interface and with a limited set of constructors)
|
||||
<tt>Directed</tt> = <tt>directedS</tt> and a bidirectional CSR graph (with
|
||||
a limited set of constructors)
|
||||
has <tt>Directed</tt> = <tt>bidirectionalS</tt>.</p>
|
||||
|
||||
<ul>
|
||||
@@ -121,7 +110,7 @@ public:
|
||||
<i>// <a href="#constructors">Graph constructors</a></i>
|
||||
<a href="#default-const">compressed_sparse_row_graph</a>();
|
||||
|
||||
<i>// Unsorted edge list constructors <b>(new interface only)</b></i>
|
||||
<i>// Unsorted edge list constructors </i>
|
||||
template<typename InputIterator>
|
||||
<a href="#edge-const">compressed_sparse_row_graph</a>(edges_are_unsorted_t,
|
||||
InputIterator edge_begin, InputIterator edge_end,
|
||||
@@ -148,21 +137,7 @@ public:
|
||||
vertices_size_type numverts,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// Old sorted edge list constructors <b>(old interface only)</b></i>
|
||||
template<typename InputIterator>
|
||||
<a href="#edge-sorted-const">compressed_sparse_row_graph</a>(InputIterator edge_begin, InputIterator edge_end,
|
||||
vertices_size_type numverts,
|
||||
edges_size_type numedges = 0,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
template<typename InputIterator, typename EdgePropertyIterator>
|
||||
<a href="#edge-sorted-prop-const">compressed_sparse_row_graph</a>(InputIterator edge_begin, InputIterator edge_end,
|
||||
EdgePropertyIterator ep_iter,
|
||||
vertices_size_type numverts,
|
||||
edges_size_type numedges = 0,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// New sorted edge list constructors <b>(both interfaces, directed only)</b></i>
|
||||
<i>// New sorted edge list constructors <b>(directed only)</b></i>
|
||||
template<typename InputIterator>
|
||||
<a href="#edge-sorted-const">compressed_sparse_row_graph</a>(edges_are_sorted_t,
|
||||
InputIterator edge_begin, InputIterator edge_end,
|
||||
@@ -178,7 +153,7 @@ public:
|
||||
edges_size_type numedges = 0,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// In-place unsorted edge list constructors <b>(new interface and directed only)</b></i>
|
||||
<i>// In-place unsorted edge list constructors <b>(directed only)</b></i>
|
||||
template<typename InputIterator>
|
||||
<a href="#edge-inplace-const">compressed_sparse_row_graph</a>(construct_inplace_from_sources_and_targets_t,
|
||||
std::vector<vertex_descriptor>& sources,
|
||||
@@ -194,7 +169,7 @@ public:
|
||||
vertices_size_type numverts,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// Miscellaneous constructors <b>(both interfaces, directed only)</b></i>
|
||||
<i>// Miscellaneous constructors <b>(directed only)</b></i>
|
||||
template<typename Graph, typename VertexIndexMap>
|
||||
<a href="#graph-const">compressed_sparse_row_graph</a>(const Graph& g, const VertexIndexMap& vi,
|
||||
vertices_size_type numverts,
|
||||
@@ -206,7 +181,7 @@ public:
|
||||
template<typename Graph>
|
||||
explicit <a href="#graph-const">compressed_sparse_row_graph</a>(const Graph& g);
|
||||
|
||||
<i>// <a href="#mutators">Graph mutators <b>(both interfaces, directed only)</b></a></i>
|
||||
<i>// <a href="#mutators">Graph mutators <b>(directed only)</b></a></i>
|
||||
template<typename Graph, typename VertexIndexMap>
|
||||
void <a href="#assign">assign</a>(const Graph& g, const VertexIndexMap& vi,
|
||||
vertices_size_type numverts, edges_size_type numedges);
|
||||
@@ -217,51 +192,46 @@ public:
|
||||
template<typename Graph>
|
||||
void <a href="#assign">assign</a>(const Graph& g);
|
||||
|
||||
<i>// <a href="#property-access">Property Access <b>(both interfaces)</b></a></i>
|
||||
<i>// <a href="#property-access">Property Access</a></i>
|
||||
VertexProperty& <a href="#vertex-subscript">operator[]</a>(vertex_descriptor v);
|
||||
const VertexProperty& <a href="#vertex-subscript">operator[]</a>(vertex_descriptor v) const;
|
||||
EdgeProperty& <a href="#edge-subscript">operator[]</a>(edge_descriptor v);
|
||||
const EdgeProperty& <a href="#edge-subscript">operator[]</a>(edge_descriptor v) const;
|
||||
};
|
||||
|
||||
<i>// <a href="IncidenceGraph.html">Incidence Graph requirements <b>(both interfaces)</b></a></i>
|
||||
<i>// <a href="IncidenceGraph.html">Incidence Graph requirements</a></i>
|
||||
vertex_descriptor source(edge_descriptor, const compressed_sparse_row_graph&);
|
||||
vertex_descriptor target(edge_descriptor, const compressed_sparse_row_graph&);
|
||||
std::pair<out_edge_iterator, out_edge_iterator>
|
||||
out_edges(vertex_descriptor, const compressed_sparse_row_graph&);
|
||||
degree_size_type out_degree(vertex_descriptor v, const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="BidirectionalGraph.html">Bidirectional Graph requirements <b>(new interface and bidirectional only)</b></a></i>
|
||||
<i>// <a href="BidirectionalGraph.html">Bidirectional Graph requirements <b>(bidirectional only)</b></a></i>
|
||||
std::pair<in_edge_iterator, in_edge_iterator>
|
||||
in_edges(vertex_descriptor, const compressed_sparse_row_graph&);
|
||||
degree_size_type in_degree(vertex_descriptor v, const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="AdjacencyGraph.html">Adjacency Graph requirements <b>(both interfaces)</b></a></i>
|
||||
<i>// <a href="AdjacencyGraph.html">Adjacency Graph requirements</a></i>
|
||||
std::pair<adjacency_iterator, adjacency_iterator>
|
||||
adjacent_vertices(vertex_descriptor, const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="VertexListGraph.html">Vertex List Graph requirements <b>(both interfaces)</b></a></i>
|
||||
<i>// <a href="VertexListGraph.html">Vertex List Graph requirements</a></i>
|
||||
std::pair<vertex_iterator, vertex_iterator> vertices(const compressed_sparse_row_graph&);
|
||||
vertices_size_type num_vertices(const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="EdgeListGraph.html">Edge List Graph requirements <b>(both interfaces)</b></a></i>
|
||||
<i>// <a href="EdgeListGraph.html">Edge List Graph requirements</a></i>
|
||||
std::pair<edge_iterator, edge_iterator> edges(const compressed_sparse_row_graph&);
|
||||
edges_size_type num_edges(const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="#vertex-access">Vertex access <b>(both interfaces)</b></a></i>
|
||||
vertex_descriptor <a href="#vertex">vertex</a>(vertices_size_type i, const compressed_sparse_row_graph&);
|
||||
<i>// <a href="#vertex-access">Vertex access</a></i>
|
||||
vertex_descriptor <a href="#vertex-lookup">vertex</a>(vertices_size_type i, const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="#edge-access">Edge access</a></i>
|
||||
<b>(old interface only)</b>
|
||||
std::pair<out_edge_iterator, out_edge_iterator>
|
||||
<a href="#edge_range">edge_range</a>(vertex_descriptor u, vertex_descriptor v, const compressed_sparse_row_graph&);
|
||||
<b>(both interfaces)</b>
|
||||
std::pair<edge_descriptor, bool>
|
||||
<a href="#edge">edge</a>(vertex_descriptor u, vertex_descriptor v, const compressed_sparse_row_graph&);
|
||||
<b>(both interfaces)</b>
|
||||
edge_descriptor <a href="#edge_from_index">edge_from_index</a>(edges_size_type i, const compressed_sparse_row_graph&);
|
||||
|
||||
<i>// <a href="#property-map-accessors">Property map accessors <b>(both interfaces)</b></a></i>
|
||||
<i>// <a href="#property-map-accessors">Property map accessors</a></i>
|
||||
template<typename <a href="./PropertyTag.html">PropertyTag</a>>
|
||||
property_map<compressed_sparse_row_graph, PropertyTag>::type
|
||||
<a href="#get">get</a>(PropertyTag, compressed_sparse_row_graph& g)
|
||||
@@ -290,31 +260,19 @@ void <a href="#set_property">set_property</a>(const compressed_sparse_row_graph&
|
||||
const typename graph_property<compressed_sparse_row_graph, GraphPropertyTag>::type& value);
|
||||
|
||||
<i>// <a href="#incremental-construction-functions">Incremental construction functions</a></i>
|
||||
<b>(old interface only)</b>
|
||||
template<typename Graph>
|
||||
vertex_descriptor <a href="#add_vertex">add_vertex</a>(compressed_sparse_row_graph& g);
|
||||
|
||||
<b>(old interface only)</b>
|
||||
template<typename Graph>
|
||||
vertex_descriptor <a href="#add_vertices">add_vertices</a>(vertices_size_type count, compressed_sparse_row_graph& g);
|
||||
|
||||
<b>(old interface only)</b>
|
||||
template<typename Graph>
|
||||
edge_descriptor <a href="#add_edge">add_edge</a>(vertex_descriptor src, vertex_descriptor tgt, compressed_sparse_row_graph& g);
|
||||
|
||||
<b>(new interface and directed only)</b>
|
||||
<b>(directed only)</b>
|
||||
template<typename InputIterator, typename Graph>
|
||||
void <a href="#add_edges">add_edges</a>(InputIterator first, InputIterator last, compressed_sparse_row_graph& g);
|
||||
|
||||
<b>(new interface and directed only)</b>
|
||||
<b>(directed only)</b>
|
||||
template<typename InputIterator, typename EPIter, typename Graph>
|
||||
void <a href="#add_edges_prop">add_edges</a>(InputIterator first, InputIterator last, EPIter ep_first, EPIter ep_last, compressed_sparse_row_graph& g);
|
||||
|
||||
<b>(new interface and directed only)</b>
|
||||
<b>(directed only)</b>
|
||||
template<typename BidirectionalIterator, typename Graph>
|
||||
void <a href="#add_edges_sorted">add_edges_sorted</a>(BidirectionalIterator first, BidirectionalIterator last, compressed_sparse_row_graph& g);
|
||||
|
||||
<b>(new interface and directed only)</b>
|
||||
<b>(directed only)</b>
|
||||
template<typename BidirectionalIterator, typename EPIter, typename Graph>
|
||||
void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator first, BidirectionalIterator last, EPIter ep_iter, compressed_sparse_row_graph& g);
|
||||
|
||||
@@ -359,8 +317,9 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
<blockquote>
|
||||
A selector that determines whether the graph will be directed,
|
||||
bidirectional or undirected. At this time, the CSR graph type
|
||||
only supports directed graphs, so this value must
|
||||
be <code>boost::directedS</code>.<br>
|
||||
only supports directed and bidirectional graphs, so this value must
|
||||
be either <code>boost::directedS</code> or
|
||||
<code>boost::bidirectionalS</code>.<br>
|
||||
<b>Default</b>: <code>boost::directedS</code>
|
||||
</blockquote>
|
||||
|
||||
@@ -465,7 +424,6 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
edge_end)</code> do not need to be sorted. This constructor uses extra
|
||||
memory to save the edge information before adding it to the graph,
|
||||
avoiding the requirement for the iterator to have multi-pass capability.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<p class="indent">
|
||||
@@ -498,12 +456,11 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
<tt>edge_begin</tt> to <tt>edge_end</tt>. This constructor uses extra
|
||||
memory to save the edge information before adding it to the graph,
|
||||
avoiding the requirement for the iterator to have multi-pass capability.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="edge-const"></a>
|
||||
<pre><a name="edge-multi-const"></a>
|
||||
template<typename MultiPassInputIterator>
|
||||
compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
|
||||
MultiPassInputIterator edge_begin, MultiPassInputIterator edge_end,
|
||||
@@ -523,7 +480,6 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
numverts)</code>. The edges in <code>[edge_begin,
|
||||
edge_end)</code> do not need to be sorted. Multiple passes will be made
|
||||
over the edge range.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<p class="indent">
|
||||
@@ -533,7 +489,7 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="edge-prop-const"></a>
|
||||
<pre><a name="edge-multi-prop-const"></a>
|
||||
template<typename MultiPassInputIterator, typename EdgePropertyIterator>
|
||||
compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
|
||||
MultiPassInputIterator edge_begin, MultiPassInputIterator edge_end,
|
||||
@@ -555,7 +511,6 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
of the graph, where <tt>m</tt> is distance from
|
||||
<tt>edge_begin</tt> to <tt>edge_end</tt>. Multiple passes will be made
|
||||
over the edge and property ranges.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -584,9 +539,7 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
numverts)</code>. The edges in <code>[edge_begin,
|
||||
edge_end)</code> must be sorted so that all edges originating
|
||||
from vertex <i>i</i> preceed any edges originating from all
|
||||
vertices <i>j</i> where <i>j > i</i>. <b>(The version of this
|
||||
constructor without the <tt>edges_are_sorted</tt> tag is deprecated and
|
||||
only provided by the old interface.)</b>
|
||||
vertices <i>j</i> where <i>j > i</i>.
|
||||
</p>
|
||||
|
||||
<p class="indent">
|
||||
@@ -624,9 +577,7 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
<tt>EdgeProperty</tt>. The iterator range <tt>[ep_iter, ep_ter +
|
||||
m)</tt> will be used to initialize the properties on the edges
|
||||
of the graph, where <tt>m</tt> is distance from
|
||||
<tt>edge_begin</tt> to <tt>edge_end</tt>. <b>(The version of this
|
||||
constructor without the <tt>edges_are_sorted</tt> tag is deprecated and
|
||||
only provided by the old interface.)</b>
|
||||
<tt>edge_begin</tt> to <tt>edge_end</tt>.
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -647,7 +598,6 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
share storage with the constructed graph (and so are safe to destroy).
|
||||
The parameter <code>prop</code>, if provided, is used to initialize the
|
||||
graph property.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -670,12 +620,11 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
not share storage with the constructed graph (and so are safe to
|
||||
destroy). The parameter <code>prop</code>, if provided, is used to
|
||||
initialize the graph property.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="#graph-const"></a>
|
||||
<pre><a name="graph-const"></a>
|
||||
template<typename Graph, typename VertexIndexMap>
|
||||
compressed_sparse_row_graph(const Graph& g, const VertexIndexMap& vi,
|
||||
vertices_size_type numverts,
|
||||
@@ -764,7 +713,7 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
|
||||
<a name="vertex-access"></a><h3>Vertex access</h3>
|
||||
|
||||
<pre><a name="vertex"></a>
|
||||
<pre><a name="vertex-lookup"></a>
|
||||
vertex_descriptor vertex(vertices_size_type i, const compressed_sparse_row_graph&);
|
||||
</pre>
|
||||
<p class="indent">
|
||||
@@ -775,18 +724,6 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
<hr></hr>
|
||||
|
||||
<a name="edge-access"></a><h3>Edge access</h3>
|
||||
<pre><a name="edge_range"></a>
|
||||
std::pair<out_edge_iterator, out_edge_iterator>
|
||||
edge_range(vertex_descriptor u, vertex_descriptor v, const compressed_sparse_row_graph&);
|
||||
</pre>
|
||||
|
||||
<p class="indent">
|
||||
Returns all edges from <tt>u</tt> to <tt>v</tt>. Requires time
|
||||
logarithmic in the number of edges outgoing from <tt>u</tt>.
|
||||
<b>(This function is only provided by the old interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="edge"></a>
|
||||
std::pair<edge_descriptor, bool>
|
||||
@@ -798,10 +735,11 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
descriptor for that edge and <tt>true</tt>; otherwise, the
|
||||
second value in the pair will be <tt>false</tt>. If multiple
|
||||
edges exist from <tt>u</tt> to <tt>v</tt>, the first edge will
|
||||
be returned; use <a href="#edge_range"><tt>edge_range</tt></a>
|
||||
to retrieve all edges. This function requires time logarithmic in the
|
||||
number of edges outgoing from <tt>u</tt> for the old interface, and
|
||||
linear time for the new interface.
|
||||
be returned; use <a href="IncidenceGraph.html"><tt>out_edges</tt></a> and a
|
||||
conditional statement
|
||||
to retrieve all edges to a given target. This function requires linear
|
||||
time in the
|
||||
number of edges outgoing from <tt>u</tt>.
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -898,47 +836,6 @@ void set_property(const compressed_sparse_row_graph& g, GraphPropertyTag,
|
||||
|
||||
<h3><a name="incremental-construction-functions">Incremental construction functions</a></h3>
|
||||
|
||||
<pre><a name="add_vertex"></a>
|
||||
vertex_descriptor add_vertex(compressed_sparse_row_graph& g)
|
||||
</pre>
|
||||
|
||||
<p class="indent">
|
||||
Add a new vertex to the end of the graph <tt>g</tt>, and return a
|
||||
descriptor for that vertex. The new vertex will be greater than any of
|
||||
the previous vertices in <tt>g</tt>.
|
||||
<b>(This function is only provided by the old interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="add_vertices"></a>
|
||||
vertex_descriptor add_vertices(vertices_size_type count, compressed_sparse_row_graph& g)
|
||||
</pre>
|
||||
|
||||
<p class="indent">
|
||||
Add <tt>count</tt> new vertices to the end of the graph <tt>g</tt>, and
|
||||
return a descriptor for the smallest new vertex. The new vertices will
|
||||
be greater than any of the previous vertices in <tt>g</tt>.
|
||||
<b>(This function is only provided by the old interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="add_edge"></a>
|
||||
edge_descriptor add_edge(vertex_descriptor src, vertex_descriptor tgt, compressed_sparse_row_graph& g)
|
||||
</pre>
|
||||
|
||||
<p class="indent">
|
||||
Add a new edge from <tt>src</tt> to <tt>tgt</tt> in the graph <tt>g</tt>,
|
||||
and return a descriptor for it. There must not be an edge in <tt>g</tt>
|
||||
whose source vertex is greater than <tt>src</tt>. If the vertex
|
||||
<tt>src</tt> has out edges before this operation is called, there must be
|
||||
none whose target is larger than <tt>tgt</tt>.
|
||||
<b>(This function is only provided by the old interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<pre><a name="add_edges"></a>
|
||||
template<typename InputIterator>
|
||||
void add_edges(InputIterator first, InputIterator last, compressed_sparse_row_graph& g)
|
||||
@@ -951,7 +848,6 @@ void add_edges(InputIterator first, InputIterator last, compressed_sparse_row_gr
|
||||
whose <code>value_type</code> is an <code>std::pair</code> of integer
|
||||
values. These integer values are the source and target vertices of the
|
||||
new edges. The edges do not need to be sorted.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -972,7 +868,6 @@ void add_edges(InputIterator first, InputIterator last, EPIter ep_first, EPIter
|
||||
of <tt>EPIter</tt> must be the edge property type of the graph. The
|
||||
integer values produced by the <tt>InputIterator</tt> are the source and
|
||||
target vertices of the new edges. The edges do not need to be sorted.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -990,7 +885,6 @@ void add_edges_sorted(BidirectionalIterator first, BidirectionalIterator last, c
|
||||
values. These integer values are the source and target vertices of the
|
||||
new edges. The edges must be sorted in increasing order by source vertex
|
||||
index.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
@@ -1013,7 +907,6 @@ void add_edges_sorted(BidirectionalIterator first, BidirectionalIterator last, E
|
||||
property type of the graph.
|
||||
The edges must be sorted in increasing order by source vertex
|
||||
index.
|
||||
<b>(This function is only provided by the new interface.)</b>
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
@@ -223,7 +223,7 @@ IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
|
||||
<b>Default:</b> <tt>get(vertex_index, g)</tt>.
|
||||
Note: if you use this default, make sure your graph has
|
||||
an internal <tt>vertex_index</tt> property. For example,
|
||||
<tt>adjacenty_list</tt> with <tt>VertexList=listS</tt> does
|
||||
<tt>adjacency_list</tt> with <tt>VertexList=listS</tt> does
|
||||
not have an internal <tt>vertex_index</tt> property.<br>
|
||||
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
|
||||
@@ -22,7 +22,7 @@ dfs_visitor<EventVisitorList>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
href="./EventVisitor.html">EventVisitor</a>s (constructed using
|
||||
<tt>std::pair</tt>) into a <a href="./DFSVisitor.html">DFSVisitor</a>.
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ with <tt>std::pair</tt>.
|
||||
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.
|
||||
href="./EventVisitor.html">EventVisitor</a> in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ dijkstra_visitor<EventVisitorList>
|
||||
</H1>
|
||||
|
||||
This class is an adapter that converts a list of <a
|
||||
href="./EventVisitor.html">EventVisitor</a>'s (constructed using
|
||||
href="./EventVisitor.html">EventVisitor</a>s (constructed using
|
||||
<tt>std::pair</tt>) into a <a
|
||||
href="./DijkstraVisitor.html">DijkstraVisitor</a>.
|
||||
|
||||
@@ -77,7 +77,7 @@ with <tt>std::pair</tt>.
|
||||
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.
|
||||
href="./EventVisitor.html">EventVisitor</a> in the EventVisitorList.
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ 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
|
||||
the <tt>on_tree_edge</tt> or <tt>on_relax_edge</tt> events and
|
||||
cannot be used with vertex events.
|
||||
|
||||
<p>
|
||||
@@ -64,7 +64,7 @@ See the example for <a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>.
|
||||
<TR><TD><TT>DistanceMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>,
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>
|
||||
where the key type and the value type are the vertex descriptor type
|
||||
of the graph.
|
||||
</TD>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</H1>
|
||||
|
||||
<PRE>
|
||||
<i>// named paramter version</i>
|
||||
<i>// named parameter 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
|
||||
edmonds_karp_max_flow(Graph& g,
|
||||
@@ -76,7 +76,7 @@ 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>
|
||||
or the <a
|
||||
href="./kolmogorov_max_flow.html"><tt>kolmogorov_max_flow()</tt></a>
|
||||
href="./boykov_kolmogorov_max_flow.html"><tt>boykov_kolmogorov_max_flow()</tt></a>
|
||||
algorithm.
|
||||
|
||||
<ul>
|
||||
@@ -217,7 +217,7 @@ 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>
|
||||
<a href="./kolmogorov_max_flow.html"><tt>kolmogorov_max_flow()</tt></a>.
|
||||
<a href="./boykov_kolmogorov_max_flow.html"><tt>boykov_kolmogorov_max_flow()</tt></a>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
|
||||
|
After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<!--
|
||||
Authors: Matthias Walter
|
||||
|
||||
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)
|
||||
-->
|
||||
<head>
|
||||
<title>Boost Graph Library: find_odd_cycle</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
<h1>
|
||||
<tt>find_odd_cycle</tt>
|
||||
</h1>
|
||||
|
||||
<pre>
|
||||
<i>// Version with a colormap to retrieve the bipartition</i>
|
||||
template <typename Graph, typename IndexMap, typename PartitionMap, typename OutputIterator>
|
||||
OutputIterator find_odd_cycle (const Graph& graph, const IndexMap index_map, PartitionMap partition_map, OutputIterator result)
|
||||
|
||||
template <typename Graph, typename IndexMap, typename OutputIterator>
|
||||
OutputIterator find_odd_cycle (const Graph& graph, const IndexMap index_map, OutputIterator result)
|
||||
|
||||
<i>// Version which uses the internal index map</i>
|
||||
template <typename Graph, typename OutputIterator>
|
||||
OutputIterator find_odd_cycle (const Graph& graph, OutputIterator result)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The <tt>find_odd_cycle</tt> function tests a given graph for bipartiteness
|
||||
using a DFS-based coloring approach.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
An undirected graph is bipartite if one can partition its set of vertices
|
||||
into two sets "left" and "right", such that each edge goes from either side
|
||||
to the other. Obviously, a two-coloring of the graph is exactly the same as
|
||||
a two-partition. <tt>is_bipartite()</tt> tests whether such a two-coloring
|
||||
is possible and can return it in a given property map.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Another equivalent characterization is the non-existance of odd-length cycles,
|
||||
meaning that a graph is bipartite if and only if it does not contain a
|
||||
cycle with an odd number of vertices as a subgraph.
|
||||
<tt>find_odd_cycle()</tt> does nearly the same as
|
||||
<a href="./is_bipartite.html"><tt>is_bipartite()</tt></a>,
|
||||
but additionally constructs an odd-length cycle if the graph is found to be
|
||||
not bipartite.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The bipartition is recorded in the color map <tt>partition_map</tt>,
|
||||
which will contain a two-coloring of the graph, i.e. an assignment of
|
||||
<i>black</i> and <i>white</i> to the vertices such that no edge is monochromatic.
|
||||
The odd-length cycle is written into the Output Iterator <tt>result</tt> if
|
||||
one exists. The final final iterator is returned by the function.
|
||||
</p>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<p>
|
||||
<a href="../../../boost/graph/bipartite.hpp"><tt>boost/graph/bipartite.hpp</tt></a>
|
||||
</p>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
<p>
|
||||
IN: <tt>const Graph& graph</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
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/>
|
||||
</p></blockquote>
|
||||
|
||||
<p>
|
||||
IN: <tt>const IndexMap index_map</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(graph))</tt>. The type <tt>VertexIndexMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/doc/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/>
|
||||
</p></blockquote>
|
||||
|
||||
|
||||
<p>
|
||||
OUT: <tt>PartitionMap partition_map</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
The algorithm tests whether the graph is bipartite and assigns each
|
||||
vertex either a white or a black color, according to the partition.
|
||||
The <tt>PartitionMap</tt> type must be a model of
|
||||
<a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property
|
||||
Map</a> and
|
||||
<a href="../../property_map/doc/WritablePropertyMap.html">Writable Property
|
||||
Map</a>. The value type must model <a href="./ColorValue.html">ColorValue</a>.
|
||||
</p></blockquote>
|
||||
|
||||
<p>
|
||||
OUT: <tt>OutputIterator result</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
The <tt>find_odd_cycle</tt> function finds an odd-length cycle if the graph is
|
||||
not bipartite. The sequence of vertices producing such a cycle is written
|
||||
into this iterator. The <tt>OutputIterator</tt> type must be a model of
|
||||
<a class="external" href="http://www.sgi.com/tech/stl/OutputIterator.html">
|
||||
OutputIterator</a>. The graph's vertex descriptor type must be in the set
|
||||
of value types of the iterator. The final value is returned by the
|
||||
function. If the graph is bipartite (i.e. no odd-length cycle exists), nothing
|
||||
is written, thus the given iterator matches the return value.
|
||||
</p></blockquote>
|
||||
|
||||
|
||||
<h3>Complexity</h3>
|
||||
|
||||
<p>
|
||||
The time complexity for the algorithm is <i>O(V + E)</i>.
|
||||
</p>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<p>
|
||||
<a href="./is_bipartite.html"><tt>is_bipartite()</tt></a>
|
||||
</p>
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<p>
|
||||
The file <a href="../example/bipartite_example.cpp"><tt>example/bipartite_example.cpp</tt></a>
|
||||
contains an example of testing an undirected graph for bipartiteness.
|
||||
<br/>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<p>
|
||||
Copyright © 2010 Matthias Walter
|
||||
(<a class="external" href="mailto:xammy@xammy.homelinux.net">xammy@xammy.homelinux.net</a>)
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright (c) 2004 Trustees of Indiana University
|
||||
Copyright (c) 2004, 2010 Trustees of Indiana University
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,36 +23,35 @@
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template<typename Graph, typename PositionMap, typename Dim, typename Param,
|
||||
template<typename Graph, typename PositionMap, typename Topology, typename Param,
|
||||
typename Tag, typename Rest>
|
||||
void
|
||||
fruchterman_reingold_force_directed_layout
|
||||
(const Graph& g,
|
||||
(const Graph& g,
|
||||
PositionMap position,
|
||||
Dim width,
|
||||
Dim height,
|
||||
const Topology& space,
|
||||
const bgl_named_params<Param, Tag, Rest>& params);
|
||||
|
||||
<i>// non-named parameter version</i>
|
||||
template<typename Graph, typename PositionMap, typename Dim,
|
||||
template<typename Graph, typename PositionMap, typename Topology,
|
||||
typename AttractiveForce, typename RepulsiveForce,
|
||||
typename ForcePairs, typename DisplacementMap, typename Cooling>
|
||||
void
|
||||
fruchterman_reingold_force_directed_layout
|
||||
(const Graph& g,
|
||||
PositionMap position,
|
||||
Dim width,
|
||||
Dim height,
|
||||
const Topology& space,
|
||||
AttractiveForce fa,
|
||||
RepulsiveForce fr,
|
||||
ForcePairs fp,
|
||||
Cooling cool,
|
||||
DisplacementMap displacement);
|
||||
|
||||
template<typename Graph, typename PositionMap, typename Dim>
|
||||
template<typename Graph, typename PositionMap, typename Topology>
|
||||
void
|
||||
fruchterman_reingold_force_directed_layout(const Graph& g,
|
||||
fruchterman_reingold_force_directed_layout(const Graph& g,
|
||||
PositionMap position,
|
||||
Topology& space,
|
||||
Dim width,
|
||||
Dim height);
|
||||
</PRE>
|
||||
@@ -98,26 +97,20 @@ IN/OUT: <tt>PositionMap position</tt>
|
||||
type <tt>PositionMap</tt> must be a model of <a
|
||||
href="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</a> such that the vertex descriptor type of <tt>Graph</tt> is
|
||||
convertible to its key type. Its value type must be a structure
|
||||
with fields <tt>x</tt> and <tt>y</tt>, representing the coordinates
|
||||
convertible to its key type. Its value type must be
|
||||
<tt>Topology::point_type</tt>, representing the coordinates
|
||||
of the vertex.<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>Dim width</tt>
|
||||
IN: <tt>const Topology& space</tt>
|
||||
<blockquote>
|
||||
The width of the display area in which layout should occur. On
|
||||
termination of the algorithm, the <tt>x</tt> coordinates of all
|
||||
vertices will fall in <tt>[-width/2, width/2]</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Dim height</tt>
|
||||
<blockquote>
|
||||
The height of the display area in which layout should occur. On
|
||||
termination of the algorithm, the <tt>y</tt> coordinates of all
|
||||
vertices will fall in <tt>[-height/2, height/2]</tt>.
|
||||
The topology used to lay out the vertices. This parameter describes both the
|
||||
size and shape of the layout area. Topologies are described in more detail
|
||||
(with a list of BGL-provided topologies) <a href="topology.html">in separate
|
||||
documentation</a>.
|
||||
</blockquote>
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
@@ -184,10 +177,11 @@ temperature and gradually reduce the temperature to zero.<br>
|
||||
UTIL: <tt>displacement_map(DisplacementMap displacement)</tt>
|
||||
<blockquote>
|
||||
The displacement map is used to compute the amount by which each
|
||||
vertex will move in each step. The <tt>DisplacementMap</tt> type
|
||||
carries the same requirements as the <tt>PositionMap</tt> type.<br>
|
||||
<b>Default:</b> An <tt>iterator_property_map</tt> with a value type
|
||||
of <tt>simple_point<double></tt> and using the given vertex index map.<br>
|
||||
vertex will move in each step. The <tt>DisplacementMap</tt> type must be a
|
||||
property map whose key type is the graph's vertex type and whose value type is
|
||||
<tt>Topology::point_difference_type</tt>.<br>
|
||||
<b>Default:</b> An <tt>iterator_property_map</tt> with the specified value type
|
||||
and using the given vertex index map.<br>
|
||||
<b>Python:</b> Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
@@ -233,7 +227,7 @@ determined by the cooling schedule.
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<TD nowrap>Copyright © 2004, 2010 Trustees of Indiana University</TD><TD>
|
||||
<A HREF="http://www.boost.org/people/doug_gregor.html">Doug Gregor</A>, Indiana University
|
||||
</TD></TR></TABLE>
|
||||
|
||||
|
||||
@@ -30,17 +30,22 @@ to define a graph implicitly based on some functions.
|
||||
|
||||
<P>
|
||||
The BGL interface does not appear as a single graph concept. Instead
|
||||
it is factored into much smaller peices. The reason for this is that
|
||||
it is factored into much smaller pieces. The reason for this is that
|
||||
the purpose of a concept is to summarize the requirements for
|
||||
<i>particular</i> algorithms. Any one algorithm does not need every
|
||||
kind of graph operation, typically only a small subset. Furthermore,
|
||||
there are many graph data-structures that can not provide efficient
|
||||
implementations of all the operations, but provide highly efficient
|
||||
implementations of the operations necessary for a particular algorithm
|
||||
. By factoring the graph interface into many smaller concepts we
|
||||
implementations of the operations necessary for a particular algorithm.
|
||||
By factoring the graph interface into many smaller concepts we
|
||||
provide the graph algorithm writer with a good selection from which to
|
||||
choose the concept that is the closest match for their algorithm.
|
||||
|
||||
Note that because of the use of traits classes rather than member
|
||||
types, it is not safe (and often will not work) to define subclasses of BGL
|
||||
graph types; those types may be missing important traits and properties that
|
||||
were defined externally to the class definition.
|
||||
|
||||
<H2>Graph Structure Concepts Overview</H2>
|
||||
|
||||
<P>
|
||||
@@ -224,7 +229,7 @@ vertex degee. </TD>
|
||||
<!---------------------------------------------------------------->
|
||||
<TR><TD ALIGN="LEFT" COLSPAN=2>
|
||||
<a href="./VertexListGraph.html">VertexListGraph</a> refines
|
||||
IncidenceGraph and AdjacencyGraph </TD>
|
||||
Graph</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT">
|
||||
<TT>boost::graph_traits<G>::vertex_iterator</TT> </TD>
|
||||
@@ -421,7 +426,7 @@ parallel edges. If the graph is not a multigraph then <i>(u,v)</i> and
|
||||
In the example below the edge equality test will return <TT>false</TT>
|
||||
for the directed graph and <TT>true</TT> for the undirected graph. The
|
||||
difference also affects the meaning of <TT>add_edge()</TT>. In the
|
||||
example below, if we had also written <TT>add_add(v, u,
|
||||
example below, if we had also written <TT>add_edge(v, u,
|
||||
undigraph)</TT>, this would have added a parallel edge between
|
||||
<i>u</i> and <i>v</i> (provided the graph type allows parallel
|
||||
edges). The difference in edge equality also affects the association
|
||||
|
||||
@@ -90,7 +90,7 @@ allowed in a directed or undirected graph).
|
||||
<P>
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:directed-graph"></A><A NAME="1509"></A>
|
||||
<DIV ALIGN="center"><A NAME="fig:directed-graph"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
|
||||
Example of a directed graph.</CAPTION>
|
||||
@@ -356,8 +356,8 @@ Breadth-first search spreading through a graph.</CAPTION>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
We start at vertex , and first visit <i>r</i> and <i>w</i> (the two
|
||||
neighbors of ). Once both neighbors of are visited, we visit the
|
||||
We start at vertex <i>s</i>, and first visit <i>r</i> and <i>w</i> (the two
|
||||
neighbors of <i>s</i>). Once both neighbors of are visited, we visit the
|
||||
neighbor of <i>r</i> (vertex <i>v</i>), then the neighbors of <i>w</i>
|
||||
(the discovery order between <i>r</i> and <i>w</i> does not matter)
|
||||
which are <i>t</i> and <i>x</i>. Finally we visit the neighbors of
|
||||
@@ -558,7 +558,7 @@ A flow network is shown in <a href="#fig:max-flow">Figure
|
||||
vertex.
|
||||
|
||||
<P></P>
|
||||
<DIV ALIGN="center"><A NAME="fig:max-flow"></A><A NAME="1509"></A>
|
||||
<DIV ALIGN="center"><A NAME="fig:max-flow"></A>
|
||||
<TABLE>
|
||||
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 8:</STRONG> A Maximum Flow
|
||||
Network.<br> Edges are labeled with the flow and capacity
|
||||
|
||||
@@ -34,6 +34,10 @@ required by the concepts, it is ok to use <tt>void</tt> as the type
|
||||
(when using nested typedefs inside the graph class), or to leave the
|
||||
typedef out of the <tt>graph_traits</tt> specialization for the graph
|
||||
class.
|
||||
Note that because of the use of traits classes rather than member
|
||||
types, it is not safe (and often will not work) to define subclasses of BGL
|
||||
graph types; those types may be missing important traits and properties that
|
||||
were defined externally to the class definition.
|
||||
|
||||
<pre>
|
||||
template <typename Graph>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
<h4>Template Parameters</h4>
|
||||
<pre class="code">
|
||||
<span class="keyword">template</span> <<span class="keyword">typename</span> <span class="name">std</span>::<span class="type">size_t</span> <span class="name">Dimensions</span>,
|
||||
<span class="keyword">template</span> <<span class="name">std</span>::<span class="type">size_t</span> <span class="name">Dimensions</span>,
|
||||
<span class="keyword">typename</span> <span class="name">VertexIndex</span> = <span class="name">std</span>::<span class="type">size_t</span>,
|
||||
<span class="keyword">typename</span> <span class="name">EdgeIndex</span> = <span class="name">VertexIndex</span>>
|
||||
<span class="keyword">class</span> grid_graph;
|
||||
@@ -152,8 +152,8 @@ vertex(<span class="name">Traits</span>::<span class="type">vertices_size_type</
|
||||
<span class="comment">// Get the index associated with vertex</span>
|
||||
<span class="name">Traits</span>::<span class="type">vertices_size_type</span>
|
||||
get(<span class="name">boost</span>::<span class="type">vertex_index_t</span>,
|
||||
<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex,
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph);
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph,
|
||||
<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex);
|
||||
|
||||
<span class="comment">// Get the edge associated with edge_index</span>
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span>
|
||||
@@ -163,8 +163,8 @@ edge_at(<span class="name">Traits</span>::<span class="type">edges_size_type</sp
|
||||
<span class="comment">// Get the index associated with edge</span>
|
||||
<span class="name">Traits</span>::<span class="type">edges_size_type</span>
|
||||
get(<span class="name">boost</span>::<span class="type">edge_index_t</span>,
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span> edge,
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph);
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph,
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span> edge);
|
||||
|
||||
<span class="comment">// Get the out-edge associated with vertex and out_edge_index</span>
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span>
|
||||
@@ -190,7 +190,7 @@ in_edge_at(<span class="name">Traits</span>::<span class="type">vertex_descripto
|
||||
|
||||
<span class="comment">// Do a round-trip test of the vertex index functions</span>
|
||||
<span class="keyword">for</span> (<span class="name">Traits</span>::<span class="type">vertices_size_type</span> v_index = <span class="literal">0</span>;
|
||||
v_index < num_vertices(graph); ++v_index) {
|
||||
v_index < num_vertices(graph); ++v_index) {
|
||||
|
||||
<span class="comment">// The two indices should always be equal</span>
|
||||
<span class="name">std</span>::cout << <span class="literal">"Index of vertex "</span> << v_index << <span class="literal">" is "</span> <<
|
||||
@@ -200,7 +200,7 @@ in_edge_at(<span class="name">Traits</span>::<span class="type">vertex_descripto
|
||||
|
||||
<span class="comment">// Do a round-trip test of the edge index functions</span>
|
||||
<span class="keyword">for</span> (<span class="name">Traits</span>::<span class="type">edges_size_type</span> e_index = <span class="literal">0</span>;
|
||||
e_index < num_edges(graph); ++e_index) {
|
||||
e_index < num_edges(graph); ++e_index) {
|
||||
|
||||
<span class="comment">// The two indices should always be equal</span>
|
||||
<span class="name">std</span>::cout << <span class="literal">"Index of edge "</span> << e_index << <span class="literal">" is "</span> <<
|
||||
|
||||
@@ -28,6 +28,7 @@ function address(host, user) {
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
<TT>gursoy_atun_layout</TT>
|
||||
</H1>
|
||||
|
||||
@@ -59,16 +60,6 @@ gursoy_atun_layout(const VertexListAndIncidenceGraph& g,
|
||||
const Topology& space,
|
||||
PositionMap position,
|
||||
const bgl_named_params<P,T,R>& params = <em>all defaults</em>);
|
||||
|
||||
<em>// Topologies</em>
|
||||
template<std::size_t Dims> class <a href="#convex_topology">convex_topology</a>;
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand> class <a href="#hypercube_topology">hypercube_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#square_topology">square_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#cube_topology">cube_topology</a>;
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand> class <a href="#ball_topology">ball_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#circle_topology">circle_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#sphere_topology">sphere_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#heart_topology">heart_topology</a>;
|
||||
</PRE>
|
||||
|
||||
<h3>Description</h3>
|
||||
@@ -81,26 +72,18 @@ href="fruchterman_reingold.html">Fruchterman-Reingold</a> algorithms,
|
||||
because it does not explicitly strive to layout graphs in a visually
|
||||
pleasing manner. Instead, it attempts to distribute the vertices
|
||||
uniformly within a <em>topology</em> (e.g., rectangle, sphere, heart shape),
|
||||
keeping vertices close to their neighbors. The algorithm itself is
|
||||
keeping vertices close to their neighbors; <a href="topology.html">various
|
||||
topologies</a> are provided by BGL, and users can also create their own. The
|
||||
algorithm itself is
|
||||
based on <a
|
||||
href="http://davis.wpi.edu/~matt/courses/soms/">Self-Organizing
|
||||
Maps</a>.
|
||||
|
||||
<p> <a href="#topologies">Various topologies</a> are provided that
|
||||
produce different, interesting results. The <a
|
||||
href="#square_topology">square topology</a> can be used for normal
|
||||
display of graphs or distributing vertices for parallel computation on
|
||||
a process array, for instance. Other topologies, such as the <a
|
||||
href="#sphere_topology">sphere topology</a> (or N-dimensional <a
|
||||
href="#ball_topology">ball topology</a>) make sense for different
|
||||
problems, whereas the <a href="#heart_topology">heart topology</a> is
|
||||
just plain fun. One can also <a href="#topology-concept">define a
|
||||
topology</a> to suit other particular needs. <br>
|
||||
|
||||
<a href="#square_topology"><img src="figs/ga-square.png"></a>
|
||||
<a href="#heart_topology"><img src="figs/ga-heart.png"></a>
|
||||
<a href="#circle_topology"><img src="figs/ga-circle.png"></a>
|
||||
|
||||
<p>
|
||||
<a href="topology.html#square_topology"><img src="figs/ga-square.png"></a>
|
||||
<a href="topology.html#heart_topology"><img src="figs/ga-heart.png"></a>
|
||||
<a href="topology.html#circle_topology"><img src="figs/ga-circle.png"></a>
|
||||
</p>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
@@ -118,8 +101,8 @@ IN: <tt>const Graph& g</tt>
|
||||
|
||||
IN: <tt>const Topology& space</tt>
|
||||
<blockquote>
|
||||
The topology on which the graph will be layed out. The type must
|
||||
model the <a href="#topology-concept">Topology</a> concept.
|
||||
The topology on which the graph will be laid out. The type must
|
||||
model the <a href="topology.html#topology-concept">Topology</a> concept.
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>PositionMap position</tt>
|
||||
@@ -128,8 +111,8 @@ OUT: <tt>PositionMap position</tt>
|
||||
<tt>PositionMap</tt> must be a model of <a
|
||||
href="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</a> such that the vertex descriptor type of <tt>Graph</tt> is
|
||||
convertible to its key type. Its value type must be the type of a
|
||||
point in the topology.
|
||||
convertible to its key type. Its value type must be
|
||||
<tt>Topology::point_type</tt>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>int nsteps</tt>
|
||||
@@ -242,216 +225,11 @@ Equivalent to the non-named <tt>vertex_index_map</tt> parameter.<br>
|
||||
not have an internal <tt>vertex_index</tt> property.
|
||||
</blockquote>
|
||||
|
||||
<a name="topologies"><h3>Topologies</h3></a>
|
||||
A topology is a description of a space on which layout can be
|
||||
performed. Some common two, three, and multidimensional topologies
|
||||
are provided, or you may create your own so long as it meets the
|
||||
requirements of the <a href="#topology-concept">Topology concept</a>.
|
||||
|
||||
<a name="topology-concept"><h4>Topology Concept</h4></a> Let
|
||||
<tt>Topology</tt> be a model of the Topology concept and let
|
||||
<tt>space</tt> be an object of type <tt>Topology</tt>. <tt>p1</tt> and
|
||||
<tt>p2</tt> are objects of associated type <tt>point_type</tt> (see
|
||||
below). The following expressions must be valid:
|
||||
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Expression</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>Topology::point_type</tt></td>
|
||||
<td>type</td>
|
||||
<td>The type of points in the space.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>space.random_point()</tt></td>
|
||||
<td>point_type</td>
|
||||
<td>Returns a random point (usually uniformly distributed) within
|
||||
the space.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>space.distance(p1, p2)</tt></td>
|
||||
<td>double</td>
|
||||
<td>Get a quantity representing the distance between <tt>p1</tt>
|
||||
and <tt>p2</tt> using a path going completely inside the space.
|
||||
This only needs to have the same < relation as actual
|
||||
distances, and does not need to satisfy the other properties of a
|
||||
norm in a Banach space.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>space.move_position_toward(p1, fraction, p2)</tt></td>
|
||||
<td>point_type</td>
|
||||
<td>Returns a point that is a fraction of the way from <tt>p1</tt>
|
||||
to <tt>p2</tt>, moving along a "line" in the space according to
|
||||
the distance measure. <tt>fraction</tt> is a <tt>double</tt>
|
||||
between 0 and 1, inclusive.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a name="convex_topology"><h3>Class template <tt>convex_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>convex_topology</tt> implements the basic
|
||||
distance and point movement functions for any convex topology in
|
||||
<tt>Dims</tt> dimensions. It is not itself a topology, but is intended
|
||||
as a base class that any convex topology can derive from. The derived
|
||||
topology need only provide a suitable <tt>random_point</tt> function
|
||||
that returns a random point within the space.
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims>
|
||||
class convex_topology
|
||||
{
|
||||
struct point
|
||||
{
|
||||
point() { }
|
||||
double& operator[](std::size_t i) {return values[i];}
|
||||
const double& operator[](std::size_t i) const {return values[i];}
|
||||
|
||||
private:
|
||||
double values[Dims];
|
||||
};
|
||||
|
||||
public:
|
||||
typedef point point_type;
|
||||
|
||||
double distance(point a, point b) const;
|
||||
point move_position_toward(point a, double fraction, point b) const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="hypercube_topology"><h3>Class template <tt>hypercube_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>hypercube_topology</tt> implements a
|
||||
<tt>Dims</tt>-dimensional hypercube. It is a convex topology whose
|
||||
points are drawn from a random number generator of type
|
||||
<tt>RandomNumberGenerator</tt>. The <tt>hypercube_topology</tt> can
|
||||
be constructed with a given random number generator; if omitted, a
|
||||
new, default-constructed random number generator will be used. The
|
||||
resulting layout will be contained within the hypercube, whose sides
|
||||
measure 2*<tt>scaling</tt> long (points will fall in the range
|
||||
[-<tt>scaling</tt>, <tt>scaling</tt>] in each dimension).
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand>
|
||||
class hypercube_topology : public <a href="#convex_topology">convex_topology</a><Dims>
|
||||
{
|
||||
public:
|
||||
explicit hypercube_topology(double scaling = 1.0);
|
||||
hypercube_topology(RandomNumberGenerator& gen, double scaling = 1.0);
|
||||
point_type random_point() const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="square_topology"><h3>Class template <tt>square_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>square_topology</tt> is a two-dimensional
|
||||
hypercube topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class square_topology : public <a href="#hypercube_topology">hypercube_topology</a><2, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit square_topology(double scaling = 1.0);
|
||||
square_topology(RandomNumberGenerator& gen, double scaling = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="cube_topology"><h3>Class template <tt>cube_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>cube_topology</tt> is a two-dimensional
|
||||
hypercube topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class cube_topology : public <a href="#hypercube_topology">hypercube_topology</a><3, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit cube_topology(double scaling = 1.0);
|
||||
cube_topology(RandomNumberGenerator& gen, double scaling = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="ball_topology"><h3>Class template <tt>ball_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>ball_topology</tt> implements a
|
||||
<tt>Dims</tt>-dimensional ball. It is a convex topology whose points
|
||||
are drawn from a random number generator of type
|
||||
<tt>RandomNumberGenerator</tt> but reside inside the ball. The
|
||||
<tt>ball_topology</tt> can be constructed with a given random number
|
||||
generator; if omitted, a new, default-constructed random number
|
||||
generator will be used. The resulting layout will be contained within
|
||||
the ball with the given <tt>radius</tt>.
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand>
|
||||
class ball_topology : public <a href="#convex_topology">convex_topology</a><Dims>
|
||||
{
|
||||
public:
|
||||
explicit ball_topology(double radius = 1.0);
|
||||
ball_topology(RandomNumberGenerator& gen, double radius = 1.0);
|
||||
point_type random_point() const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="circle_topology"><h3>Class template <tt>circle_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>circle_topology</tt> is a two-dimensional
|
||||
ball topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class circle_topology : public <a href="#ball_topology">ball_topology</a><2, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit circle_topology(double radius = 1.0);
|
||||
circle_topology(RandomNumberGenerator& gen, double radius = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="sphere_topology"><h3>Class template <tt>sphere_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>sphere_topology</tt> is a two-dimensional
|
||||
ball topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class sphere_topology : public <a href="#ball_topology">ball_topology</a><3, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit sphere_topology(double radius = 1.0);
|
||||
sphere_topology(RandomNumberGenerator& gen, double radius = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="heart_topology"><h3>Class template <tt>heart_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>heart_topology</tt> is topology in the shape of
|
||||
a heart. It serves as an example of a non-convex, nontrivial topology
|
||||
for layout.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class heart_topology
|
||||
{
|
||||
public:
|
||||
typedef <em>unspecified</em> point_type;
|
||||
|
||||
heart_topology();
|
||||
heart_topology(RandomNumberGenerator& gen);
|
||||
point_type random_point() const;
|
||||
double distance(point_type a, point_type b) const;
|
||||
point_type move_position_toward(point_type a, double fraction, point_type b) const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<TD nowrap>Copyright © 2004 Trustees of Indiana University</TD><TD>
|
||||
Jeremiah Willcock, Indiana University (<script language="Javascript">address("osl.iu.edu", "jewillco")</script>)<br>
|
||||
<A HREF="http://www.boost.org/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>,
|
||||
|
||||
@@ -76,7 +76,7 @@ September 27, 2000.
|
||||
<h2>Changes by version</h2>
|
||||
<a name="by-version">
|
||||
<ul>
|
||||
<a name="1.35.0"></a><li>Version 1.35.0<br><b>New algorithms and components</b>
|
||||
<a name="1.36.0"></a><li>Version 1.36.0<br><b>New algorithms and components</b>
|
||||
<ul>
|
||||
<li><a href="r_c_shortest_paths.html"><tt>r_c_shortest_paths</tt></a>, resource-constrained shortest paths, from Michael Drexl.</li>
|
||||
</ul>
|
||||
@@ -84,7 +84,7 @@ September 27, 2000.
|
||||
|
||||
<a name="1.35.0"></a><li>Version 1.35.0<br><b>New algorithms and components</b>
|
||||
<ul>
|
||||
<li><a href="kolmogorov_max_flow.html"><tt>kolmogorov_max_flow</tt></a>, from Stephan Diederich as part of the <a href="http://code.google.com/soc/">2006 Google Summer of Code</a>.</li>
|
||||
<li><a href="boykov_kolmogorov_max_flow.html"><tt>boykov_kolmogorov_max_flow</tt></a> (formerly kolmogorov_max_flow), from Stephan Diederich as part of the <a href="http://code.google.com/soc/">2006 Google Summer of Code</a>.</li>
|
||||
<li><a href="read_dimacs.html">read_dimacs_max_flow</a> and <a href="write_dimacs.html">write_dimacs_max_flow</a> for max-flow problems, from Stephan Diederich.</li>
|
||||
<li><a href="read_graphml.html">read_graphml</a> and <a href="write_graphml.html">write_graphml</a> for <a href="http://graphml.graphdrawing.org/">GraphML</a> input/output, from Tiago de Paula Peixoto.</li>
|
||||
<li><a href="howard_cycle_ratio.html"><tt>minimum_cycle_ratio</tt> and <tt>maximum_cycle_ratio</tt></a>, from Dmitry Bufistov and Andrey Parfenov.</li>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
@@ -7,17 +9,16 @@
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
<Head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
<Title>The Boost Graph Library</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>
|
||||
<BODY bgcolor="#ffffff" link="#0000ee" text="#000000" vlink="#551a8b"
|
||||
alink="#ff0000">
|
||||
<IMG src="../../../boost.png"
|
||||
alt="C++ Boost" width="277" height="86">
|
||||
|
||||
<h1>The Boost Graph Library (BGL)
|
||||
<a href="http://www.awprofessional.com/title/0201729148">
|
||||
<img src="bgl-cover.jpg" ALT="BGL Book" ALIGN="RIGHT"></a>
|
||||
<img src="bgl-cover.jpg" alt="BGL Book" align="RIGHT"></a>
|
||||
</h1>
|
||||
|
||||
<P>
|
||||
@@ -28,12 +29,12 @@ standardized generic interface for traversing graphs is of utmost
|
||||
importance to encourage reuse of graph algorithms and data structures.
|
||||
Part of the Boost Graph Library is a generic interface that allows
|
||||
access to a graph's structure, but hides the details of the
|
||||
implementation. This is an ``open'' interface in the sense that any
|
||||
implementation. This is an “open” interface in the sense that any
|
||||
graph library that implements this interface will be interoperable
|
||||
with the BGL generic algorithms and with other algorithms that also
|
||||
use this interface. The BGL provides some general purpose graph classes
|
||||
that conform to this interface, but they are not meant to be the
|
||||
``only'' graph classes; there certainly will be other graph classes
|
||||
“only” graph classes; there certainly will be other graph classes
|
||||
that are better for certain situations. We believe that the main
|
||||
contribution of the The BGL is the formulation of this interface.
|
||||
|
||||
@@ -49,7 +50,9 @@ programming in the context of graphs.
|
||||
<P>
|
||||
Of course, if you are already familiar with generic programming,
|
||||
please dive right in! Here's the <a
|
||||
href="./table_of_contents.html">Table of Contents</a>.
|
||||
href="./table_of_contents.html">Table of Contents</a>. For distributed-memory
|
||||
parallelism, you can also look at the <a
|
||||
href="../../graph_parallel/doc/html/index.html">Parallel BGL</a>.
|
||||
|
||||
<P>
|
||||
The source for the BGL is available as part of the Boost distribution,
|
||||
@@ -62,7 +65,7 @@ does not need to be built to be used. The only exception is the <a
|
||||
href="read_graphviz.html">GraphViz input parser</a>.</p>
|
||||
|
||||
<p>When compiling programs that use the BGL, <b>be sure to compile
|
||||
with optimization</b>. For instance, select "Release" mode with
|
||||
with optimization</b>. For instance, select “Release” mode with
|
||||
Microsoft Visual C++ or supply the flag <tt>-O2</tt> or <tt>-O3</tt>
|
||||
to GCC. </p>
|
||||
|
||||
@@ -108,14 +111,14 @@ handle the specifics of each problem domain.
|
||||
<P>
|
||||
The third way that STL is generic is that its containers are
|
||||
parameterized on the element type. Though hugely important, this is
|
||||
perhaps the least ``interesting'' way in which STL is generic.
|
||||
perhaps the least “interesting” way in which STL is generic.
|
||||
Generic programming is often summarized by a brief description of
|
||||
parameterized lists such as <TT>std::list<T></TT>. This hardly scratches
|
||||
the surface!
|
||||
|
||||
<P>
|
||||
|
||||
<H2>Genericity in the Boost Graph Library</A>
|
||||
<H2>Genericity in the Boost Graph Library
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
@@ -169,7 +172,7 @@ BGL graph algorithms.
|
||||
Second, the graph algorithms of the BGL are extensible. The BGL introduces the
|
||||
notion of a <I>visitor</I>, which is just a function object with
|
||||
multiple methods. In graph algorithms, there are often several key
|
||||
``event points'' at which it is useful to insert user-defined
|
||||
“event points” at which it is useful to insert user-defined
|
||||
operations. The visitor object has a different method that is invoked
|
||||
at each event point. The particular event points and corresponding
|
||||
visitor methods depend on the particular algorithm. They often
|
||||
@@ -185,13 +188,13 @@ include methods like <TT>start_vertex()</TT>,
|
||||
The third way that the BGL is generic is analogous to the parameterization
|
||||
of the element-type in STL containers, though again the story is a bit
|
||||
more complicated for graphs. We need to associate values (called
|
||||
"properties") with both the vertices and the edges of the graph.
|
||||
“properties”) with both the vertices and the edges of the graph.
|
||||
In addition, it will often be necessary to associate
|
||||
multiple properties with each vertex and edge; this is what we mean
|
||||
by multi-parameterization.
|
||||
The STL <tt>std::list<T></tt> class has a parameter <tt>T</tt>
|
||||
for its element type. Similarly, BGL graph classes have template
|
||||
parameters for vertex and edge ``properties''. A
|
||||
parameters for vertex and edge “properties”. A
|
||||
property specifies the parameterized type of the property and also assigns
|
||||
an identifying tag to the property. This tag is used to distinguish
|
||||
between the multiple properties which an edge or vertex may have. A
|
||||
@@ -265,8 +268,8 @@ The BGL currently provides two graph classes and an edge list adaptor:
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The <TT>adjacency_list</TT> class is the general purpose ``swiss army
|
||||
knife'' of graph classes. It is highly parameterized so that it can be
|
||||
The <TT>adjacency_list</TT> class is the general purpose “swiss army
|
||||
knife” of graph classes. It is highly parameterized so that it can be
|
||||
optimized for different situations: the graph is directed or
|
||||
undirected, allow or disallow parallel edges, efficient access to just
|
||||
the out-edges or also to the in-edges, fast vertex insertion and
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<!--
|
||||
Authors: Matthias Walter
|
||||
|
||||
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)
|
||||
-->
|
||||
<head>
|
||||
<title>Boost Graph Library: is_bipartite</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
<h1>
|
||||
<tt>is_bipartite</tt>
|
||||
</h1>
|
||||
|
||||
<pre>
|
||||
<i>// Version with a colormap to retrieve the bipartition</i>
|
||||
template <typename Graph, typename IndexMap, typename PartitionMap>
|
||||
bool is_bipartite (const Graph& graph, const IndexMap index_map, PartitionMap partition_map)
|
||||
|
||||
template <typename Graph, typename IndexMap>
|
||||
bool is_bipartite (const Graph& graph, const IndexMap index_map)
|
||||
|
||||
<i>// Version which uses the internal index map</i>
|
||||
template <typename Graph>
|
||||
bool is_bipartite (const Graph& graph);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The <tt>is_bipartite()</tt> functions tests a given graph for
|
||||
bipartiteness using a DFS-based coloring approach.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
An undirected graph is bipartite if one can partition its set of vertices
|
||||
into two sets "left" and "right", such that each edge goes from either side
|
||||
to the other. Obviously, a two-coloring of the graph is exactly the same as
|
||||
a two-partition. <tt>is_bipartite()</tt> tests whether such a two-coloring
|
||||
is possible and can return it in a given property map.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The bipartition is recorded in the color map <tt>partition_map</tt>,
|
||||
which will contain a two-coloring of the graph, i.e. an assignment of
|
||||
<i>black</i> and <i>white</i> to the vertices such that no edge is monochromatic.
|
||||
The predicate whether the graph is bipartite is the return value of the function.
|
||||
</p>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
<p>
|
||||
<a href="../../../boost/graph/bipartite.hpp"><tt>boost/graph/bipartite.hpp</tt></a>
|
||||
</p>
|
||||
|
||||
<h3>Parameters</h3>
|
||||
|
||||
<p>
|
||||
IN: <tt>const Graph& graph</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
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/>
|
||||
</p></blockquote>
|
||||
|
||||
<p>
|
||||
IN: <tt>const IndexMap index_map</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
This maps each vertex to an integer in the range <tt>[0,
|
||||
num_vertices(graph))</tt>. The type <tt>VertexIndexMap</tt>
|
||||
must be a model of <a
|
||||
href="../../property_map/doc/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/>
|
||||
</p></blockquote>
|
||||
|
||||
|
||||
<p>
|
||||
OUT: <tt>PartitionMap partition_map</tt>
|
||||
</p>
|
||||
<blockquote><p>
|
||||
The algorithm tests whether the graph is bipartite and assigns each
|
||||
vertex either a white or a black color, according to the partition.
|
||||
The <tt>PartitionMap</tt> type must be a model of
|
||||
<a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property
|
||||
Map</a> and
|
||||
<a href="../../property_map/doc/WritablePropertyMap.html">Writable Property
|
||||
Map</a> The value type must model <a href="./ColorValue.html">ColorValue</a>.
|
||||
</p></blockquote>
|
||||
|
||||
|
||||
<h3>Complexity</h3>
|
||||
|
||||
<p>
|
||||
The time complexity for the algorithm is <i>O(V + E)</i>.
|
||||
</p>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<p>
|
||||
<a href="./find_odd_cycle.html"><tt>find_odd_cycle()</tt></a>
|
||||
</p>
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<p>
|
||||
The file <a href="../example/bipartite_example.cpp"><tt>examples/bipartite.cpp</tt></a>
|
||||
contains an example of testing an undirected graph for bipartiteness.
|
||||
<br/>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<p>
|
||||
Copyright © 2010 Matthias Walter
|
||||
(<a class="external" href="mailto:xammy@xammy.homelinux.net">xammy@xammy.homelinux.net</a>)
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<!--
|
||||
Copyright (c) 2004 Trustees of Indiana University
|
||||
Copyright (c) 2004, 2010 Trustees of Indiana University
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -46,6 +46,7 @@ layout for connected, undirected graphs.</p>
|
||||
"refsynopsisdiv">
|
||||
<pre class="synopsis">
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> Topology, <span class=
|
||||
"bold"><b>typename</b></span> Graph, <span class=
|
||||
"bold"><b>typename</b></span> PositionMap, <span class=
|
||||
"bold"><b>typename</b></span> WeightMap, <span class=
|
||||
@@ -62,6 +63,7 @@ layout for connected, undirected graphs.</p>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph & g, PositionMap position,
|
||||
WeightMap weight,
|
||||
<b>const</b> Topology& space,
|
||||
<span class=
|
||||
"emphasis"><em>unspecified</em></span> edge_or_side_length, Done done,
|
||||
<span class=
|
||||
@@ -71,6 +73,7 @@ layout for connected, undirected graphs.</p>
|
||||
SpringStrengthMatrix spring_strength,
|
||||
PartialDerivativeMap partial_derivatives);
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> Topology, <span class=
|
||||
"bold"><b>typename</b></span> Graph, <span class=
|
||||
"bold"><b>typename</b></span> PositionMap, <span class=
|
||||
"bold"><b>typename</b></span> WeightMap, <span class=
|
||||
@@ -82,12 +85,14 @@ layout for connected, undirected graphs.</p>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph & g, PositionMap position,
|
||||
WeightMap weight,
|
||||
<b>const</b> Topology& space,
|
||||
<span class=
|
||||
"emphasis"><em>unspecified</em></span> edge_or_side_length, Done done,
|
||||
<span class=
|
||||
"bold"><b>typename</b></span> property_traits< WeightMap >::value_type spring_constant,
|
||||
VertexIndexMap index);
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> Topology, <span class=
|
||||
"bold"><b>typename</b></span> Graph, <span class=
|
||||
"bold"><b>typename</b></span> PositionMap, <span class=
|
||||
"bold"><b>typename</b></span> WeightMap, <span class=
|
||||
@@ -98,11 +103,13 @@ layout for connected, undirected graphs.</p>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph & g, PositionMap position,
|
||||
WeightMap weight,
|
||||
<b>const</b> Topology& space,
|
||||
<span class=
|
||||
"emphasis"><em>unspecified</em></span> edge_or_side_length, Done done,
|
||||
<span class=
|
||||
"bold"><b>typename</b></span> property_traits< WeightMap >::value_type spring_constant = typename property_traits< WeightMap >::value_type(1));
|
||||
<span class="bold"><b>template</b></span><<span class=
|
||||
"bold"><b>typename</b></span> Topology, <span class=
|
||||
"bold"><b>typename</b></span> Graph, <span class=
|
||||
"bold"><b>typename</b></span> PositionMap, <span class=
|
||||
"bold"><b>typename</b></span> WeightMap, <span class=
|
||||
@@ -112,6 +119,7 @@ layout for connected, undirected graphs.</p>
|
||||
<span class="type"><span class=
|
||||
"bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph & g, PositionMap position,
|
||||
WeightMap weight,
|
||||
<b>const</b> Topology& space,
|
||||
<span class=
|
||||
"emphasis"><em>unspecified</em></span> edge_or_side_length);
|
||||
</pre></div>
|
||||
@@ -158,7 +166,8 @@ OUT: <tt>PositionMap position</tt>
|
||||
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/doc/WritablePropertyMap.html">Writable Property
|
||||
Map</a>, with the graph's vertex descriptor type as its key type.<br>
|
||||
Map</a>, with the graph's vertex descriptor type as its key type and
|
||||
<tt>Topology::point_type</tt> as its value type.<br>
|
||||
|
||||
<b>Python</b>: The position map must be a <tt>vertex_point2d_map</tt> for
|
||||
the graph.<br>
|
||||
@@ -182,6 +191,16 @@ IN: <tt>weight_map(WeightMap w_map)</tt>
|
||||
<b>Python default</b>: <tt>graph.get_edge_double_map("weight")</tt>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>const Topology& space</tt>
|
||||
<blockquote>
|
||||
The topology used to lay out the vertices. This parameter describes both the
|
||||
size and shape of the layout area, as well as its dimensionality; up to three
|
||||
dimensions are supported by the current implementation. Topologies are
|
||||
described in more detail
|
||||
(with a list of BGL-provided topologies) <a href="topology.html">in separate
|
||||
documentation</a>.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>EdgeOrSideLength edge_or_side_length</tt>
|
||||
<blockquote>
|
||||
Provides either the unit length <tt class= "computeroutput">e</tt> of
|
||||
@@ -257,17 +276,15 @@ value type of the weight map.<br>
|
||||
|
||||
UTIL: <tt>PartialDerivativeMap partial_derivatives</tt>
|
||||
<blockquote>
|
||||
A property map that will be used to store the partial derivates of
|
||||
each vertex with respect to the <tt class="computeroutput">x</tt> and
|
||||
<tt class="computeroutput">y</tt> coordinates. This must be a
|
||||
A property map that will be used to store the partial derivatives of
|
||||
each vertex with respect to the vertex's current coordinates.
|
||||
coordinates. This must be a
|
||||
<a href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write
|
||||
Property Map</a> whose value type is a pair with both types equivalent
|
||||
to the value type of the weight map. The default is an iterator
|
||||
property map.<br>
|
||||
Property Map</a> whose value type is <tt>Topology::point_difference_type</tt>.
|
||||
The default is an iterator property map built using the graph's vertex index
|
||||
map.<br>
|
||||
<b>Default</b>: An <tt>iterator_property_map</tt> created from
|
||||
an <tt>std::vector</tt> of <tt>std::pair<weight_type,
|
||||
weight_type></tt>, where <tt>weight_type</tt> is the value type of
|
||||
the <tt>WeightMap</tt>.<br>
|
||||
an <tt>std::vector</tt> of <tt>Topology::point_difference_type</tt>.<br>
|
||||
<b>Python</b>: Unsupported parameter.
|
||||
</blockquote>
|
||||
|
||||
@@ -294,7 +311,7 @@ the <tt>WeightMap</tt>.<br>
|
||||
<hr>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td nowrap>Copyright © 2004</td>
|
||||
<td nowrap>Copyright © 2004, 2010 Trustees of Indiana University</td>
|
||||
<td><a href="http://www.boost.org/people/doug_gregor.html">Douglas Gregor</a>,
|
||||
Indiana University (dgregor -at cs.indiana.edu)<br>
|
||||
<a href="http://www.osl.iu.edu/~lums">Andrew Lumsdaine</a>, Indiana
|
||||
|
||||
@@ -44,14 +44,6 @@ versions.
|
||||
<li>"using boost::tie;" may cause VC++ internal compiler error.
|
||||
</ol>
|
||||
|
||||
<h2>Workarounds</h2>
|
||||
<p>
|
||||
<b>Compiler Warnings on <code>hash_set</code> and <code>hash_map</code></b>. Versions of
|
||||
GCC >= 4.3 deprecate these headers and data structures and will emit warnings when
|
||||
compiling the BGL. To suppress these warnings <em>and the hash-based storage selectors</em>
|
||||
define the <code>BOOST_NO_HASH</code> prior to including any Boost.Graph headers.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-15">
|
||||
<TITLE>Boost Graph Library: Kolmogorov Maximum Flow</TITLE>
|
||||
<TITLE>Boost Graph Library: Boykov-Kolmogorov Maximum Flow</TITLE>
|
||||
<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.0 (Linux)">
|
||||
<META NAME="CREATED" CONTENT="20060820;17315200">
|
||||
<META NAME="CHANGEDBY" CONTENT="Stephan Diederich">
|
||||
@@ -53,14 +53,31 @@
|
||||
</STYLE>
|
||||
</HEAD>
|
||||
<BODY LANG="de-DE" TEXT="#000000" LINK="#0000ee" VLINK="#551a8b" BGCOLOR="#ffffff" DIR="LTR">
|
||||
<P><IMG SRC="../../../boost.png" NAME="Grafik1" ALT="C++ Boost" ALIGN=BOTTOM WIDTH=277 HEIGHT=86 BORDER=0>
|
||||
|
||||
<P>
|
||||
<IMG SRC="../../../boost.png" NAME="Grafik1" ALT="C++ Boost" ALIGN=BOTTOM WIDTH=277 HEIGHT=86 BORDER=0>
|
||||
</P>
|
||||
|
||||
<table align="center" width="75%" style="border:1px solid; border-spacing: 10pt">
|
||||
<tr>
|
||||
<td style="vertical-align: top"><img src="figs/warning.png"></td>
|
||||
<td>
|
||||
<b>Warning!</b> This header and its contents are <em>deprecated</em> and
|
||||
will be removed in a future release. Please update your program to use
|
||||
<a href="boykov_kolmogorov_max_flow.html"> <tt>boykov_kolmogorov_max_flow</tt></a>
|
||||
instead. Note that only the name of the algorithm has changed. The template
|
||||
and function parameters will remain the same.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<H1><A NAME="sec:kolmogorov_max_flow"></A><TT>kolmogorov_max_flow</TT>
|
||||
</H1>
|
||||
<PRE><I>// named parameter version</I>
|
||||
template <class Graph, class P, class T, class R>
|
||||
typename property_traits<typename property_map<Graph, edge_capacity_t>::const_type>::value_type
|
||||
kolmogorov_max_flow(Graph& g,
|
||||
kolmogorov_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>)
|
||||
@@ -88,14 +105,14 @@ 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>.
|
||||
<I>r(u,v) = c(u,v) - f(u,v)</I>.
|
||||
</P>
|
||||
<P><B>Requirements:</B><BR>The directed graph <I>G=(V,E)</I> that
|
||||
represents the network must include a 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>.
|
||||
<I>(u,v) -> (v,u)</I> for all <I>(u,v)</I> in <I>E</I>.
|
||||
</P>
|
||||
<P>Remarks: While the push-relabel method states that each edge in <I>E<SUP>T</SUP></I>
|
||||
has to have capacity of 0, the reverse edges for this algorithm ARE
|
||||
@@ -155,7 +172,7 @@ no more orphans.</P>
|
||||
<UL>
|
||||
<LI><P>Marking heuristics: A timestamp is stored for each vertex
|
||||
which shows in which iteration of the algorithm the distance to the
|
||||
corresponding terminal was calculated.
|
||||
corresponding terminal was calculated.
|
||||
</P>
|
||||
<UL>
|
||||
<LI><P>This distance is used and gets calculated in the
|
||||
@@ -190,7 +207,7 @@ of Kolmogorov. Few changes were made for increasing performance:</P>
|
||||
improves especially graph-cuts used in image vision where nearly
|
||||
each vertex has a source and sink connect. During this step, all
|
||||
vertices that have an unsaturated connection from source are added
|
||||
to the active vertex list and so the source is not.
|
||||
to the active vertex list and so the source is not.
|
||||
</P>
|
||||
<LI><P>active vertices: Kolmogorov uses two lists for active nodes
|
||||
and states that new active vertices are added to the rear of the
|
||||
@@ -210,54 +227,56 @@ of Kolmogorov. Few changes were made for increasing performance:</P>
|
||||
<P><TT><A HREF="../../../boost/graph/kolmogorov_max_flow.hpp">boost/graph/kolmogorov_max_flow.hpp</A></TT>
|
||||
</P>
|
||||
<H3>Parameters</H3>
|
||||
<P>IN: <TT>Graph& g</TT>
|
||||
<P>IN: <TT>Graph& g</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A directed graph. The graph's type must be a model of
|
||||
<A HREF="VertexListGraph.html">Vertex List Graph</A>, <A HREF="EdgeListGraph.html">Edge
|
||||
List Graph</A> and <A HREF="IncidenceGraph.html">Incidence Graph</A>.
|
||||
For each edge <I>(u,v)</I> in the graph, the reverse edge <I>(v,u)</I>
|
||||
must also be in the graph.
|
||||
must also be in the graph. Performance of the algorithm will be slightly
|
||||
improved if the graph type also models <a href="AdjacencyMatrix.html">Adjacency
|
||||
Matrix</a>.
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>vertex_descriptor src</TT>
|
||||
<P>IN: <TT>vertex_descriptor src</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The source vertex for the flow network graph.
|
||||
<BLOCKQUOTE>The source vertex for the flow network graph.
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>vertex_descriptor sink</TT>
|
||||
<P>IN: <TT>vertex_descriptor sink</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The sink vertex for the flow network graph.
|
||||
<BLOCKQUOTE>The sink vertex for the flow network graph.
|
||||
</BLOCKQUOTE>
|
||||
<H3>Named Parameters</H3>
|
||||
<P>IN: <TT>edge_capacity(EdgeCapacityMap cap)</TT>
|
||||
<P>IN: <TT>edge_capacity(EdgeCapacityMap cap)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The edge capacity property map. The type must be a model
|
||||
of a constant <A HREF="../../property_map/doc/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>
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(edge_capacity, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>OUT: <TT>edge_residual_capacity(ResidualCapacityEdgeMap res)</TT>
|
||||
<P>OUT: <TT>edge_residual_capacity(ResidualCapacityEdgeMap res)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>The edge residual capacity property map. The type must be
|
||||
a model of a mutable <A HREF="../../property_map/doc/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>
|
||||
g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>edge_reverse(ReverseEdgeMap rev)</TT>
|
||||
<P>IN: <TT>edge_reverse(ReverseEdgeMap rev)</TT>
|
||||
</P>
|
||||
<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/doc/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>
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(edge_reverse, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>UTIL: <TT>vertex_predecessor(PredecessorMap pre_map)</TT>
|
||||
<P>UTIL: <TT>vertex_predecessor(PredecessorMap pre_map)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A vertex property map that stores the edge to the vertex'
|
||||
predecessor. The map must be a model of mutable <A HREF="../../property_map/doc/LvaluePropertyMap.html">Lvalue
|
||||
Property Map</A>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_predecessor, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>OUT/UTIL: <TT>vertex_color(ColorMap color)</TT>
|
||||
<P>OUT/UTIL: <TT>vertex_color(ColorMap color)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A vertex property map that stores a color for edge
|
||||
vertex. If the color of a vertex after running the algorithm is black
|
||||
@@ -265,29 +284,29 @@ the vertex belongs to the source tree else it belongs to the
|
||||
sink-tree (used for minimum cuts). The map must be a model of mutable
|
||||
<A HREF="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</A>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_color, g)</TT>
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_color, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>UTIL: <TT>vertex_distance(DistanceMap dist)</TT>
|
||||
<P>UTIL: <TT>vertex_distance(DistanceMap dist)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>A vertex property map that stores the distance to the
|
||||
corresponding terminal. It's a utility-map for speeding up the
|
||||
algorithm. The map must be a model of mutable <A HREF="../../property_map/doc/LvaluePropertyMap.html">Lvalue
|
||||
Property Map</A>. The key type of the map must be the graph's vertex
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_distance, g)</TT>
|
||||
descriptor type.<BR><B>Default:</B> <TT>get(vertex_distance, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<P>IN: <TT>vertex_index(VertexIndexMap index_map)</TT>
|
||||
<P>IN: <TT>vertex_index(VertexIndexMap index_map)</TT>
|
||||
</P>
|
||||
<BLOCKQUOTE>Maps each vertex of the graph to a unique integer in the
|
||||
range <TT>[0, num_vertices(g))</TT>. The map must be a model of
|
||||
constant <A HREF="../../property_map/doc/LvaluePropertyMap.html">LvaluePropertyMap</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>
|
||||
type.<BR><B>Default:</B> <TT>get(vertex_index, g)</TT>
|
||||
</BLOCKQUOTE>
|
||||
<H3>Example</H3>
|
||||
<P>This reads an example maximum flow problem (a graph with edge
|
||||
capacities) from a file in the DIMACS format (<TT><A HREF="../example/max_flow.dat">example/max_flow.dat</A></TT>).
|
||||
The source for this example can be found in
|
||||
<TT><A HREF="../example/kolmogorov-eg.cpp">example/kolmogorov-eg.cpp</A></TT>.
|
||||
<TT><A HREF="../example/boykov_kolmogorov-eg.cpp">example/boykov_kolmogorov-eg.cpp</A></TT>.
|
||||
</P>
|
||||
<PRE>#include <boost/config.hpp>
|
||||
#include <iostream>
|
||||
@@ -309,11 +328,11 @@ main()
|
||||
property < vertex_color_t, boost::default_color_type,
|
||||
property < vertex_distance_t, long,
|
||||
property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
|
||||
|
||||
|
||||
property < edge_capacity_t, long,
|
||||
property < edge_residual_capacity_t, long,
|
||||
property < edge_reverse_t, Traits::edge_descriptor > > > > Graph;
|
||||
|
||||
|
||||
Graph g;
|
||||
property_map < Graph, edge_capacity_t >::type
|
||||
capacity = get(edge_capacity, g);
|
||||
@@ -341,7 +360,7 @@ main()
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}</PRE><P>
|
||||
The output is:
|
||||
The output is:
|
||||
</P>
|
||||
<PRE>c The total flow:
|
||||
s 13
|
||||
|
||||
@@ -27,7 +27,7 @@ template <typename Graph, typename MateMap, typename VertexIndexMap>
|
||||
bool checked_edmonds_maximum_cardinality_matching(const Graph& g, MateMap mate, VertexIndexMap vm);
|
||||
</pre>
|
||||
<p>
|
||||
<a name="sec:articulation_points">A <i>matching</i> is a subset of the edges
|
||||
<a name="sec:matching">A <i>matching</i> is a subset of the edges
|
||||
of a graph such that no two edges share a common vertex.
|
||||
Two different matchings in the same graph are illustrated below (edges in the
|
||||
matching are colored blue.) The matching on the left is a <i>maximal matching</i>,
|
||||
@@ -38,9 +38,9 @@ over all matchings in the graph.
|
||||
</a></p><p></p><center>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td><a name="sec:articulation_points"><img src="figs/maximal-match.png"></a></td>
|
||||
<td><a name="fig:maximal_matching"><img src="figs/maximal-match.png"></a></td>
|
||||
<td width="150"></td>
|
||||
<td><a name="sec:articulation_points"><img src="figs/maximum-match.png"></a></td>
|
||||
<td><a name="fig:maximum_matching"><img src="figs/maximum-match.png"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
@@ -82,6 +82,11 @@ IN: <tt>Graph& g</tt>
|
||||
<blockquote>
|
||||
An undirected graph. The graph type must be a model of
|
||||
<a href="VertexAndEdgeListGraph.html">VertexAndEdgeListGraph</a>.
|
||||
The graph must:
|
||||
<ul>
|
||||
<li>Be maximal planar.</li>
|
||||
<li>Have at least two vertices.</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>PlanarEmbedding</tt>
|
||||
|
||||
@@ -88,7 +88,7 @@ into the plane separates it into two faces: the region inside the triangle and
|
||||
the (unbounded) region outside the triangle. The unbounded region outside the
|
||||
graph's embedding is called the <i>outer face</i>. Every embedding yields
|
||||
one outer face and zero or more inner faces. A famous result called
|
||||
<a name="EulersFormula">Euler's formula</a> states that for any
|
||||
Euler's formula states that for any
|
||||
planar graph with <i>n</i> vertices, <i>e</i> edges, <i>f</i> faces, and
|
||||
<i>c</i> connected components,
|
||||
<a name="EulersFormula">
|
||||
|
||||
@@ -27,7 +27,7 @@ map. This is particularly useful in graph search algorithms where
|
||||
recording the predecessors is an efficient way to encode the search
|
||||
tree that was traversed during the search. The predecessor recorder is
|
||||
typically used with the <tt>on_tree_edge</tt> or
|
||||
<tt>on_relax_edge</tt> events, and cannot be used with vertex events.
|
||||
<tt>on_relax_edge</tt> events and cannot be used with vertex events.
|
||||
|
||||
<p>
|
||||
<tt>predecessor_recorder</tt> can be used with graph algorithms by
|
||||
@@ -40,12 +40,12 @@ visitor can be combined with other event visitors using
|
||||
<p>
|
||||
Algorithms such as Dijkstra's and breadth-first search will not assign
|
||||
a predecessor to the source vertex (which is the root of the search
|
||||
tree). Often times it is useful to initialize the source vertex's
|
||||
tree). It is often useful to initialize the source vertex's
|
||||
predecessor to itself, thereby identifying the root vertex as the only
|
||||
vertex which is its own parent. When using an algorithm like
|
||||
depth-first search that creates a forest (multiple search trees), it
|
||||
is useful to intialize the predecessor of every vertex to itself, so
|
||||
that all the root nodes can be distinguished.
|
||||
depth-first search that creates a forest (multiple search trees) it
|
||||
is useful to intialize the predecessor of every vertex to itself. This
|
||||
way all the root nodes can be distinguished.
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
@@ -74,7 +74,7 @@ See the example for <a href="./bfs_visitor.html"><tt>bfs_visitor</tt></a>.
|
||||
<TR><TD><TT>PredecessorMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>,
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>
|
||||
where the key type and the value type are the vertex descriptor type
|
||||
of the graph.
|
||||
</TD>
|
||||
|
||||
@@ -55,6 +55,8 @@ simply a call to <a
|
||||
href="./dijkstra_shortest_paths.html"><TT>dijkstra_shortest_paths()</TT></a>
|
||||
with the appropriate choice of comparison and combine functors.
|
||||
The pseudo-code for Prim's algorithm is listed below.
|
||||
The algorithm as implemented in Boost.Graph does not produce correct results on
|
||||
graphs with parallel edges.
|
||||
</p>
|
||||
|
||||
<table>
|
||||
@@ -131,7 +133,8 @@ IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
An undirected graph. 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>
|
||||
and <a href="./IncidenceGraph.html">Incidence Graph</a>. It should not
|
||||
contain parallel edges.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
Copyright (c) 2010 Matthias Walter (xammy@xammy.homelinux.net)
|
||||
Copyright (c) 2010 Trustees of Indiana University
|
||||
|
||||
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)
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: property_put</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>
|
||||
property_put<PropertyMap, EventTag>
|
||||
</pre>
|
||||
</H1>
|
||||
|
||||
This is an <a href="./EventVisitor.html">EventVisitor</a> that can be
|
||||
used to write a fixed value to a property map when a vertex or edge is
|
||||
visited at some event-point within an algorithm. For example, this
|
||||
visitor can be used as an alternative to a loop to initialize a
|
||||
property map, or it can be used to mark only back edges with a
|
||||
property.
|
||||
|
||||
<p>
|
||||
<tt>property_put</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>
|
||||
|
||||
<pre>
|
||||
boost::depth_first_search
|
||||
(G, boost::visitor(
|
||||
boost::make_dfs_visitor(
|
||||
boost::put_property(is_back_edge, boost::on_back_edge()))));
|
||||
</pre>
|
||||
|
||||
<h3>Model of</h3>
|
||||
|
||||
<a href="./EventVisitor.html">EventVisitor</a>
|
||||
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/visitors.hpp">
|
||||
<TT>boost/graph/visitors.hpp</TT></a>
|
||||
|
||||
<H3>Template Parameters</H3>
|
||||
|
||||
<P>
|
||||
<TABLE border>
|
||||
<TR>
|
||||
<th>Parameter</th><th>Description</th><th>Default</th>
|
||||
</tr>
|
||||
|
||||
<TR><TD><TT>PropertyMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>,
|
||||
where the <tt>key_type</tt> is the vertex descriptor type or edge
|
||||
descriptor of the graph (depending on the kind of event tag).
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD><TT>EventTag</TT></TD>
|
||||
<TD>
|
||||
The tag to specify when the <tt>property_put</tt> should be
|
||||
applied during the graph algorithm.
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
|
||||
<H2>Associated Types</H2>
|
||||
|
||||
<table border>
|
||||
|
||||
<tr>
|
||||
<th>Type</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>property_put::event_filter</tt></td>
|
||||
<td>
|
||||
This will be the same type as the template parameter <tt>EventTag</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Member Functions</h3>
|
||||
|
||||
<p>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Member</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
property_put(PropertyMap pa, property_traits<PropertyMap>::value_type val);
|
||||
</tt></td>
|
||||
<td>
|
||||
Construct a property put object with the property map
|
||||
<tt>pa</tt> and constant value <tt>val</tt>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>
|
||||
template <class X, class Graph><br>
|
||||
void operator()(X x, const Graph& g);
|
||||
</tt></td>
|
||||
<td>
|
||||
This puts the value <tt>val</tt> into the property map for the vertex
|
||||
or edge <tt>x</tt>.<br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Non-Member Functions</h3>
|
||||
|
||||
<table border>
|
||||
<tr>
|
||||
<th>Function</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><tt>
|
||||
template <class PropertyMap, class EventTag><br>
|
||||
property_put<PropertyMap, EventTag><br>
|
||||
put_property(PropertyMap pa,
|
||||
typename property_traits<PropertyMap>::value_type val,
|
||||
EventTag);
|
||||
</tt></td><td>
|
||||
A convenient way to create a <tt>property_put</tt>.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./visitor_concepts.html">Visitor concepts</a>
|
||||
<p>
|
||||
The following are other event visitors: <a
|
||||
<a href="./distance_recorder.html"><tt>distance_recorder</tt></a>,
|
||||
<a href="./predecessor_recorder.html"><tt>predecessor_recorder</tt></a>,
|
||||
and <a href="./time_stamper.html"><tt>time_stamper</tt></a>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<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>
|
||||
<tr><td>Copyright © 2010</td><td>Matthias Walter (<a href="mailto:xammy@xammy.homelinux.net">xammy@xammy.homelinux.net</a>)</td></tr>
|
||||
<tr><td></td><td>Trustees of Indiana University</td></tr>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
<!-- LocalWords: PropertyMap OutputIterator EventTag EventVisitor bfs dfs EventVisitorList
|
||||
-->
|
||||
<!-- LocalWords: cpp num dtime ftime int WritablePropertyMap map adaptor
|
||||
-->
|
||||
<!-- LocalWords: const Siek Univ Quan Lumsdaine typename
|
||||
-->
|
||||
@@ -27,7 +27,7 @@ within an algorithm.
|
||||
|
||||
<p>
|
||||
<tt>property_writer</tt> can be used with graph algorithms by
|
||||
wrapping it with the algorithm specific adaptor, such as <a
|
||||
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
|
||||
@@ -74,9 +74,9 @@ href="../example/dave.cpp"><tt>examples/dave.cpp</tt></a>.
|
||||
<TR><TD><TT>PropertyMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/doc/ReadablePropertyMap.html">ReadablePropertyMap</a>,
|
||||
href="../../property_map/doc/ReadablePropertyMap.html">ReadablePropertyMap</a>
|
||||
where the <tt>key_type</tt> is the vertex descriptor type or edge
|
||||
descriptor of the graph (depending on the kind of event tag), and
|
||||
descriptor of the graph (depending on the kind of event tag) and
|
||||
the <tt>value_type</tt> of the property is convertible
|
||||
to the <tt>value_type</tt> of the <tt>OutputIterator</tt>.
|
||||
</TD>
|
||||
@@ -145,7 +145,7 @@ template <class X, class Graph><br>
|
||||
void operator()(X x, const Graph& g);
|
||||
</tt></td>
|
||||
<td>
|
||||
This writs the property value for <tt>x</tt> to the output iterator.<br>
|
||||
This writes the property value for <tt>x</tt> to the output iterator.<br>
|
||||
<tt>*out++ = get(pa, x);</tt>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -226,7 +226,7 @@ f 6 7 1
|
||||
<h3>See Also</h3>
|
||||
|
||||
<a href="./edmonds_karp_max_flow.html"><tt>edmonds_karp_max_flow()</tt></a><br>
|
||||
<a href="./kolmogorov_max_flow.html"><tt>kolmogorov_max_flow()</tt></a>.
|
||||
<a href="./boykov_kolmogorov_max_flow.html"><tt>boykov_kolmogorov_max_flow()</tt></a>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
|
||||
@@ -445,7 +445,7 @@ of iterators (a pointer qualifies as a <a href="http://www.sgi.com/tech/stl/Rand
|
||||
E(4,0), E(4,1) };
|
||||
int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1};
|
||||
|
||||
Graph G(edges + sizeof(edges) / sizeof(E), weights, num_nodes);
|
||||
Graph G(edges, edges + sizeof(edges) / sizeof(E), weights, num_nodes);
|
||||
</pre>
|
||||
<p>For the external distance property we will use a <tt>std::vector</tt> for
|
||||
storage. BGL algorithms treat random access iterators as property maps, so we
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright (c) 2005 Trustees of Indiana University
|
||||
Copyright (c) 2005, 2010 Trustees of Indiana University
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -22,17 +22,14 @@
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// non-named parameter version</i>
|
||||
template<typename Graph, typename PositionMap, typename Dimension,
|
||||
typename RandomNumberGenerator>
|
||||
template<typename Graph, typename PositionMap, typename Topology>
|
||||
void
|
||||
random_graph_layout(const Graph& g, PositionMap position_map,
|
||||
Dimension minX, Dimension maxX,
|
||||
Dimension minY, Dimension maxY,
|
||||
RandomNumberGenerator& gen);
|
||||
const Topology& space);
|
||||
</PRE>
|
||||
|
||||
<P> This algorithm places the points of the graph at random
|
||||
locations. </p>
|
||||
locations within a given space. </p>
|
||||
|
||||
<h3>Where Defined</h3>
|
||||
|
||||
@@ -53,37 +50,17 @@ IN/OUT: <tt>PositionMap position</tt>
|
||||
<tt>PositionMap</tt> must be a model of <a
|
||||
href="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
|
||||
Map</a> such that the vertex descriptor type of <tt>Graph</tt> is
|
||||
convertible to its key type. Its value type must be a structure with
|
||||
fields <tt>x</tt> and <tt>y</tt>, representing the coordinates of
|
||||
the vertex.
|
||||
convertible to its key type. Its value type must be
|
||||
<tt>Topology::point_type</tt>, representing the coordinates of the vertex.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Dimension minX</tt>
|
||||
IN: <tt>const Topology& space</tt>
|
||||
<blockquote>
|
||||
The minimum <tt>x</tt> coordinate.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Dimension maxX</tt>
|
||||
<blockquote>
|
||||
The maximum <tt>x</tt> coordinate.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Dimension minY</tt>
|
||||
<blockquote>
|
||||
The minimum <tt>y</tt> coordinate.
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Dimension maxY</tt>
|
||||
<blockquote>
|
||||
The maximum <tt>y</tt> coordinate.
|
||||
</blockquote>
|
||||
|
||||
IN/UTIL: <tt>RandomNumberGenerator& gen</tt>
|
||||
<blockquote>
|
||||
A random number generator that will be used to place vertices. The
|
||||
type <tt>RandomNumberGenerator</tt> must model the <a
|
||||
href="../../random/random-concepts.html#number_generator">NumberGenerator</a>
|
||||
concept.
|
||||
The topology used to lay out the vertices. This parameter describes both the
|
||||
size and shape of the layout area and provides a random number generator used
|
||||
to create random positions within the space. Topologies are described in
|
||||
more detail (with a list of BGL-provided topologies) <a
|
||||
href="topology.html">in separate documentation</a>.
|
||||
</blockquote>
|
||||
|
||||
<H3>Complexity</H3>
|
||||
@@ -93,7 +70,7 @@ concept.
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004</TD><TD>
|
||||
<TD nowrap>Copyright © 2004, 2010</TD><TD>
|
||||
<A HREF="http://www.boost.org/people/doug_gregor.html">Doug Gregor</A>, Indiana University
|
||||
</TD></TR></TABLE>
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright 2010 The Trustees of Indiana University.
|
||||
|
||||
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)
|
||||
|
||||
Authors: Jeremiah Willcock
|
||||
Jeremy Siek (due to adaptation from depth_first_search.html)
|
||||
Andrew Lumsdaine
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Random Spanning Tree</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>
|
||||
|
||||
<TT>random_spanning_tree</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
<i>// named parameter version</i>
|
||||
template <class Graph, class Gen, class class P, class T, class R>
|
||||
void random_spanning_tree(Graph& G,
|
||||
Gen& gen,
|
||||
const bgl_named_params<P, T, R>& params);
|
||||
|
||||
<i>// non-named parameter versions</i>
|
||||
template <class Graph, class Gen, class PredMap, class WeightMap, class ColorMap>
|
||||
void random_spanning_tree(const Graph& g, Gen& gen, vertex_descriptor root,
|
||||
PredMap pred, WeightMap weight, ColorMap color);
|
||||
</PRE>
|
||||
|
||||
<p>
|
||||
The <tt>random_spanning_tree()</tt> function generates a random spanning tree
|
||||
on a directed or undirected graph. The algorithm used is Wilson's algorithm (<a
|
||||
href="bibliography.html#wilson96generating">73</a>, based on <!-- (FIXME: add
|
||||
documentation for loop_erased_random_walk()) <a
|
||||
href="loop_erased_random_walk.html"> -->loop-erased random walks<!-- </a> -->. There must
|
||||
be a path from every non-root vertex of the graph to the root;
|
||||
the algorithm typically enters an infinite loop when
|
||||
given a graph that does not satisfy this property, but may also throw the
|
||||
exception <tt>loop_erased_random_walk_stuck</tt> if the search reaches a vertex
|
||||
with no outgoing edges. Both weighted and unweighted versions of
|
||||
<tt>random_spanning_tree()</tt> are
|
||||
implemented. In the unweighted version, all spanning trees are equally likely.
|
||||
In the weighted version, the probability of a particular spanning tree being
|
||||
selected is the product of its edge weights.
|
||||
In the non-named-parameter
|
||||
version of the algorithm, the unweighted version can be selected by passing an
|
||||
object of type <tt>static_property_map<double></tt> as the weight map.
|
||||
In the named-parameter version, leaving off the <tt>weight_map</tt> parameter
|
||||
has the same effect.
|
||||
</p>
|
||||
|
||||
<H3>Where Defined</H3>
|
||||
|
||||
<P>
|
||||
<a href="../../../boost/graph/random_spanning_tree.hpp"><TT>boost/graph/random_spanning_tree.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="./IncidenceGraph.html">Incidence Graph</a>
|
||||
and <a href="./VertexListGraph.html">Vertex List Graph</a>.<br>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>Gen& gen</tt>
|
||||
<blockquote>
|
||||
A random number generator. The generator type must
|
||||
be a model of <a
|
||||
href="../../random/doc/reference.html#boost_random.reference.concepts.uniform_random_number_generator">Uniform
|
||||
Random Number Generator</a> or a pointer or reference to such a type.<br>
|
||||
</blockquote>
|
||||
|
||||
|
||||
<h3>Named Parameters</h3>
|
||||
|
||||
IN: <tt>root_vertex(vertex_descriptor root)</tt>
|
||||
<blockquote>
|
||||
This parameter, whose type must be the vertex descriptor type of
|
||||
<tt>Graph</tt>, gives the root of the tree to be generated. The default is
|
||||
<tt>*vertices(g).first</tt>.<br>
|
||||
</blockquote>
|
||||
|
||||
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/doc/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> a <tt>two_bit_color_map</tt> of size
|
||||
<tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
|
||||
map.<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/doc/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>
|
||||
</blockquote>
|
||||
|
||||
OUT: <tt>predecessor_map(PredMap pred)</tt>
|
||||
<blockquote>
|
||||
This map, on output, will contain the predecessor of each vertex in the graph
|
||||
in the spanning tree. The value
|
||||
<tt>graph_traits<Graph>::null_vertex()</tt> will be used as the
|
||||
predecessor of the root of the tree. The type <tt>PredMap</tt> must be a
|
||||
model of
|
||||
<a
|
||||
href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write Property
|
||||
Map</a>. The key and value types of the map must both be the graph's vertex type.<br>
|
||||
</blockquote>
|
||||
|
||||
IN: <tt>weight_map(WeightMap weight)</tt>
|
||||
<blockquote>
|
||||
This map contains the weight of each edge in the graph. The probability of
|
||||
any given spanning tree being produced as the result of the algorithm is
|
||||
proportional to the product of its edge weights. If the weight map is
|
||||
omitted, a default that gives an equal weight to each edge will be used; a
|
||||
faster algorithm that relies on constant weights will also be invoked.
|
||||
The type <tt>WeightMap</tt> must be a
|
||||
model of
|
||||
<a
|
||||
href="../../property_map/doc/ReadablePropertyMap.html">Readable Property
|
||||
Map</a>. The key type of the map must be the graph's edge type, and the value
|
||||
type must be a real number type (such as <tt>double</tt>).<br>
|
||||
</blockquote>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000-2001</TD><TD>
|
||||
<A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
|
||||
Indiana University (<A
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
|
||||
<A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
|
||||
<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,3 +1,5 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
|
||||
@@ -7,14 +9,13 @@
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
<Head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
<Title>Table of Contents: Boost Graph Library</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>Table of Contents: the Boost Graph Library
|
||||
<a href="http://www.awprofessional.com/title/0201729148">
|
||||
<img src="bgl-cover.jpg" ALT="BGL Book" ALIGN="RIGHT"></a>
|
||||
@@ -22,6 +23,7 @@
|
||||
|
||||
<OL>
|
||||
<LI><A Href="./index.html">Introduction to the BGL</A>
|
||||
<li><a href="../../graph_parallel/doc/html/index.html">Parallel BGL (distributed-memory parallel graph data structures and algorithms)</a>
|
||||
<LI><A Href="./history.html">History</A>
|
||||
<LI><A Href="./users.html">List of BGL Users</A>
|
||||
<LI><A Href="./publications.html">Publications</A>
|
||||
@@ -64,12 +66,12 @@
|
||||
<LI><A href="./MutablePropertyGraph.html">Mutable Property Graph</A>
|
||||
</OL>
|
||||
<li><a href="../../property_map/doc/property_map.html">The Property Map Library</a> (technically not part of the graph library, but used a lot here)
|
||||
<li><img src="figs/python_ico.gif" alt="(Python)"/><a href="python.html">Python bindings</a></li>
|
||||
<li><img src="figs/python_ico.gif" alt="(Python)"><a href="python.html">Python bindings</a></li>
|
||||
<li><a href="./visitor_concepts.html">Visitor Concepts</a>
|
||||
<OL>
|
||||
<LI><a href="./BFSVisitor.html">BFS Visitor</a>
|
||||
<LI><a href="./DFSVisitor.html">DFS Visitor</a>
|
||||
<LI><a href="./DFSVisitor.html"><a href="./DijkstraVisitor.html">Dijkstra Visitor</a>
|
||||
<LI><a href="./DijkstraVisitor.html">Dijkstra Visitor</a>
|
||||
<LI><a href="./BellmanFordVisitor.html">Bellman Ford Visitor</a>
|
||||
<LI><a href="AStarVisitor.html">A* Visitor</a></LI>
|
||||
<LI><a href="./EventVisitor.html">Event Visitor</a>
|
||||
@@ -91,6 +93,7 @@
|
||||
<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="property_put.html"><tt>property_put</tt></a>
|
||||
<li><a href="tsp_tour_visitor.html"><tt>tsp_tour_visitor</tt></a></li>
|
||||
<li><a href="tsp_tour_len_visitor.html"><tt>tsp_tour_len_visitor</tt></a></li>
|
||||
</OL>
|
||||
@@ -114,144 +117,171 @@
|
||||
<OL>
|
||||
<LI><A href="./grid_graph.html">Multi-dimensional grid graph</A>
|
||||
</OL>
|
||||
<LI>Iterator Adaptors
|
||||
<OL>
|
||||
<LI><a
|
||||
href="./adjacency_iterator.html"><tt>adjacency_iterator</tt></a>
|
||||
<LI><a
|
||||
href="./inv_adjacency_iterator.html"><tt>inv_adjacency_iterator</tt></a>
|
||||
</OL>
|
||||
<LI>Traits classes
|
||||
<OL>
|
||||
<LI><a href="./graph_traits.html"><tt>graph_traits</tt></a>
|
||||
<LI><a href="./adjacency_list_traits.html"><tt>adjacency_list_traits</tt></a>
|
||||
<LI><a href="./property_map.html"><tt>property_map</tt></a>
|
||||
</OL>
|
||||
<LI>Algorithms
|
||||
<OL>
|
||||
<LI><a href="./bgl_named_params.html"><tt>bgl_named_params</tt></a>
|
||||
<LI>Core Algorithm Patterns
|
||||
<OL>
|
||||
<LI><A href="./breadth_first_search.html"><tt>breadth_first_search</tt></A>
|
||||
<LI><A href="./breadth_first_search.html"><A href="./breadth_first_visit.html"><tt>breadth_first_visit</tt></A>
|
||||
<LI><A
|
||||
href="./depth_first_search.html"><tt>depth_first_search</tt></A>
|
||||
<LI><A href="./depth_first_visit.html"><tt>depth_first_visit</tt></A>
|
||||
<LI><A
|
||||
href="./undirected_dfs.html"><tt>undirected_dfs</tt></A>
|
||||
</OL>
|
||||
<LI>Graph Algorithms
|
||||
<OL>
|
||||
<LI>Shortest Paths Algorithms
|
||||
<OL>
|
||||
<LI><A href="./dijkstra_shortest_paths.html"><tt>dijkstra_shortest_paths</tt></A>
|
||||
<LI><A href="./dijkstra_shortest_paths_no_color_map.html"><tt>dijkstra_shortest_paths_no_color_map</tt></A>
|
||||
<LI><A href="./bellman_ford_shortest.html"><tt>bellman_ford_shortest_paths</tt></A>
|
||||
<LI><A href="./dag_shortest_paths.html"><tt>dag_shortest_paths</tt></A>
|
||||
<LI><A
|
||||
href="./johnson_all_pairs_shortest.html"><tt>johnson_all_pairs_shortest_paths</tt></A>
|
||||
<li><a href="floyd_warshall_shortest.html"><tt>floyd_warshall_all_pairs_shortest_paths</tt></a></li>
|
||||
<li><a href="r_c_shortest_paths.html"><tt>r_c_shortest_paths</tt> - resource-constrained shortest paths</a></li>
|
||||
</OL>
|
||||
<LI>Minimum Spanning Tree Algorithms
|
||||
<OL>
|
||||
<LI><A
|
||||
href="./kruskal_min_spanning_tree.html"><tt>kruskal_minimum_spanning_tree</tt></A>
|
||||
<LI><A
|
||||
href="./prim_minimum_spanning_tree.html"><tt>prim_minimum_spanning_tree</tt></A>
|
||||
</OL>
|
||||
<LI>Connected Components Algorithms
|
||||
</ol>
|
||||
<LI>Iterator Adaptors
|
||||
<OL>
|
||||
<LI><A href="./connected_components.html"><tt>connected_components</tt></A>
|
||||
<LI><A href="./strong_components.html"><tt>strong_components</tt></A>
|
||||
|
||||
<LI><a href="biconnected_components.html"><tt>biconnected_components</tt></a>
|
||||
<LI><a href="biconnected_components.html#sec:articulation_points"><tt>articulation_points</tt></a>
|
||||
<LI><a href="./incremental_components.html">Incremental Connected Components</a>
|
||||
<LI><a
|
||||
href="./adjacency_iterator.html"><tt>adjacency_iterator</tt></a>
|
||||
<LI><a
|
||||
href="./inv_adjacency_iterator.html"><tt>inv_adjacency_iterator</tt></a>
|
||||
</OL>
|
||||
<LI>Traits classes
|
||||
<OL>
|
||||
<LI><a href="./graph_traits.html"><tt>graph_traits</tt></a>
|
||||
<LI><a href="./adjacency_list_traits.html"><tt>adjacency_list_traits</tt></a>
|
||||
<LI><a href="./property_map.html"><tt>property_map</tt></a>
|
||||
</OL>
|
||||
<LI>Algorithms
|
||||
<OL>
|
||||
<LI><a href="./bgl_named_params.html">Named parameters (used in many graph algorithms)</a>
|
||||
<li>Basic Operations
|
||||
<ol>
|
||||
<LI><A href="copy_graph.html"><tt>copy_graph</tt></A>
|
||||
<LI><A href="transpose_graph.html"><tt>transpose_graph</tt></A>
|
||||
</ol>
|
||||
<LI>Core Searches
|
||||
<OL>
|
||||
<LI><A href="./breadth_first_search.html"><tt>breadth_first_search</tt></A>
|
||||
<LI><A href="./breadth_first_visit.html"><tt>breadth_first_visit</tt></A>
|
||||
<LI><A
|
||||
href="./depth_first_search.html"><tt>depth_first_search</tt></A>
|
||||
<LI><A href="./depth_first_visit.html"><tt>depth_first_visit</tt></A>
|
||||
<LI><A
|
||||
href="./undirected_dfs.html"><tt>undirected_dfs</tt></A>
|
||||
</OL>
|
||||
|
||||
<li>Other Core Algorithms
|
||||
<ol>
|
||||
<LI><A href="topological_sort.html"><tt>topological_sort</tt></A>
|
||||
<li><a href="transitive_closure.html"><tt>transitive_closure</tt></a>
|
||||
<li><a href="lengauer_tarjan_dominator.htm"><tt>lengauer_tarjan_dominator_tree</tt></a></li>
|
||||
</ol>
|
||||
|
||||
<LI>Shortest Paths / Cost Minimization Algorithms
|
||||
<OL>
|
||||
<LI><A href="./dijkstra_shortest_paths.html"><tt>dijkstra_shortest_paths</tt></A>
|
||||
<LI><A href="./dijkstra_shortest_paths_no_color_map.html"><tt>dijkstra_shortest_paths_no_color_map</tt></A>
|
||||
<LI><A href="./bellman_ford_shortest.html"><tt>bellman_ford_shortest_paths</tt></A>
|
||||
<LI><A href="./dag_shortest_paths.html"><tt>dag_shortest_paths</tt></A>
|
||||
<LI><A
|
||||
href="./johnson_all_pairs_shortest.html"><tt>johnson_all_pairs_shortest_paths</tt></A>
|
||||
<li><a href="floyd_warshall_shortest.html"><tt>floyd_warshall_all_pairs_shortest_paths</tt></a></li>
|
||||
<li><a href="r_c_shortest_paths.html"><tt>r_c_shortest_paths</tt> - resource-constrained shortest paths</a></li>
|
||||
<li><a href="astar_search.html"><tt>astar_search</tt></a></li>
|
||||
</OL>
|
||||
<LI>Minimum Spanning Tree Algorithms
|
||||
<OL>
|
||||
<LI><A
|
||||
href="./kruskal_min_spanning_tree.html"><tt>kruskal_minimum_spanning_tree</tt></A>
|
||||
<LI><A
|
||||
href="./prim_minimum_spanning_tree.html"><tt>prim_minimum_spanning_tree</tt></A>
|
||||
</OL>
|
||||
<LI>Random Spanning Tree Algorithm
|
||||
<OL>
|
||||
<LI><A
|
||||
href="./random_spanning_tree.html"><tt>random_spanning_tree</tt></A>
|
||||
</OL>
|
||||
<LI>Connected Components Algorithms
|
||||
<OL>
|
||||
<LI><A href="./connected_components.html"><tt>connected_components</tt></A>
|
||||
<LI><A href="./strong_components.html"><tt>strong_components</tt></A>
|
||||
|
||||
<LI><a href="biconnected_components.html"><tt>biconnected_components</tt></a>
|
||||
<LI><a href="biconnected_components.html#sec:articulation_points"><tt>articulation_points</tt></a>
|
||||
<LI><a href="./incremental_components.html">Incremental Connected Components</a>
|
||||
<OL>
|
||||
<LI><A href="./incremental_components.html#sec:initialize-incremental-components"><tt>initialize_incremental_components</tt></A>
|
||||
<LI><A href="./incremental_components.html#sec:incremental-components"><tt>incremental_components</tt></A>
|
||||
<LI><A
|
||||
href="./incremental_components.html#sec:same-component"><tt>same_component</tt></A>
|
||||
<LI><A href="./incremental_components.html#sec:component-index"><tt>component_index</tt></A>
|
||||
</OL>
|
||||
</OL></LI>
|
||||
<LI>Maximum Flow and Matching Algorithms
|
||||
<OL>
|
||||
<LI><A href="edmonds_karp_max_flow.html"><tt>edmonds_karp_max_flow</tt></A>
|
||||
<LI><A href="push_relabel_max_flow.html"><tt>push_relabel_max_flow</tt></A>
|
||||
<li><a href="kolmogorov_max_flow.html"><tt>kolmogorov_max_flow</tt></a></li>
|
||||
<LI><A href="maximum_matching.html"><tt>edmonds_maximum_cardinality_matching</tt></A>
|
||||
</OL>
|
||||
</OL>
|
||||
</OL></LI>
|
||||
<LI>Maximum Flow and Matching Algorithms
|
||||
<OL>
|
||||
<LI><A href="edmonds_karp_max_flow.html"><tt>edmonds_karp_max_flow</tt></A>
|
||||
<LI><A href="push_relabel_max_flow.html"><tt>push_relabel_max_flow</tt></A>
|
||||
<li>
|
||||
<a href="kolmogorov_max_flow.html"><tt>kolmogorov_max_flow</tt></a> (<em>Deprecated</em>.
|
||||
Use <a href="boykov_kolmogorov_max_flow.html"><tt>boykov_kolmogorov_max_flow</tt></a>
|
||||
instead.)
|
||||
</li>
|
||||
<li><a href="boykov_kolmogorov_max_flow.html"><tt>boykov_kolmogorov_max_flow</tt></a></li>
|
||||
<LI><A href="maximum_matching.html"><tt>edmonds_maximum_cardinality_matching</tt></A>
|
||||
</OL>
|
||||
|
||||
<li>Sparse Matrix Ordering Algorithms
|
||||
<ol>
|
||||
<LI><A
|
||||
href="./cuthill_mckee_ordering.html"><tt>cuthill_mckee_ordering</tt></a>
|
||||
<li><a href="king_ordering.html"><tt>king_ordering</tt></a></li>
|
||||
<LI><a href="./minimum_degree_ordering.html"><tt>minimum_degree_ordering</tt></a>
|
||||
<li>Sparse Matrix Ordering Algorithms
|
||||
<ol>
|
||||
<LI><A
|
||||
href="./cuthill_mckee_ordering.html"><tt>cuthill_mckee_ordering</tt></a>
|
||||
<li><a href="king_ordering.html"><tt>king_ordering</tt></a></li>
|
||||
<LI><a href="./minimum_degree_ordering.html"><tt>minimum_degree_ordering</tt></a>
|
||||
<li><a href="sloan_ordering.htm"><tt>sloan_ordering</tt></a></li>
|
||||
<li><a href="sloan_start_end_vertices.htm"><tt>sloan_start_end_vertices</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>Graph Metrics
|
||||
<ol>
|
||||
<LI><A href="./wavefront.htm"><tt>ith_wavefront</tt>, <tt>max_wavefront</tt>, <tt>aver_wavefront</tt>, and <tt>rms_wavefront</tt></A></LI>
|
||||
<LI><a href="./bandwidth.html#sec:bandwidth"><tt>bandwidth</tt></a>
|
||||
<LI><a href="./bandwidth.html#sec:ith-bandwidth"><tt>ith_bandwidth</tt></a>
|
||||
<LI><A href="betweenness_centrality.html"><tt>brandes_betweenness_centrality</tt></A></LI>
|
||||
<li><a href="howard_cycle_ratio.html"><tt>minimum_cycle_ratio</tt> and <tt>maximum_cycle_ratio</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>Graph Structure Comparisons
|
||||
<ol>
|
||||
<LI><A href="isomorphism.html"><tt>isomorphism</tt></A>
|
||||
<li><a href="mcgregor_common_subgraphs.html"><tt>mcgregor_common_subgraphs</tt></a></li>
|
||||
</ol>
|
||||
|
||||
<li>Layout Algorithms
|
||||
<ol>
|
||||
<li><a href="topology.html">Topologies used as spaces for graph drawing</a></li>
|
||||
<li><a href="random_layout.html"><tt>random_graph_layout</tt></a></li>
|
||||
<li><a href="circle_layout.html"><tt>circle_layout</tt></a></li>
|
||||
<li><a href="kamada_kawai_spring_layout.html"><tt>kamada_kawai_spring_layout</tt></a></li>
|
||||
<li><a href="fruchterman_reingold.html"><tt>fruchterman_reingold_force_directed_layout</tt></a></li>
|
||||
<li><a href="gursoy_atun_layout.html"><tt>gursoy_atun_layout</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<LI><A href="topological_sort.html"><tt>topological_sort</tt></A>
|
||||
<li><a href="transitive_closure.html"><tt>transitive_closure</tt></a>
|
||||
<LI><A href="copy_graph.html"><tt>copy_graph</tt></A>
|
||||
<LI><A href="transpose_graph.html"><tt>transpose_graph</tt></A>
|
||||
<LI><A href="isomorphism.html"><tt>isomorphism</tt></A>
|
||||
|
||||
<li>Path and Tour Algorithms
|
||||
<ol>
|
||||
<li><a href="metric_tsp_approx.html"><tt>metric_tsp_approx</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
<LI><A href="sequential_vertex_coloring.html"><tt>sequential_vertex_coloring</tt></A>
|
||||
<li><a href="sloan_ordering.htm"><tt>sloan_ordering</tt></a></li>
|
||||
<li><a href="sloan_start_end_vertices.htm"><tt>sloan_start_end_vertices</tt></a></li>
|
||||
|
||||
<LI><A href="./wavefront.htm"><tt>ith_wavefront</tt>, <tt>max_wavefront</tt>, <tt>aver_wavefront</tt>, and <tt>rms_wavefront</tt></A></LI>
|
||||
<LI><A href="betweenness_centrality.html"><tt>brandes_betweenness_centrality</tt></A></LI>
|
||||
<li>Layout algorithms
|
||||
</li>
|
||||
<li>Clustering algorithms
|
||||
<ol>
|
||||
<li><a href="random_layout.html"><tt>random_graph_layout</tt></a></li>
|
||||
<li><a href="circle_layout.html"><tt>circle_layout</tt></a></li>
|
||||
<li><a href="kamada_kawai_spring_layout.html"><tt>kamada_kawai_spring_layout</tt></a></li>
|
||||
<li><a href="fruchterman_reingold.html"><tt>fruchterman_reingold_force_directed_layout</tt></a></li>
|
||||
<li><a href="gursoy_atun_layout.html"><tt>gursoy_atun_layout</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>Clustering algorithms
|
||||
<ol>
|
||||
<li><a href="bc_clustering.html"><tt>betweenness_centrality_clustering</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><a href="astar_search.html"><tt>astar_search</tt></a></li>
|
||||
<li><a href="lengauer_tarjan_dominator.htm"><tt>lengauer_tarjan_dominator_tree</tt></a></li>
|
||||
<li><a href="howard_cycle_ratio.html"><tt>minimum_cycle_ratio</tt> and <tt>maximum_cycle_ratio</tt></a></li>
|
||||
<li><a href="planar_graphs.html">Planar Graph Algorithms</a>
|
||||
<ol>
|
||||
<li><a href="boyer_myrvold.html">
|
||||
<tt>boyer_myrvold_planarity_test</tt></a>
|
||||
<li><a href="planar_face_traversal.html">
|
||||
<tt>planar_face_traversal</tt></a>
|
||||
<li><a href="planar_canonical_ordering.html">
|
||||
<tt>planar_canonical_ordering</tt></a>
|
||||
<li><a href="straight_line_drawing.html">
|
||||
<tt>chrobak_payne_straight_line_drawing</tt></a>
|
||||
<li><a href="is_straight_line_drawing.html">
|
||||
<tt>is_straight_line_drawing</tt></a>
|
||||
<li><a href="is_kuratowski_subgraph.html">
|
||||
<tt>is_kuratowski_subgraph</tt></a>
|
||||
<li><a href="make_connected.html">
|
||||
<tt>make_connected</tt></a>
|
||||
<li><a href="make_biconnected_planar.html">
|
||||
<tt>make_biconnected_planar</tt></a>
|
||||
<li><a href="make_maximal_planar.html">
|
||||
<tt>make_maximal_planar</tt></a>
|
||||
</ol>
|
||||
<li><a href="lengauer_tarjan_dominator.htm"><tt>lengauer_tarjan_dominator_tree</tt></a></li>
|
||||
<li><a href="mcgregor_common_subgraphs.html"><tt>mcgregor_common_subgraphs</tt></a></li>
|
||||
</OL>
|
||||
</OL>
|
||||
<li><a href="bc_clustering.html"><tt>betweenness_centrality_clustering</tt></a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><a href="planar_graphs.html">Planar Graph Algorithms</a>
|
||||
<ol>
|
||||
<li><a href="boyer_myrvold.html">
|
||||
<tt>boyer_myrvold_planarity_test</tt></a>
|
||||
<li><a href="planar_face_traversal.html">
|
||||
<tt>planar_face_traversal</tt></a>
|
||||
<li><a href="planar_canonical_ordering.html">
|
||||
<tt>planar_canonical_ordering</tt></a>
|
||||
<li><a href="straight_line_drawing.html">
|
||||
<tt>chrobak_payne_straight_line_drawing</tt></a>
|
||||
<li><a href="is_straight_line_drawing.html">
|
||||
<tt>is_straight_line_drawing</tt></a>
|
||||
<li><a href="is_kuratowski_subgraph.html">
|
||||
<tt>is_kuratowski_subgraph</tt></a>
|
||||
<li><a href="make_connected.html">
|
||||
<tt>make_connected</tt></a>
|
||||
<li><a href="make_biconnected_planar.html">
|
||||
<tt>make_biconnected_planar</tt></a>
|
||||
<li><a href="make_maximal_planar.html">
|
||||
<tt>make_maximal_planar</tt></a>
|
||||
</ol>
|
||||
|
||||
<li>Miscellaneous Algorithms
|
||||
<ol>
|
||||
<li><a href="metric_tsp_approx.html"><tt>metric_tsp_approx</tt></a></li>
|
||||
<LI><A href="sequential_vertex_coloring.html"><tt>sequential_vertex_coloring</tt></A>
|
||||
<LI><A href="is_bipartite.html"><tt>is_bipartite</tt></A> (including two-coloring of bipartite graphs)
|
||||
<LI><A href="find_odd_cycle.html"><tt>find_odd_cycle</tt></A>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
</OL>
|
||||
|
||||
<li>Graph Input/Output
|
||||
<ol>
|
||||
@@ -268,18 +298,16 @@
|
||||
<LI><a href="./BasicMatrix.html">BasicMatrix</a>
|
||||
<LI><a href="./incident.html"><tt>incident</tt></a>
|
||||
<LI><a href="./opposite.html"><tt>opposite</tt></a>
|
||||
<LI><a href="./bandwidth.html#sec:bandwidth"><tt>bandwidth</tt></a>
|
||||
<LI><a href="./bandwidth.html#sec:ith-bandwidth"><tt>ith_bandwidth</tt></a>
|
||||
<LI><a href="./random.html">Tools for random graphs</a>
|
||||
<OL>
|
||||
<LI><a href="./random.html#random_vertex">random_vertex</a>
|
||||
<LI><a href="./random.html#random_edge">random_edge</a>
|
||||
<LI><a href="./random.html#generate_random_graph">generate_random_graph</a>
|
||||
<LI><a href="./random.html#randomize_property">randomize_property</a>
|
||||
<li><a href="erdos_renyi_generator.html"><tt>erdos_renyi_iterator</tt></li>
|
||||
<li><a href="sorted_erdos_renyi_gen.html"><tt>sorted_erdos_renyi_iterator</tt></li>
|
||||
<li><a href="plod_generator.html"><tt>plod_iterator</tt></li>
|
||||
<li><a href="small_world_generator.html"><tt>small_world_iterator</tt></li>
|
||||
<li><a href="erdos_renyi_generator.html"><tt>erdos_renyi_iterator</tt></a></li>
|
||||
<li><a href="sorted_erdos_renyi_gen.html"><tt>sorted_erdos_renyi_iterator</tt></a></li>
|
||||
<li><a href="plod_generator.html"><tt>plod_iterator</tt></a></li>
|
||||
<li><a href="small_world_generator.html"><tt>small_world_iterator</tt></a></li>
|
||||
</OL>
|
||||
</OL>
|
||||
<LI><a href="./challenge.html">Challenge and To-Do List</a>
|
||||
|
||||
@@ -74,9 +74,9 @@ The following example shows the usage of the <tt>time_stamper</tt>.
|
||||
<TR><TD><TT>TimeMap</TT></TD>
|
||||
<TD>
|
||||
A <a
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>,
|
||||
href="../../property_map/doc/WritablePropertyMap.html">WritablePropertyMap</a>
|
||||
where the <tt>key_type</tt> is the vertex descriptor type or edge
|
||||
descriptor of the graph (depending on the kind of event tag), and
|
||||
descriptor of the graph (depending on the kind of event tag) and
|
||||
where the <tt>TimeT</tt> type is convertible to the
|
||||
<tt>value_type</tt> of the time property map.
|
||||
</TD>
|
||||
@@ -85,7 +85,7 @@ where the <tt>TimeT</tt> type is convertible to the
|
||||
|
||||
<TR><TD><TT>TimeT</TT></TD>
|
||||
<TD>
|
||||
The type for the time counter, which should be convertible to the
|
||||
The type for the time counter which should be convertible to the
|
||||
<tt>value_type</tt> of the time property map
|
||||
</TD>
|
||||
<TD> </TD>
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
<HTML>
|
||||
<!--
|
||||
Copyright (c) 2004, 2010 Trustees of Indiana University
|
||||
|
||||
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)
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Topologies for Graph Drawing</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">
|
||||
|
||||
<BR Clear>
|
||||
|
||||
<H1>
|
||||
Topologies for Graph Drawing
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims> class <a href="#convex_topology">convex_topology</a>;
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand> class <a href="#hypercube_topology">hypercube_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#square_topology">square_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#cube_topology">cube_topology</a>;
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand> class <a href="#ball_topology">ball_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#circle_topology">circle_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#sphere_topology">sphere_topology</a>;
|
||||
template<typename RandomNumberGenerator = minstd_rand> class <a href="#heart_topology">heart_topology</a>;
|
||||
</pre>
|
||||
|
||||
<h3>Summary</h3>
|
||||
|
||||
<p> <a href="#topologies">Various topologies</a> are provided that
|
||||
produce different, interesting results for graph layout algorithms. The <a
|
||||
href="#square_topology">square topology</a> can be used for normal
|
||||
display of graphs or distributing vertices for parallel computation on
|
||||
a process array, for instance. Other topologies, such as the <a
|
||||
href="#sphere_topology">sphere topology</a> (or N-dimensional <a
|
||||
href="#ball_topology">ball topology</a>) make sense for different
|
||||
problems, whereas the <a href="#heart_topology">heart topology</a> is
|
||||
just plain fun. One can also <a href="#topology-concept">define a
|
||||
topology</a> to suit other particular needs. <br>
|
||||
|
||||
<a name="topologies"><h3>Topologies</h3></a>
|
||||
A topology is a description of a space on which layout can be
|
||||
performed. Some common two, three, and multidimensional topologies
|
||||
are provided, or you may create your own so long as it meets the
|
||||
requirements of the <a href="#topology-concept">Topology concept</a>.
|
||||
|
||||
<a name="topology-concept"><h4>Topology Concept</h4></a> Let
|
||||
<tt>Topology</tt> be a model of the Topology concept and let
|
||||
<tt>space</tt> be an object of type <tt>Topology</tt>. <tt>p1</tt> and
|
||||
<tt>p2</tt> are objects of associated type <tt>point_type</tt> (see
|
||||
below). The following expressions must be valid:
|
||||
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Expression</th>
|
||||
<th>Type</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>Topology::point_type</tt></td>
|
||||
<td>type</td>
|
||||
<td>The type of points in the space.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>space.random_point()</tt></td>
|
||||
<td>point_type</td>
|
||||
<td>Returns a random point (usually uniformly distributed) within
|
||||
the space.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>space.distance(p1, p2)</tt></td>
|
||||
<td>double</td>
|
||||
<td>Get a quantity representing the distance between <tt>p1</tt>
|
||||
and <tt>p2</tt> using a path going completely inside the space.
|
||||
This only needs to have the same < relation as actual
|
||||
distances, and does not need to satisfy the other properties of a
|
||||
norm in a Banach space.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>space.move_position_toward(p1, fraction, p2)</tt></td>
|
||||
<td>point_type</td>
|
||||
<td>Returns a point that is a fraction of the way from <tt>p1</tt>
|
||||
to <tt>p2</tt>, moving along a "line" in the space according to
|
||||
the distance measure. <tt>fraction</tt> is a <tt>double</tt>
|
||||
between 0 and 1, inclusive.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a name="convex_topology"><h3>Class template <tt>convex_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>convex_topology</tt> implements the basic
|
||||
distance and point movement functions for any convex topology in
|
||||
<tt>Dims</tt> dimensions. It is not itself a topology, but is intended
|
||||
as a base class that any convex topology can derive from. The derived
|
||||
topology need only provide a suitable <tt>random_point</tt> function
|
||||
that returns a random point within the space.
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims>
|
||||
class convex_topology
|
||||
{
|
||||
struct point
|
||||
{
|
||||
point() { }
|
||||
double& operator[](std::size_t i) {return values[i];}
|
||||
const double& operator[](std::size_t i) const {return values[i];}
|
||||
|
||||
private:
|
||||
double values[Dims];
|
||||
};
|
||||
|
||||
public:
|
||||
typedef point point_type;
|
||||
|
||||
double distance(point a, point b) const;
|
||||
point move_position_toward(point a, double fraction, point b) const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="hypercube_topology"><h3>Class template <tt>hypercube_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>hypercube_topology</tt> implements a
|
||||
<tt>Dims</tt>-dimensional hypercube. It is a convex topology whose
|
||||
points are drawn from a random number generator of type
|
||||
<tt>RandomNumberGenerator</tt>. The <tt>hypercube_topology</tt> can
|
||||
be constructed with a given random number generator; if omitted, a
|
||||
new, default-constructed random number generator will be used. The
|
||||
resulting layout will be contained within the hypercube, whose sides
|
||||
measure 2*<tt>scaling</tt> long (points will fall in the range
|
||||
[-<tt>scaling</tt>, <tt>scaling</tt>] in each dimension).
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand>
|
||||
class hypercube_topology : public <a href="#convex_topology">convex_topology</a><Dims>
|
||||
{
|
||||
public:
|
||||
explicit hypercube_topology(double scaling = 1.0);
|
||||
hypercube_topology(RandomNumberGenerator& gen, double scaling = 1.0);
|
||||
point_type random_point() const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="square_topology"><h3>Class template <tt>square_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>square_topology</tt> is a two-dimensional
|
||||
hypercube topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class square_topology : public <a href="#hypercube_topology">hypercube_topology</a><2, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit square_topology(double scaling = 1.0);
|
||||
square_topology(RandomNumberGenerator& gen, double scaling = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="cube_topology"><h3>Class template <tt>cube_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>cube_topology</tt> is a two-dimensional
|
||||
hypercube topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class cube_topology : public <a href="#hypercube_topology">hypercube_topology</a><3, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit cube_topology(double scaling = 1.0);
|
||||
cube_topology(RandomNumberGenerator& gen, double scaling = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="ball_topology"><h3>Class template <tt>ball_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>ball_topology</tt> implements a
|
||||
<tt>Dims</tt>-dimensional ball. It is a convex topology whose points
|
||||
are drawn from a random number generator of type
|
||||
<tt>RandomNumberGenerator</tt> but reside inside the ball. The
|
||||
<tt>ball_topology</tt> can be constructed with a given random number
|
||||
generator; if omitted, a new, default-constructed random number
|
||||
generator will be used. The resulting layout will be contained within
|
||||
the ball with the given <tt>radius</tt>.
|
||||
|
||||
<pre>
|
||||
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand>
|
||||
class ball_topology : public <a href="#convex_topology">convex_topology</a><Dims>
|
||||
{
|
||||
public:
|
||||
explicit ball_topology(double radius = 1.0);
|
||||
ball_topology(RandomNumberGenerator& gen, double radius = 1.0);
|
||||
point_type random_point() const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="circle_topology"><h3>Class template <tt>circle_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>circle_topology</tt> is a two-dimensional
|
||||
ball topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class circle_topology : public <a href="#ball_topology">ball_topology</a><2, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit circle_topology(double radius = 1.0);
|
||||
circle_topology(RandomNumberGenerator& gen, double radius = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="sphere_topology"><h3>Class template <tt>sphere_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>sphere_topology</tt> is a two-dimensional
|
||||
ball topology.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class sphere_topology : public <a href="#ball_topology">ball_topology</a><3, RandomNumberGenerator>
|
||||
{
|
||||
public:
|
||||
explicit sphere_topology(double radius = 1.0);
|
||||
sphere_topology(RandomNumberGenerator& gen, double radius = 1.0);
|
||||
};
|
||||
</pre>
|
||||
|
||||
<a name="heart_topology"><h3>Class template <tt>heart_topology</tt></h3></a>
|
||||
|
||||
<p>Class template <tt>heart_topology</tt> is topology in the shape of
|
||||
a heart. It serves as an example of a non-convex, nontrivial topology
|
||||
for layout.
|
||||
|
||||
<pre>
|
||||
template<typename RandomNumberGenerator = minstd_rand>
|
||||
class heart_topology
|
||||
{
|
||||
public:
|
||||
typedef <em>unspecified</em> point_type;
|
||||
|
||||
heart_topology();
|
||||
heart_topology(RandomNumberGenerator& gen);
|
||||
point_type random_point() const;
|
||||
double distance(point_type a, point_type b) const;
|
||||
point_type move_position_toward(point_type a, double fraction, point_type b) const;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2004, 2010 Trustees of Indiana University</TD><TD>
|
||||
Jeremiah Willcock, Indiana University (<script language="Javascript">address("osl.iu.edu", "jewillco")</script>)<br>
|
||||
<A HREF="http://www.boost.org/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>
|
||||
@@ -56,8 +56,9 @@ Thanks to Vladimir Prus for the implementation of this algorithm!
|
||||
IN: <tt>const Graph& g</tt>
|
||||
<blockquote>
|
||||
A directed graph, where the <tt>Graph</tt> type must model the
|
||||
<a href="./VertexListGraph.html">Vertex List Graph</a>
|
||||
and <a href="./AdjacencyGraph.html">Adjacency Graph</a> concepts.<br>
|
||||
<a href="./VertexListGraph.html">Vertex List Graph</a>,
|
||||
<a href="./AdjacencyGraph.html">Adjacency Graph</a>,
|
||||
and <a href="./AdjacencyMatrix.html">Adjacency Matrix</a> concepts.<br>
|
||||
|
||||
<b>Python</b>: The parameter is named <tt>graph</tt>.
|
||||
</blockquote>
|
||||
|
||||
@@ -102,7 +102,7 @@ template <typename Graph, typename WeightMap, typename OutputIterator, typena
|
||||
tsp_tour_len_visitor<OutputIterator><br>
|
||||
make_tsp_tour_len_visitor(Graph const& g, OutIter iter, Length& l, WeightMap map)
|
||||
</tt></td><td>
|
||||
Returns a tour_len_visitor that records the TSP tour in the OutputIterator parameter and the tour's length in the Length parameter.
|
||||
Returns a tour_len_visitor that records the TSP tour in the OutputIterator parameter and the length of the tour in the Length parameter.
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
@@ -40,6 +40,8 @@ the following visitor concepts:
|
||||
<li> <a href="./BellmanFordVisitor.html">Bellman Ford Visitor</a>
|
||||
<li> <a href="./AStarVisitor.html">A* Visitor</a>
|
||||
<li> <a href="./EventVisitor.html">Event Visitor</a>
|
||||
<li> <a href="./PlanarFaceVisitor.html">Planar Face Visitor</a>
|
||||
<li> <a href="./TSPTourVisitor.html">TSP Tour Visitor</a>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -57,15 +57,15 @@ write_graphviz(std::ostream& out, const VertexAndEdgeListGraph& g,
|
||||
// Graph structure with dynamic property output
|
||||
template<typename Graph>
|
||||
void
|
||||
write_graphviz(std::ostream& out, const Graph& g,
|
||||
const dynamic_properties& dp,
|
||||
const std::string& node_id = "node_id");
|
||||
write_graphviz_dp(std::ostream& out, const Graph& g,
|
||||
const dynamic_properties& dp,
|
||||
const std::string& node_id = "node_id");
|
||||
|
||||
template<typename Graph, typename VertexID>
|
||||
void
|
||||
write_graphviz(std::ostream& out, const Graph& g,
|
||||
const dynamic_properties& dp, const std::string& node_id,
|
||||
VertexID vertex_id);
|
||||
write_graphviz_dp(std::ostream& out, const Graph& g,
|
||||
const dynamic_properties& dp, const std::string& node_id,
|
||||
VertexID vertex_id);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -92,7 +92,7 @@ version and fourth version require vertex
|
||||
<a href="./write-graphviz.html#concept:PropertyWriter">PropertyWriter</a>,
|
||||
respectively.
|
||||
|
||||
<p> The final two overloads of <code>write_graphviz</code> will emit
|
||||
<p> The two overloads of <code>write_graphviz_dp</code> will emit
|
||||
all of the properties stored in the <a
|
||||
href="../../property_map/doc/dynamic_property_map.html"><code>dynamic_properties</a></code>
|
||||
object, thereby retaining the properties that have been read in
|
||||
@@ -329,10 +329,6 @@ href="../example/graphviz.cpp">example using
|
||||
|
||||
<a href="./read_graphviz.html"><tt>read_graphviz</tt></a>
|
||||
|
||||
<h3>Notes</h3>
|
||||
Note that you can use Graphviz dot file write facilities
|
||||
without the library <tt>libbglviz.a</tt>.
|
||||
|
||||
<br>
|
||||
<HR>
|
||||
<TABLE>
|
||||
|
||||
@@ -20,3 +20,10 @@ exe bron_kerbosch_print_cliques : bron_kerbosch_print_cliques.cpp ;
|
||||
exe bron_kerbosch_clique_number : bron_kerbosch_clique_number.cpp ;
|
||||
exe mcgregor_subgraphs_example : mcgregor_subgraphs_example.cpp ;
|
||||
exe grid_graph_example : grid_graph_example.cpp ;
|
||||
exe bipartite_example : bipartite_example.cpp ;
|
||||
exe fr_layout : fr_layout.cpp ;
|
||||
exe canonical_ordering : canonical_ordering.cpp ;
|
||||
exe components_on_edgelist : components_on_edgelist.cpp ;
|
||||
exe boykov_kolmogorov-eg : boykov_kolmogorov-eg.cpp ;
|
||||
exe ospf-example : ospf-example.cpp ../build//boost_graph ;
|
||||
# exe cc-internet : cc-internet.cpp ../build//boost_graph ;
|
||||
|
||||
@@ -85,14 +85,14 @@ main()
|
||||
std::ifstream name_in("makefile-target-names.dat");
|
||||
std::ifstream compile_cost_in("target-compile-costs.dat");
|
||||
graph_traits < file_dep_graph2 >::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
name_in >> name_map[*vi];
|
||||
compile_cost_in >> compile_cost_map[*vi];
|
||||
}
|
||||
|
||||
graph_property_iter_range < file_dep_graph2,
|
||||
vertex_compile_cost_t >::iterator ci, ci_end;
|
||||
tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost);
|
||||
boost::tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost);
|
||||
std::cout << "total (sequential) compile time: "
|
||||
<< std::accumulate(ci, ci_end, 0.0) << std::endl;
|
||||
|
||||
|
||||
@@ -164,8 +164,8 @@ int main(int argc, char **argv)
|
||||
WeightMap weightmap = get(edge_weight, g);
|
||||
for(std::size_t j = 0; j < num_edges; ++j) {
|
||||
edge_descriptor e; bool inserted;
|
||||
tie(e, inserted) = add_edge(edge_array[j].first,
|
||||
edge_array[j].second, g);
|
||||
boost::tie(e, inserted) = add_edge(edge_array[j].first,
|
||||
edge_array[j].second, g);
|
||||
weightmap[e] = weights[j];
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ main()
|
||||
property_map<Graph, int EdgeProperties::*>::type
|
||||
weight_pmap = get(&EdgeProperties::weight, g);
|
||||
int i = 0;
|
||||
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i)
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i)
|
||||
weight_pmap[*ei] = weight[i];
|
||||
|
||||
std::vector<int> distance(N, (std::numeric_limits < short >::max)());
|
||||
@@ -108,7 +108,7 @@ main()
|
||||
<< " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n";
|
||||
|
||||
{
|
||||
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
graph_traits < Graph >::edge_descriptor e = *ei;
|
||||
graph_traits < Graph >::vertex_descriptor
|
||||
u = source(e, g), v = target(e, g);
|
||||
|
||||
@@ -78,7 +78,7 @@ main()
|
||||
std::vector < Size > dtime(num_vertices(g));
|
||||
graph_traits<graph_t>::vertex_iterator vi, vi_end;
|
||||
std::size_t c = 0;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c)
|
||||
dtime[c] = dtime_map[*vi];
|
||||
|
||||
// Use std::sort to order the vertices by their discover time
|
||||
|
||||
@@ -32,19 +32,19 @@ build_router_network(Graph & g, VertexNameMap name_map,
|
||||
typename graph_traits<Graph>::edge_descriptor ed;
|
||||
bool inserted;
|
||||
|
||||
tie(ed, inserted) = add_edge(a, b, g);
|
||||
boost::tie(ed, inserted) = add_edge(a, b, g);
|
||||
delay_map[ed] = 1.2;
|
||||
tie(ed, inserted) = add_edge(a, d, g);
|
||||
boost::tie(ed, inserted) = add_edge(a, d, g);
|
||||
delay_map[ed] = 4.5;
|
||||
tie(ed, inserted) = add_edge(b, d, g);
|
||||
boost::tie(ed, inserted) = add_edge(b, d, g);
|
||||
delay_map[ed] = 1.8;
|
||||
tie(ed, inserted) = add_edge(c, a, g);
|
||||
boost::tie(ed, inserted) = add_edge(c, a, g);
|
||||
delay_map[ed] = 2.6;
|
||||
tie(ed, inserted) = add_edge(c, e, g);
|
||||
boost::tie(ed, inserted) = add_edge(c, e, g);
|
||||
delay_map[ed] = 5.2;
|
||||
tie(ed, inserted) = add_edge(d, c, g);
|
||||
boost::tie(ed, inserted) = add_edge(d, c, g);
|
||||
delay_map[ed] = 0.4;
|
||||
tie(ed, inserted) = add_edge(d, e, g);
|
||||
boost::tie(ed, inserted) = add_edge(d, e, g);
|
||||
delay_map[ed] = 3.3;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ main()
|
||||
}
|
||||
|
||||
graph_traits < graph_t >::edge_iterator ei, ei_end;
|
||||
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
std::cout << (char)(source(*ei, g) + 'A') << " -- "
|
||||
<< (char)(target(*ei, g) + 'A')
|
||||
<< "[label=\"" << component[*ei] << "\"]\n";
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
*
|
||||
* Copyright (c) 2010 Matthias Walter (xammy@xammy.homelinux.net)
|
||||
*
|
||||
* Authors: Matthias Walter
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/bipartite.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
/// Example to test for bipartiteness and print the certificates.
|
||||
|
||||
template <typename Graph>
|
||||
void print_bipartite (const Graph& g)
|
||||
{
|
||||
typedef graph_traits <Graph> traits;
|
||||
typename traits::vertex_iterator vertex_iter, vertex_end;
|
||||
|
||||
/// Most simple interface just tests for bipartiteness.
|
||||
|
||||
bool bipartite = is_bipartite (g);
|
||||
|
||||
if (bipartite)
|
||||
{
|
||||
typedef std::vector <default_color_type> partition_t;
|
||||
typedef vec_adj_list_vertex_id_map <no_property, unsigned int> index_map_t;
|
||||
typedef iterator_property_map <partition_t::iterator, index_map_t> partition_map_t;
|
||||
|
||||
partition_t partition (num_vertices (g));
|
||||
partition_map_t partition_map (partition.begin (), get (vertex_index, g));
|
||||
|
||||
/// A second interface yields a bipartition in a color map, if the graph is bipartite.
|
||||
|
||||
is_bipartite (g, get (vertex_index, g), partition_map);
|
||||
|
||||
for (boost::tie (vertex_iter, vertex_end) = vertices (g); vertex_iter != vertex_end; ++vertex_iter)
|
||||
{
|
||||
std::cout << "Vertex " << *vertex_iter << " has color " << (get (partition_map, *vertex_iter) == color_traits <
|
||||
default_color_type>::white () ? "white" : "black") << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef std::vector <typename traits::vertex_descriptor> vertex_vector_t;
|
||||
vertex_vector_t odd_cycle;
|
||||
|
||||
/// A third interface yields an odd-cycle if the graph is not bipartite.
|
||||
|
||||
find_odd_cycle (g, get (vertex_index, g), std::back_inserter (odd_cycle));
|
||||
|
||||
std::cout << "Odd cycle consists of the vertices:";
|
||||
for (size_t i = 0; i < odd_cycle.size (); ++i)
|
||||
{
|
||||
std::cout << " " << odd_cycle[i];
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
typedef adjacency_list <vecS, vecS, undirectedS> vector_graph_t;
|
||||
typedef std::pair <int, int> E;
|
||||
|
||||
/**
|
||||
* Create the graph drawn below.
|
||||
*
|
||||
* 0 - 1 - 2
|
||||
* | |
|
||||
* 3 - 4 - 5 - 6
|
||||
* / \ /
|
||||
* | 7
|
||||
* | |
|
||||
* 8 - 9 - 10
|
||||
**/
|
||||
|
||||
E bipartite_edges[] = { E (0, 1), E (0, 4), E (1, 2), E (2, 6), E (3, 4), E (3, 8), E (4, 5), E (4, 7), E (5, 6), E (
|
||||
6, 7), E (7, 10), E (8, 9), E (9, 10) };
|
||||
vector_graph_t bipartite_vector_graph (&bipartite_edges[0],
|
||||
&bipartite_edges[0] + sizeof(bipartite_edges) / sizeof(E), 11);
|
||||
|
||||
/**
|
||||
* Create the graph drawn below.
|
||||
*
|
||||
* 2 - 1 - 0
|
||||
* | |
|
||||
* 3 - 6 - 5 - 4
|
||||
* / \ /
|
||||
* | 7
|
||||
* | /
|
||||
* 8 ---- 9
|
||||
*
|
||||
**/
|
||||
|
||||
E non_bipartite_edges[] = { E (0, 1), E (0, 4), E (1, 2), E (2, 6), E (3, 6), E (3, 8), E (4, 5), E (4, 7), E (5, 6),
|
||||
E (6, 7), E (7, 9), E (8, 9) };
|
||||
vector_graph_t non_bipartite_vector_graph (&non_bipartite_edges[0], &non_bipartite_edges[0]
|
||||
+ sizeof(non_bipartite_edges) / sizeof(E), 10);
|
||||
|
||||
/// Call test routine for a bipartite and a non-bipartite graph.
|
||||
|
||||
print_bipartite (bipartite_vector_graph);
|
||||
|
||||
print_bipartite (non_bipartite_vector_graph);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ main()
|
||||
|
||||
std::list<std::string>::iterator i = line_toks.begin();
|
||||
|
||||
tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex()));
|
||||
boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex()));
|
||||
if (inserted) {
|
||||
u = add_vertex(g);
|
||||
put(node_name, u, *i);
|
||||
@@ -127,7 +127,7 @@ main()
|
||||
|
||||
std::string hyperlink_name = *i++;
|
||||
|
||||
tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex()));
|
||||
boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex()));
|
||||
if (inserted) {
|
||||
v = add_vertex(g);
|
||||
put(node_name, v, *i);
|
||||
@@ -136,7 +136,7 @@ main()
|
||||
v = pos->second;
|
||||
|
||||
Edge e;
|
||||
tie(e, inserted) = add_edge(u, v, g);
|
||||
boost::tie(e, inserted) = add_edge(u, v, g);
|
||||
if (inserted) {
|
||||
put(link_name, e, hyperlink_name);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ main()
|
||||
|
||||
std::cout << "Number of clicks from the home page: " << std::endl;
|
||||
Traits::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
std::cout << d_matrix[0][*vi] << "\t" << node_name[*vi] << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
@@ -179,7 +179,7 @@ main()
|
||||
|
||||
// Create storage for a mapping from vertices to their parents
|
||||
std::vector<Traits::vertex_descriptor> parent(num_vertices(g));
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
parent[*vi] = *vi;
|
||||
|
||||
// Do a BFS starting at the home page, recording the parent of each
|
||||
@@ -192,7 +192,7 @@ main()
|
||||
|
||||
// Add all the search tree edges into a new graph
|
||||
Graph search_tree(num_vertices(g));
|
||||
tie(vi, vi_end) = vertices(g);
|
||||
boost::tie(vi, vi_end) = vertices(g);
|
||||
++vi;
|
||||
for (; vi != vi_end; ++vi)
|
||||
add_edge(parent[*vi], *vi, search_tree);
|
||||
@@ -205,7 +205,7 @@ main()
|
||||
std::vector<size_type> dfs_distances(num_vertices(g), 0);
|
||||
print_tree_visitor<NameMap, size_type*>
|
||||
tree_printer(node_name, &dfs_distances[0]);
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
get(vertex_color, g)[*vi] = white_color;
|
||||
depth_first_visit(search_tree, src, tree_printer, get(vertex_color, g));
|
||||
|
||||
|
||||
@@ -32,18 +32,18 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <boost/graph/kolmogorov_max_flow.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
|
||||
#include <boost/graph/read_dimacs.hpp>
|
||||
#include <boost/graph/graph_utility.hpp>
|
||||
|
||||
// Use a DIMACS network flow file as stdin.
|
||||
// kolmogorov-eg < max_flow.dat
|
||||
// boykov_kolmogorov-eg < max_flow.dat
|
||||
//
|
||||
// Sample output:
|
||||
// c The total flow:
|
||||
// s 13
|
||||
//
|
||||
//
|
||||
// c flow values:
|
||||
// f 0 6 3
|
||||
// f 0 1 6
|
||||
@@ -66,8 +66,7 @@
|
||||
// f 7 6 0
|
||||
// f 7 5 0
|
||||
|
||||
int
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
@@ -78,11 +77,11 @@ main()
|
||||
property < vertex_color_t, boost::default_color_type,
|
||||
property < vertex_distance_t, long,
|
||||
property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
|
||||
|
||||
|
||||
property < edge_capacity_t, long,
|
||||
property < edge_residual_capacity_t, long,
|
||||
property < edge_reverse_t, Traits::edge_descriptor > > > > Graph;
|
||||
|
||||
|
||||
Graph g;
|
||||
property_map < Graph, edge_capacity_t >::type
|
||||
capacity = get(edge_capacity, g);
|
||||
@@ -94,7 +93,7 @@ main()
|
||||
|
||||
std::vector<default_color_type> color(num_vertices(g));
|
||||
std::vector<long> distance(num_vertices(g));
|
||||
long flow = kolmogorov_max_flow(g ,s, t);
|
||||
long flow = boykov_kolmogorov_max_flow(g ,s, t);
|
||||
|
||||
std::cout << "c The total flow:" << std::endl;
|
||||
std::cout << "s " << flow << std::endl << std::endl;
|
||||
@@ -102,8 +101,8 @@ main()
|
||||
std::cout << "c flow values:" << std::endl;
|
||||
graph_traits < Graph >::vertex_iterator u_iter, u_end;
|
||||
graph_traits < Graph >::out_edge_iterator ei, e_end;
|
||||
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
|
||||
for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
|
||||
for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
|
||||
for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
|
||||
if (capacity[*ei] > 0)
|
||||
std::cout << "f " << *u_iter << " " << target(*ei, g) << " "
|
||||
<< (capacity[*ei] - residual_capacity[*ei]) << std::endl;
|
||||
@@ -30,7 +30,7 @@ main()
|
||||
std::string color[] = {
|
||||
"white", "gray", "black", "lightgray"};
|
||||
graph_traits < GraphvizGraph >::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
vertex_attr_map[*vi]["color"] = color[component[*vi]];
|
||||
vertex_attr_map[*vi]["style"] = "filled";
|
||||
if (vertex_attr_map[*vi]["color"] == "black")
|
||||
|
||||
@@ -68,7 +68,7 @@ int main(int , char* [])
|
||||
print_edges(g, identity_property_map());
|
||||
cout << endl;
|
||||
|
||||
disjoint_sets_with_storage<> ds;
|
||||
disjoint_sets_with_storage<> ds(N);
|
||||
incremental_components(g, ds);
|
||||
|
||||
component_index<int> components(&ds.parents()[0],
|
||||
@@ -80,11 +80,11 @@ int main(int , char* [])
|
||||
<< ds.find_set(k) << endl;
|
||||
cout << endl;
|
||||
|
||||
for (component_index<int>::size_type i = 0; i < components.size(); ++i) {
|
||||
for (std::size_t i = 0; i < components.size(); ++i) {
|
||||
cout << "component " << i << " contains: ";
|
||||
component_index<int>::value_type::iterator
|
||||
j = components[i].begin(),
|
||||
jend = components[i].end();
|
||||
component_index<int>::component_iterator
|
||||
j = components[i].first,
|
||||
jend = components[i].second;
|
||||
for ( ; j != jend; ++j)
|
||||
cout << *j << " ";
|
||||
cout << endl;
|
||||
|
||||
@@ -26,7 +26,7 @@ main()
|
||||
name_map = get(vertex_name, G);
|
||||
char name = 'a';
|
||||
graph_traits < graph_t >::vertex_iterator v, v_end;
|
||||
for (tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
|
||||
for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
|
||||
name_map[*v] = name;
|
||||
|
||||
typedef std::pair < int, int >E;
|
||||
|
||||
@@ -38,7 +38,7 @@ has_cycle_dfs(const file_dep_graph & g, vertex_t u,
|
||||
{
|
||||
color[u] = gray_color;
|
||||
graph_traits < file_dep_graph >::adjacency_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi)
|
||||
if (color[*vi] == white_color) {
|
||||
if (has_cycle_dfs(g, *vi, color))
|
||||
return true; // cycle detected, return immediately
|
||||
@@ -53,7 +53,7 @@ has_cycle(const file_dep_graph & g)
|
||||
{
|
||||
std::vector < default_color_type > color(num_vertices(g), white_color);
|
||||
graph_traits < file_dep_graph >::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
if (color[*vi] == white_color)
|
||||
if (has_cycle_dfs(g, *vi, &color[0]))
|
||||
return true;
|
||||
@@ -75,7 +75,7 @@ main()
|
||||
file_dep_graph g(n_vertices);
|
||||
while (input_begin != input_end) {
|
||||
size_type i, j;
|
||||
tie(i, j) = *input_begin++;
|
||||
boost::tie(i, j) = *input_begin++;
|
||||
add_edge(i, j, g);
|
||||
}
|
||||
#else
|
||||
@@ -85,7 +85,7 @@ main()
|
||||
std::vector < std::string > name(num_vertices(g));
|
||||
std::ifstream name_in("makefile-target-names.dat");
|
||||
graph_traits < file_dep_graph >::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
name_in >> name[*vi];
|
||||
|
||||
assert(has_cycle(g) == false);
|
||||
|
||||
@@ -42,7 +42,7 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color,
|
||||
color[u] = gray_color;
|
||||
vis.discover_vertex(u, g);
|
||||
graph_traits < file_dep_graph >::out_edge_iterator ei, ei_end;
|
||||
for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) {
|
||||
for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) {
|
||||
if (color[target(*ei, g)] == white_color) {
|
||||
vis.tree_edge(*ei, g);
|
||||
dfs_v1(g, target(*ei, g), color, vis);
|
||||
@@ -60,7 +60,7 @@ generic_dfs_v1(const file_dep_graph & g, Visitor vis)
|
||||
{
|
||||
std::vector < default_color_type > color(num_vertices(g), white_color);
|
||||
graph_traits < file_dep_graph >::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
if (color[*vi] == white_color)
|
||||
dfs_v1(g, *vi, &color[0], vis);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ main()
|
||||
file_dep_graph g(n_vertices);
|
||||
while (input_begin != input_end) {
|
||||
size_type i, j;
|
||||
tie(i, j) = *input_begin++;
|
||||
boost::tie(i, j) = *input_begin++;
|
||||
add_edge(i, j, g);
|
||||
}
|
||||
#else
|
||||
@@ -142,7 +142,7 @@ main()
|
||||
std::vector < std::string > name(num_vertices(g));
|
||||
std::ifstream name_in("makefile-target-names.dat");
|
||||
graph_traits < file_dep_graph >::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
name_in >> name[*vi];
|
||||
|
||||
assert(has_cycle(g) == false);
|
||||
|
||||
@@ -60,7 +60,7 @@ int main(int argc, char* argv[])
|
||||
cout << "Edges number: " << num_edges(tgr) << endl;
|
||||
int i = 0;
|
||||
graph_traits<grap_real_t>::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) {
|
||||
for (boost::tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) {
|
||||
vim[*vi] = i++; ///Initialize vertex index property
|
||||
}
|
||||
max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2);
|
||||
|
||||
@@ -60,7 +60,7 @@ int main()
|
||||
#endif
|
||||
|
||||
graph_traits<graph_t>::vertex_iterator vi , vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
if (d_map[*vi] == (std::numeric_limits<int>::max)())
|
||||
std::cout << name[*vi] << ": inifinity\n";
|
||||
else
|
||||
|
||||
@@ -36,7 +36,7 @@ main()
|
||||
GraphvizGraph g;
|
||||
read_graphviz("figs/dfs-example.dot", g);
|
||||
graph_traits < GraphvizGraph >::edge_iterator e, e_end;
|
||||
for (tie(e, e_end) = edges(g); e != e_end; ++e)
|
||||
for (boost::tie(e, e_end) = edges(g); e != e_end; ++e)
|
||||
std::cout << '(' << name[source(*e, g)] << ' '
|
||||
<< name[target(*e, g)] << ')' << std::endl;
|
||||
parenthesis_visitor
|
||||
|
||||
@@ -43,13 +43,13 @@ main(int, char *[])
|
||||
property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
|
||||
|
||||
std::vector<vertex_descriptor> msvc_vertices;
|
||||
for (tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
for (boost::tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
msvc_vertices.push_back(*i);
|
||||
|
||||
for (std::size_t j = 0; j < num_arcs; ++j) {
|
||||
edge_descriptor e; bool inserted;
|
||||
tie(e, inserted) = add_edge(msvc_vertices[edge_array[j].first],
|
||||
msvc_vertices[edge_array[j].second], g);
|
||||
boost::tie(e, inserted) = add_edge(msvc_vertices[edge_array[j].first],
|
||||
msvc_vertices[edge_array[j].second], g);
|
||||
weightmap[e] = weights[j];
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ main(int, char *[])
|
||||
property_map<graph_t, vertex_index_t>::type indexmap = get(vertex_index, g);
|
||||
property_map<graph_t, vertex_name_t>::type name = get(vertex_name, g);
|
||||
int c = 0;
|
||||
for (tie(i, iend) = vertices(g); i != iend; ++i, ++c) {
|
||||
for (boost::tie(i, iend) = vertices(g); i != iend; ++i, ++c) {
|
||||
indexmap[*i] = c;
|
||||
name[*i] = 'A' + c;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ main(int, char *[])
|
||||
|
||||
std::cout << "distances and parents:" << std::endl;
|
||||
graph_traits < graph_t >::vertex_iterator vi, vend;
|
||||
for (tie(vi, vend) = vertices(g); vi != vend; ++vi) {
|
||||
for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) {
|
||||
std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", ";
|
||||
std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::
|
||||
endl;
|
||||
@@ -101,7 +101,7 @@ main(int, char *[])
|
||||
<< " edge[style=\"bold\"]\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) {
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
graph_traits < graph_t >::edge_descriptor e = *ei;
|
||||
graph_traits < graph_t >::vertex_descriptor
|
||||
u = source(e, g), v = target(e, g);
|
||||
|
||||
@@ -37,7 +37,7 @@ main(int, char *[])
|
||||
property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
|
||||
for (std::size_t j = 0; j < num_arcs; ++j) {
|
||||
edge_descriptor e; bool inserted;
|
||||
tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g);
|
||||
boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g);
|
||||
weightmap[e] = weights[j];
|
||||
}
|
||||
#else
|
||||
@@ -61,7 +61,7 @@ main(int, char *[])
|
||||
|
||||
std::cout << "distances and parents:" << std::endl;
|
||||
graph_traits < graph_t >::vertex_iterator vi, vend;
|
||||
for (tie(vi, vend) = vertices(g); vi != vend; ++vi) {
|
||||
for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) {
|
||||
std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", ";
|
||||
std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::
|
||||
endl;
|
||||
@@ -77,7 +77,7 @@ main(int, char *[])
|
||||
<< " edge[style=\"bold\"]\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) {
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
graph_traits < graph_t >::edge_descriptor e = *ei;
|
||||
graph_traits < graph_t >::vertex_descriptor
|
||||
u = source(e, g), v = target(e, g);
|
||||
|
||||
@@ -41,7 +41,7 @@ main(int, char *[])
|
||||
property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
|
||||
for (std::size_t j = 0; j < num_arcs; ++j) {
|
||||
edge_descriptor e; bool inserted;
|
||||
tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g);
|
||||
boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g);
|
||||
weightmap[e] = weights[j];
|
||||
}
|
||||
#else
|
||||
@@ -66,7 +66,7 @@ main(int, char *[])
|
||||
|
||||
std::cout << "distances and parents:" << std::endl;
|
||||
graph_traits < graph_t >::vertex_iterator vi, vend;
|
||||
for (tie(vi, vend) = vertices(g); vi != vend; ++vi) {
|
||||
for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) {
|
||||
std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", ";
|
||||
std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::
|
||||
endl;
|
||||
@@ -82,7 +82,7 @@ main(int, char *[])
|
||||
<< " edge[style=\"bold\"]\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) {
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
graph_traits < graph_t >::edge_descriptor e = *ei;
|
||||
graph_traits < graph_t >::vertex_descriptor
|
||||
u = source(e, g), v = target(e, g);
|
||||
|
||||
@@ -73,11 +73,11 @@ main(int argc, char *argv[])
|
||||
int r, d;
|
||||
EccentricityContainer eccs(num_vertices(g));
|
||||
EccentricityMap em(eccs, g);
|
||||
tie(r, d) = all_eccentricities(g, dm, em);
|
||||
boost::tie(r, d) = all_eccentricities(g, dm, em);
|
||||
|
||||
// Print the closeness centrality of each vertex.
|
||||
graph_traits<Graph>::vertex_iterator i, end;
|
||||
for(tie(i, end) = vertices(g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = vertices(g); i != end; ++i) {
|
||||
cout << setw(12) << setiosflags(ios::left)
|
||||
<< g[*i].name << get(em, *i) << endl;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace boost
|
||||
typedef typename graph_traits < Graph >::degree_size_type size_type;
|
||||
size_type delta = (std::numeric_limits < size_type >::max)();
|
||||
typename graph_traits < Graph >::vertex_iterator i, iend;
|
||||
for (tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
for (boost::tie(i, iend) = vertices(g); i != iend; ++i)
|
||||
if (degree(*i, g) < delta)
|
||||
{
|
||||
delta = degree(*i, g);
|
||||
@@ -39,7 +39,7 @@ namespace boost
|
||||
OutputIterator result)
|
||||
{
|
||||
typename graph_traits < Graph >::adjacency_iterator ai, aend;
|
||||
for (tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai)
|
||||
for (boost::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai)
|
||||
*result++ = *ai;
|
||||
}
|
||||
template < typename Graph, typename VertexIterator,
|
||||
@@ -87,17 +87,17 @@ namespace boost
|
||||
rev_edge = get(edge_reverse, flow_g);
|
||||
|
||||
typename graph_traits < VertexListGraph >::edge_iterator ei, ei_end;
|
||||
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) {
|
||||
u = source(*ei, g), v = target(*ei, g);
|
||||
tie(e1, inserted) = add_edge(u, v, flow_g);
|
||||
boost::tie(e1, inserted) = add_edge(u, v, flow_g);
|
||||
cap[e1] = 1;
|
||||
tie(e2, inserted) = add_edge(v, u, flow_g);
|
||||
boost::tie(e2, inserted) = add_edge(v, u, flow_g);
|
||||
cap[e2] = 1;
|
||||
rev_edge[e1] = e2;
|
||||
rev_edge[e2] = e1;
|
||||
}
|
||||
|
||||
tie(p, delta) = min_degree_vertex(g);
|
||||
boost::tie(p, delta) = min_degree_vertex(g);
|
||||
S_star.push_back(p);
|
||||
alpha_star = delta;
|
||||
S.insert(p);
|
||||
@@ -115,7 +115,7 @@ namespace boost
|
||||
if (alpha_S_k < alpha_star) {
|
||||
alpha_star = alpha_S_k;
|
||||
S_star.clear();
|
||||
for (tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi)
|
||||
if (color[*vi] != Color::white())
|
||||
S_star.push_back(*vi);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace boost
|
||||
degree_size_type c = 0;
|
||||
for (si = S_star.begin(); si != S_star.end(); ++si) {
|
||||
typename graph_traits < VertexListGraph >::out_edge_iterator ei, ei_end;
|
||||
for (tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei)
|
||||
for (boost::tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei)
|
||||
if (!in_S_star[target(*ei, g)]) {
|
||||
*disconnecting_set++ = *ei;
|
||||
++c;
|
||||
|
||||
@@ -43,7 +43,7 @@ output_adjacent_vertices(std::ostream & out,
|
||||
{
|
||||
typename graph_traits < Graph >::adjacency_iterator vi, vi_end;
|
||||
out << get(name_map, u) << " -> { ";
|
||||
for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi)
|
||||
for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi)
|
||||
out << get(name_map, *vi) << " ";
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ main()
|
||||
name_map_t name = get(vertex_name, g);
|
||||
// Get iterators for the vertex set
|
||||
graph_traits < graph_type >::vertex_iterator i, end;
|
||||
tie(i, end) = vertices(g);
|
||||
boost::tie(i, end) = vertices(g);
|
||||
// Find yow.h
|
||||
name_equals_t < name_map_t > predicate1("yow.h", name);
|
||||
yow = *std::find_if(i, end, predicate1);
|
||||
@@ -123,13 +123,13 @@ main()
|
||||
bool exists;
|
||||
|
||||
// Get the edge connecting yow.h to zag.o
|
||||
tie(e1, exists) = edge(yow, zag, g);
|
||||
boost::tie(e1, exists) = edge(yow, zag, g);
|
||||
assert(exists == true);
|
||||
assert(source(e1, g) == yow);
|
||||
assert(target(e1, g) == zag);
|
||||
|
||||
// Discover that there is no edge connecting zag.o to bar.o
|
||||
tie(e2, exists) = edge(zag, bar, g);
|
||||
boost::tie(e2, exists) = edge(zag, bar, g);
|
||||
assert(exists == false);
|
||||
|
||||
assert(num_vertices(g) == 15);
|
||||
|
||||
@@ -151,8 +151,8 @@ int main(int , char* [])
|
||||
boost::graph_traits<Graph>::vertex_iterator v, v_end;
|
||||
boost::graph_traits<Graph>::out_edge_iterator e, e_end;
|
||||
int f = 0;
|
||||
for (tie(v, v_end) = vertices(G); v != v_end; ++v)
|
||||
for (tie(e, e_end) = out_edges(*v, G); e != e_end; ++e)
|
||||
for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v)
|
||||
for (boost::tie(e, e_end) = out_edges(*v, G); e != e_end; ++e)
|
||||
flow[*e] = ++f;
|
||||
cout << endl << endl;
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ main()
|
||||
std::cout << "c flow values:" << std::endl;
|
||||
graph_traits < Graph >::vertex_iterator u_iter, u_end;
|
||||
graph_traits < Graph >::out_edge_iterator ei, e_end;
|
||||
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
|
||||
for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
|
||||
for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
|
||||
for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
|
||||
if (capacity[*ei] > 0)
|
||||
std::cout << "f " << *u_iter << " " << target(*ei, g) << " "
|
||||
<< (capacity[*ei] - residual_capacity[*ei]) << std::endl;
|
||||
|
||||
@@ -34,9 +34,9 @@ main()
|
||||
property_map < adjacency_list <>, vertex_index_t >::type
|
||||
index_map = get(vertex_index, g);
|
||||
|
||||
for (tie(i, end) = vertices(g); i != end; ++i) {
|
||||
for (boost::tie(i, end) = vertices(g); i != end; ++i) {
|
||||
std::cout << name[get(index_map, *i)];
|
||||
tie(ai, a_end) = adjacent_vertices(*i, g);
|
||||
boost::tie(ai, a_end) = adjacent_vertices(*i, g);
|
||||
if (ai == a_end)
|
||||
std::cout << " has no children";
|
||||
else
|
||||
|
||||
@@ -104,7 +104,7 @@ int main(int,char*[])
|
||||
Graph g(N);
|
||||
for (std::size_t j = 0; j < nedges; ++j) {
|
||||
graph_traits<Graph>::edge_descriptor e; bool inserted;
|
||||
tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g);
|
||||
boost::tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g);
|
||||
}
|
||||
#else
|
||||
Graph g(used_by, used_by + nedges, N);
|
||||
@@ -135,7 +135,7 @@ int main(int,char*[])
|
||||
int maxdist=0;
|
||||
// Through the order from topological sort, we are sure that every
|
||||
// time we are using here is already initialized.
|
||||
for (tie(j, j_end) = in_edges(*i, g); j != j_end; ++j)
|
||||
for (boost::tie(j, j_end) = in_edges(*i, g); j != j_end; ++j)
|
||||
maxdist=(std::max)(time[source(*j, g)], maxdist);
|
||||
time[*i]=maxdist+1;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ int main(int,char*[])
|
||||
<< "vertices with same group number can be made in parallel" << endl;
|
||||
{
|
||||
graph_traits<Graph>::vertex_iterator i, iend;
|
||||
for (tie(i,iend) = vertices(g); i != iend; ++i)
|
||||
for (boost::tie(i,iend) = vertices(g); i != iend; ++i)
|
||||
cout << "time_slot[" << name[*i] << "] = " << time[*i] << endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ main()
|
||||
name_map = get(vertex_name, G);
|
||||
char name = 'a';
|
||||
graph_traits < graph_t >::vertex_iterator v, v_end;
|
||||
for (tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
|
||||
for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
|
||||
name_map[*v] = name;
|
||||
|
||||
typedef std::pair < int, int >E;
|
||||
|
||||
@@ -61,7 +61,7 @@ int main()
|
||||
|
||||
std::cout << "unfiltered edge_range(C,D)\n";
|
||||
graph_traits<Graph>::out_edge_iterator f, l;
|
||||
for (tie(f, l) = edge_range(C, D, g); f != l; ++f)
|
||||
for (boost::tie(f, l) = edge_range(C, D, g); f != l; ++f)
|
||||
std::cout << name[source(*f, g)] << " --" << weight[*f]
|
||||
<< "-> " << name[target(*f, g)] << "\n";
|
||||
|
||||
@@ -71,7 +71,7 @@ int main()
|
||||
|
||||
std::cout << "filtered edge_range(C,D)\n";
|
||||
graph_traits<FGraph>::out_edge_iterator first, last;
|
||||
for (tie(first, last) = edge_range(C, D, fg); first != last; ++first)
|
||||
for (boost::tie(first, last) = edge_range(C, D, fg); first != last; ++first)
|
||||
std::cout << name[source(*first, fg)] << " --" << weight[*first]
|
||||
<< "-> " << name[target(*first, fg)] << "\n";
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <boost/graph/fruchterman_reingold.hpp>
|
||||
#include <boost/graph/random_layout.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/simple_point.hpp>
|
||||
#include <boost/graph/topology.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@@ -37,6 +37,9 @@ void usage()
|
||||
<< " Vertices and their positions are written to standard output with the label,\n x-position, and y-position of a vertex on each line, separated by spaces.\n";
|
||||
}
|
||||
|
||||
typedef boost::rectangle_topology<> topology_type;
|
||||
typedef topology_type::point_type point_type;
|
||||
|
||||
typedef adjacency_list<listS, vecS, undirectedS,
|
||||
property<vertex_name_t, std::string> > Graph;
|
||||
|
||||
@@ -110,7 +113,7 @@ int main(int argc, char* argv[])
|
||||
add_edge(get_vertex(source, g, names), get_vertex(target, g, names), g);
|
||||
}
|
||||
|
||||
typedef std::vector<simple_point<double> > PositionVec;
|
||||
typedef std::vector<point_type> PositionVec;
|
||||
PositionVec position_vec(num_vertices(g));
|
||||
typedef iterator_property_map<PositionVec::iterator,
|
||||
property_map<Graph, vertex_index_t>::type>
|
||||
@@ -118,15 +121,16 @@ int main(int argc, char* argv[])
|
||||
PositionMap position(position_vec.begin(), get(vertex_index, g));
|
||||
|
||||
minstd_rand gen;
|
||||
random_graph_layout(g, position, -width/2, width/2, -height/2, height/2, gen);
|
||||
topology_type topo(gen, -width/2, -height/2, width/2, height/2);
|
||||
random_graph_layout(g, position, topo);
|
||||
fruchterman_reingold_force_directed_layout
|
||||
(g, position, width, height,
|
||||
(g, position, topo,
|
||||
cooling(progress_cooling(iterations)));
|
||||
|
||||
graph_traits<Graph>::vertex_iterator vi, vi_end;
|
||||
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
|
||||
std::cout << get(vertex_name, g, *vi) << '\t'
|
||||
<< position[*vi].x << '\t' << position[*vi].y << std::endl;
|
||||
<< position[*vi][0] << '\t' << position[*vi][1] << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ void merge_vertex
|
||||
typedef boost::graph_traits<Graph> Traits;
|
||||
typename Traits::edge_descriptor e;
|
||||
typename Traits::out_edge_iterator out_i, out_end;
|
||||
for (tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) {
|
||||
for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) {
|
||||
e = *out_i;
|
||||
typename Traits::vertex_descriptor targ = target(e, g);
|
||||
add_edge(u, targ, getp(e), g);
|
||||
}
|
||||
typename Traits::in_edge_iterator in_i, in_end;
|
||||
for (tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) {
|
||||
for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) {
|
||||
e = *in_i;
|
||||
typename Traits::vertex_descriptor src = source(e, g);
|
||||
add_edge(src, u, getp(e), g);
|
||||
|
||||