mirror of
https://github.com/boostorg/graph.git
synced 2026-02-27 17:12:11 +00:00
Merged in changes from trunk for Boost.Graph and Boost.PropertyMap. Includes
r56013, r56014, r56015, r56016, r56017, r56089, r56097, r56116, r56117, r56126, r56127, r56128, r56140, r56147, r56300, r56301, r56339, r56360, r56454, r56473, r56563, r56651, r56654, r56658, r56682, r56732, r56796, r56855, r56856, r56868, r55667, r56860, r55473, r55507, r55528, r55749, r56147, r55723, r56109, r56859, and r55780. [SVN r56881]
This commit is contained in:
@@ -10,3 +10,4 @@
|
||||
for i in read_graphml read_graphviz write_graphml; do
|
||||
rst2html.py -gdt --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript --stylesheet=../../../rst.css $i.rst > $i.html
|
||||
done
|
||||
# Also see grid_graph_export_png.sh for figure conversions
|
||||
|
||||
@@ -62,9 +62,8 @@ href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructib
|
||||
An edge descriptor corresponds to a unique edge <i>(u,v)</i> in a
|
||||
graph. An edge descriptor must be <a
|
||||
href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructible</I>,
|
||||
<a
|
||||
href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>,
|
||||
and <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a>.
|
||||
<a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, and
|
||||
<a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
|
||||
|
||||
<TR>
|
||||
<TD><pre>boost::graph_traits<G>::degree_size_type</pre>
|
||||
The unsigned intergral type used for representing the number
|
||||
The unsigned integral type used for representing the number
|
||||
out-edges or incident edges of a vertex.
|
||||
</TD>
|
||||
</TR>
|
||||
@@ -108,7 +108,7 @@ directed graphs) or incident edges (for undirected graphs) of vertex
|
||||
<TT>u</TT> in graph <TT>g</TT>. The source vertex of an edge obtained
|
||||
via an out edge iterator is guaranteed (for both directed and
|
||||
undirected graphs) to be the vertex <tt>u</tt> used in the call to
|
||||
<tt>out_edges(u, g)</tt> and the target vertex must the a vertex
|
||||
<tt>out_edges(u, g)</tt> and the target vertex must be a vertex
|
||||
adjacent to <tt>u</tt>.<a href="#1">[1]</a>
|
||||
<br>
|
||||
Return type: <TT>std::pair<out_edge_iterator, out_edge_iterator></TT>
|
||||
|
||||
@@ -40,7 +40,8 @@ function address(host, user) {
|
||||
|
||||
<p>The class template <code>compressed_sparse_row_graph</code> is
|
||||
a graph class that uses the compact Compressed Sparse Row (CSR)
|
||||
format to store directed graphs. While CSR graphs have much less
|
||||
format to store directed (and bidirectional) graphs. While CSR graphs have
|
||||
much less
|
||||
overhead than many other graph formats (e.g., <a
|
||||
href="adjacency_list.html"><code>adjacency_list</code></a>), they
|
||||
do not provide any mutability: one cannot add or remove vertices
|
||||
@@ -67,14 +68,20 @@ function address(host, user) {
|
||||
providing the offset of the first edge outgoing from each
|
||||
vertex. Iteration over the out-edges for the <i>i</i><sup>th</sup>
|
||||
vertex in the graph is achieved by
|
||||
visiting <tt>edge_array[vertex_array[i]]</tt>, <tt>edge_array[vertex_array[i]+1]</tt>,
|
||||
visiting <tt>edge_array[vertex_array[i]]</tt>,
|
||||
<tt>edge_array[vertex_array[i]+1]</tt>,
|
||||
..., <tt>edge_array[vertex_array[i+1]]</tt>. This format minimizes
|
||||
memory use to <i>O(n + m)</i>, where <i>n</i> and <i>m</i> are the
|
||||
number of vertices and edges, respectively. The constants
|
||||
multiplied by <i>n</i> and <i>m</i> are based on the size of the
|
||||
integers needed to represent indices into the edge and vertex
|
||||
arrays, respectively, which can be controlled using
|
||||
the <a href="#template-parms">template parameters</a>.</p>
|
||||
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)
|
||||
has <tt>Directed</tt> = <tt>bidirectionalS</tt>.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#synopsis">Synopsis</a></li>
|
||||
@@ -155,7 +162,7 @@ public:
|
||||
edges_size_type numedges = 0,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// New sorted edge list constructors <b>(both interfaces)</b></i>
|
||||
<i>// New sorted edge list constructors <b>(both interfaces, 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,
|
||||
@@ -171,7 +178,7 @@ public:
|
||||
edges_size_type numedges = 0,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// In-place unsorted edge list constructors <b>(new interface only)</b></i>
|
||||
<i>// In-place unsorted edge list constructors <b>(new interface and 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,
|
||||
@@ -187,7 +194,7 @@ public:
|
||||
vertices_size_type numverts,
|
||||
const GraphProperty& prop = GraphProperty());
|
||||
|
||||
<i>// Miscellaneous constructors <b>(both interfaces)</b></i>
|
||||
<i>// Miscellaneous constructors <b>(both interfaces, 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,
|
||||
@@ -199,7 +206,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)</b></a></i>
|
||||
<i>// <a href="#mutators">Graph mutators <b>(both interfaces, 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);
|
||||
@@ -224,6 +231,11 @@ 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>
|
||||
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>
|
||||
std::pair<adjacency_iterator, adjacency_iterator>
|
||||
adjacent_vertices(vertex_descriptor, const compressed_sparse_row_graph&);
|
||||
@@ -243,7 +255,7 @@ vertex_descriptor <a href="#vertex">vertex</a>(vertices_size_type i, const compr
|
||||
<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>(old interface only)</b>
|
||||
<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>
|
||||
@@ -259,7 +271,7 @@ property_map<compressed_sparse_row_graph, Tag>::const_type
|
||||
<a href="#get">get</a>(PropertyTag, const compressed_sparse_row_graph& g)
|
||||
|
||||
template<typename <a href="./PropertyTag.html">PropertyTag</a>, class X>
|
||||
typename property_traits<property_map<compressed_sparse_row_graph, PropertyTag>::const_type>::value_type
|
||||
typename property_traits<property_map<compressed_sparse_row_graph, PropertyTag>::const_type>::value_type
|
||||
<a href="#get-x">get</a>(PropertyTag, const compressed_sparse_row_graph& g, X x)
|
||||
|
||||
template<typename <a href="./PropertyTag.html">PropertyTag</a>, class X, class Value>
|
||||
@@ -290,19 +302,19 @@ vertex_descriptor <a href="#add_vertices">add_vertices</a>(vertices_size_type co
|
||||
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 only)</b>
|
||||
<b>(new interface and 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 only)</b>
|
||||
<b>(new interface and 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 only)</b>
|
||||
<b>(new interface and 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 only)</b>
|
||||
<b>(new interface and 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);
|
||||
|
||||
@@ -699,9 +711,7 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
<p class="indent">
|
||||
Clears the CSR graph and builds a CSR graph in place from the
|
||||
structure of another graph. The graph type <tt>Graph</tt> must
|
||||
be a model of <a href="IncidenceGraph.html">IncidenceGraph</a>
|
||||
and have a <tt>vertex(i, g)</tt> function that retrieves the
|
||||
<i>i</i><sup>th</sup> vertex in the graph.
|
||||
be a model of <a href="IncidenceGraph.html">IncidenceGraph</a>.
|
||||
|
||||
<br><b>Parameters</b>
|
||||
|
||||
@@ -772,7 +782,7 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
|
||||
<p class="indent">
|
||||
Returns all edges from <tt>u</tt> to <tt>v</tt>. Requires time
|
||||
linear in the number of edges outgoing from <tt>u</tt>.
|
||||
logarithmic in the number of edges outgoing from <tt>u</tt>.
|
||||
<b>(This function is only provided by the old interface.)</b>
|
||||
</p>
|
||||
|
||||
@@ -789,8 +799,9 @@ void <a href="#add_edges_sorted_prop">add_edges_sorted</a>(BidirectionalIterator
|
||||
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.
|
||||
<b>(This function is only provided by the old interface.)</b>
|
||||
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.
|
||||
</p>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
BIN
doc/figs/grid_graph_indexed.png
Normal file
BIN
doc/figs/grid_graph_indexed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
1128
doc/figs/grid_graph_indexed.svg
Normal file
1128
doc/figs/grid_graph_indexed.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 49 KiB |
412
doc/figs/grid_graph_unindexed.svg
Normal file
412
doc/figs/grid_graph_unindexed.svg
Normal file
@@ -0,0 +1,412 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="350"
|
||||
height="250"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
version="1.0"
|
||||
sodipodi:docname="grid_graph_indexed.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
inkscape:export-filename="/home/hansenm/Projects/boost-trunk/libs/graph/doc/figs/grid_graph_unwrapped.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90">
|
||||
<defs
|
||||
id="defs4">
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Sstart"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow2Sstart"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3938"
|
||||
style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
|
||||
transform="scale(0.3) translate(-2.3,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Send"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow2Send"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3324"
|
||||
style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.97309,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z"
|
||||
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow2Mend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3318"
|
||||
style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.97309,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z"
|
||||
transform="scale(-0.6,-0.6)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow2Lend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3312"
|
||||
style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.97309,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z"
|
||||
transform="matrix(-1.1,0,0,-1.1,-1.1,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Send"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Send"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3306"
|
||||
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
|
||||
transform="matrix(-0.2,0,0,-0.2,-1.2,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3300"
|
||||
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3294"
|
||||
d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z"
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 526.18109 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||
id="perspective10" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="1"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2"
|
||||
inkscape:cx="79.05402"
|
||||
inkscape:cy="102.2962"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1600"
|
||||
inkscape:window-height="1150"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Vertices"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
sodipodi:insensitive="true">
|
||||
<g
|
||||
id="g3150">
|
||||
<g
|
||||
transform="translate(7.353668,21.661333)"
|
||||
id="g3204">
|
||||
<path
|
||||
d="M 63.63961,32.567215 A 16.920055,14.89975 0 1 1 29.7995,32.567215 A 16.920055,14.89975 0 1 1 63.63961,32.567215 z"
|
||||
sodipodi:ry="14.89975"
|
||||
sodipodi:rx="16.920055"
|
||||
sodipodi:cy="32.567215"
|
||||
sodipodi:cx="46.719555"
|
||||
id="path3199"
|
||||
style="opacity:0.5;fill:#808080;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc"
|
||||
transform="translate(2.8535534,2.5428932)" />
|
||||
<g
|
||||
id="g3168">
|
||||
<path
|
||||
style="fill:#00ccff;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
|
||||
d="M 63.63961,33.466965 C 63.63961,25.242303 56.059425,18.567215 46.719555,18.567215 C 37.379684,18.567215 29.7995,25.242303 29.7995,33.466965 L 63.63961,33.466965 z"
|
||||
id="path3158"
|
||||
sodipodi:nodetypes="cscc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cscc"
|
||||
id="path2385"
|
||||
d="M 63.63961,32.567215 C 63.63961,40.791877 56.059425,47.466965 46.719555,47.466965 C 37.379684,47.466965 29.7995,40.791877 29.7995,32.567215 L 63.63961,32.567215 z"
|
||||
style="fill:#00aad4;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" />
|
||||
<path
|
||||
d="M 63.63961,32.567215 A 16.920055,14.89975 0 1 1 29.7995,32.567215 A 16.920055,14.89975 0 1 1 63.63961,32.567215 z"
|
||||
sodipodi:ry="14.89975"
|
||||
sodipodi:rx="16.920055"
|
||||
sodipodi:cy="32.567215"
|
||||
sodipodi:cx="46.719555"
|
||||
id="path2383"
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:#004455;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
</g>
|
||||
<text
|
||||
id="text3160"
|
||||
y="57.511555"
|
||||
x="70.285149"
|
||||
style="font-size:14px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
|
||||
xml:space="preserve"><tspan
|
||||
y="57.511555"
|
||||
x="70.285149"
|
||||
id="tspan3162"
|
||||
sodipodi:role="line" /></text>
|
||||
<use
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(120,7.6293945e-6)"
|
||||
id="use3211"
|
||||
xlink:href="#g3204"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#g3204"
|
||||
id="use3213"
|
||||
transform="translate(240,7.6293945e-6)"
|
||||
width="300"
|
||||
height="200" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#g3204"
|
||||
id="use3217"
|
||||
transform="translate(120,70.000008)"
|
||||
width="300"
|
||||
height="200" />
|
||||
<use
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(240,70.000008)"
|
||||
id="use3219"
|
||||
xlink:href="#g3204"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(0,70.000008)"
|
||||
id="use3281"
|
||||
xlink:href="#g3204"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(120,140.00001)"
|
||||
id="use3253"
|
||||
xlink:href="#g3204"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#g3204"
|
||||
id="use3255"
|
||||
transform="translate(240,140.00001)"
|
||||
width="300"
|
||||
height="200" />
|
||||
<use
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(0,140.00001)"
|
||||
id="use3283"
|
||||
xlink:href="#g3204"
|
||||
y="0"
|
||||
x="0" />
|
||||
<path
|
||||
id="path3286"
|
||||
d="M 80.745313,54.999995 L 145.43911,54.999995"
|
||||
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Sstart);marker-end:url(#Arrow2Send);stroke-opacity:1" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="200"
|
||||
width="300"
|
||||
transform="matrix(0,-0.4518081,1,0,4.601123e-6,141.28126)"
|
||||
id="use7505"
|
||||
xlink:href="#path3286"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(118,0)"
|
||||
id="use7582"
|
||||
xlink:href="#path3286"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="fill:none"
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#path3286"
|
||||
id="use7594"
|
||||
transform="translate(118,70.000008)"
|
||||
width="300"
|
||||
height="200" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(118,140.00001)"
|
||||
id="use7606"
|
||||
xlink:href="#path3286"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="fill:none"
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#path3286"
|
||||
id="use7618"
|
||||
transform="translate(-2,140.00001)"
|
||||
width="300"
|
||||
height="200" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="200"
|
||||
width="300"
|
||||
transform="translate(-2,70.000008)"
|
||||
id="use7630"
|
||||
xlink:href="#path3286"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="250"
|
||||
width="350"
|
||||
transform="translate(120,0)"
|
||||
id="use4719"
|
||||
xlink:href="#use7505"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="fill:none"
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#use7505"
|
||||
id="use4721"
|
||||
transform="translate(240,0)"
|
||||
width="350"
|
||||
height="250" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="250"
|
||||
width="350"
|
||||
transform="translate(240,70)"
|
||||
id="use4723"
|
||||
xlink:href="#use7505"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="fill:none"
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#use7505"
|
||||
id="use4725"
|
||||
transform="translate(120,70)"
|
||||
width="350"
|
||||
height="250" />
|
||||
<use
|
||||
style="fill:none"
|
||||
height="250"
|
||||
width="350"
|
||||
transform="translate(0,70)"
|
||||
id="use4727"
|
||||
xlink:href="#use7505"
|
||||
y="0"
|
||||
x="0" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer3"
|
||||
inkscape:label="Wrapped Edges"
|
||||
sodipodi:insensitive="true">
|
||||
<g
|
||||
id="g3180">
|
||||
<path
|
||||
sodipodi:nodetypes="cssc"
|
||||
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Sstart);marker-end:url(#Arrow2Send);stroke-opacity:1"
|
||||
d="M 62.24531,29.999995 C 65.123489,26.146153 67.230816,19.819975 75.68005,17.029619 C 121.30433,1.9622158 235.21392,2.5182714 277.71508,19.982113 C 284.41084,22.733419 285.33426,25.904372 287.93911,29.499995"
|
||||
id="path4730" />
|
||||
<use
|
||||
height="250"
|
||||
width="350"
|
||||
transform="matrix(1,0,0,-1,0,252.61622)"
|
||||
id="use4733"
|
||||
xlink:href="#path4730"
|
||||
y="0"
|
||||
x="0" />
|
||||
<path
|
||||
id="path4735"
|
||||
d="M 27.76794,196.41186 C 23.91409,194.17719 17.58792,192.54103 14.79756,185.9809 C -0.26984,150.55741 0.28621,94.11602 17.75005,61.117382 C 20.50136,55.918677 23.67231,55.201718 27.26794,53.179267"
|
||||
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow2Sstart);marker-end:url(#Arrow2Send);stroke-opacity:1"
|
||||
sodipodi:nodetypes="cssc" />
|
||||
<use
|
||||
height="250"
|
||||
width="350"
|
||||
transform="matrix(-1,0,0,1,348.4957,0)"
|
||||
id="use4737"
|
||||
xlink:href="#path4735"
|
||||
y="0"
|
||||
x="0" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 13 KiB |
BIN
doc/figs/grid_graph_unwrapped.png
Normal file
BIN
doc/figs/grid_graph_unwrapped.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
doc/figs/grid_graph_wrapped.png
Normal file
BIN
doc/figs/grid_graph_wrapped.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
304
doc/grid_graph.html
Normal file
304
doc/grid_graph.html
Normal file
@@ -0,0 +1,304 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<!--
|
||||
Copyright © 2009 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)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost Graph Library: Grid Graph</title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
a {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #551A8B;
|
||||
}
|
||||
|
||||
.code
|
||||
{
|
||||
border-left-style: groove;
|
||||
border-left-width: 1px;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="../../../boost.png" alt="C++ Boost" width="277" height="86" />
|
||||
<br />
|
||||
<h1>
|
||||
<tt>grid_graph</tt>
|
||||
</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="#overview">Overview</a></li>
|
||||
<li><a href="#creating">Creating a Grid Graph</a></li>
|
||||
<li><a href="#indexing">Indexing</a></li>
|
||||
<li><a href="#member">Grid Graph Member Functions</a></li>
|
||||
</ul>
|
||||
|
||||
<h3 id="overview">Overview</h3>
|
||||
<p>
|
||||
A <tt>grid_graph</tt> represents a multi-dimensional,
|
||||
rectangular grid of vertices with user-defined dimension lengths
|
||||
and wrapping.
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<tt>grid_graph</tt> models:
|
||||
<ul>
|
||||
<li><a href="IncidenceGraph.html">Incidence Graph</a></li>
|
||||
<li><a href="AdjacencyGraph.html">Adjacency Graph</a></li>
|
||||
<li><a href="VertexListGraph.html">Vertex List Graph</a></li>
|
||||
<li><a href="EdgeListGraph.html">Edge List Graph</a></li>
|
||||
<li><a href="BidirectionalGraph.html">Bidirectional Graph</a></li>
|
||||
<li><a href="AdjacencyMatrix.html">Adjacency Matrix</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
Defined in
|
||||
<a href="../../../boost/graph/grid_graph.hpp"><tt>boost/graph/grid_graph.hpp</tt></a>
|
||||
with all functions in the <tt>boost</tt> namespace. All examples are available in a single program file in <a href="../../../libs/graph/example/grid_graph_example.cpp"><tt>libs/graph/example/grid_graph_example.cpp</tt></a>
|
||||
</p>
|
||||
|
||||
<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">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;
|
||||
</pre>
|
||||
<ul>
|
||||
<li>
|
||||
<tt>Dimensions</tt> - Number of dimensions in the graph, <b>must be greater than 2</b>
|
||||
</li>
|
||||
<li>
|
||||
<tt>VertexIndex</tt> - Type used for vertex indices, defaults to std::size_t
|
||||
</li>
|
||||
<li>
|
||||
<tt>EdgeIndex</tt> - Type used for edge indices, defaults to the same type as VertexIndex
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3 id="creating">Creating a Grid Graph</h3>
|
||||
<p>
|
||||
The constructor to <tt>grid_graph</tt> has several overloads to aid in configuring each dimension:
|
||||
</p>
|
||||
<pre class="code">
|
||||
<span class="comment">// Defines a grid_graph that does not wrap.</span>
|
||||
<span class="type">grid_graph</span><...>(<span class="name">boost</span>:<span class="type">array</span><<span class="name">VertexIndex</span>, <span class="name">Dimensions</span>> dimension_lengths);
|
||||
|
||||
<span class="comment">// Defines a grid_graph where all dimensions are either wrapped or unwrapped.</span>
|
||||
<span class="type">grid_graph</span><...>(<span class="name">boost</span>:<span class="type">array</span><<span class="name">VertexIndex</span>, <span class="name">Dimensions</span>> dimension_lengths,
|
||||
<span class="keyword">bool</span> wrap_all_dimensions);
|
||||
|
||||
<span class="comment">// Defines a grid_graph where the wrapping for each dimension is specified individually.</span>
|
||||
<span class="type">grid_graph</span><...>(<span class="name">boost</span>:<span class="type">array</span><<span class="name">VertexIndex</span>, <span class="name">Dimensions</span>> dimension_lengths,
|
||||
<span class="name">boost</span>:<span class="type">array</span><<span class="keyword">bool</span>, <span class="name">Dimensions</span>> wrap_dimension);
|
||||
</pre>
|
||||
|
||||
<h4>Example</h4>
|
||||
<pre class="code">
|
||||
<span class="comment">// Define dimension lengths, a 3x3 in this case</span>
|
||||
<span class="name">boost</span>::<span class="type">array</span><<span class="keyword">int</span>, <span class="literal">2</span>> lengths = { { <span class="literal">3</span>, <span class="literal">3</span> } };
|
||||
|
||||
<span class="comment">// Create a 3x3 two-dimensional, unwrapped grid graph (Figure 1)</span>
|
||||
<span class="type">grid_graph</span><<span class="literal">2</span>> graph(lengths);
|
||||
|
||||
<span class="comment">// Create a 3x3 two-dimensional, wrapped grid graph (Figure 2)</span>
|
||||
<span class="type">grid_graph</span><<span class="literal">2</span>> graph(lengths, <span class="keyword">true</span>);
|
||||
|
||||
</pre>
|
||||
<p style="margin-left: 10px;">
|
||||
<img src="figs/grid_graph_unwrapped.png" />
|
||||
<br />
|
||||
<em style="font-size: 0.8em"><b>Figure 1:</b> A 3x3 two-dimensional, unwrapped grid graph</em>
|
||||
</p>
|
||||
<br />
|
||||
<p style="margin-left: 10px;">
|
||||
<img src="figs/grid_graph_wrapped.png" />
|
||||
<br />
|
||||
<em style="font-size: 0.8em"><b>Figure 2:</b> A 3x3 two-dimensional, wrapped grid graph</em>
|
||||
</p>
|
||||
<br />
|
||||
|
||||
<h3 id="indexing">Indexing</h3>
|
||||
<p>
|
||||
The <tt>grid_graph</tt> supports addressing vertices and edges
|
||||
by index. The following functions allow you to convert between
|
||||
vertices, edges, and their associated indices:
|
||||
</p>
|
||||
|
||||
<pre class="code">
|
||||
<span class="keyword">typedef</span> <span class="type">grid_graph</span><...> <span class="name">Graph</span>;
|
||||
<span class="keyword">typedef</span> <span class="type">graph_traits</span><<span class="name">Graph</span>> <span class="name">Traits</span>;
|
||||
|
||||
<span class="comment">// Get the vertex associated with vertex_index</span>
|
||||
<span class="name">Traits</span>::<span class="type">vertex_descriptor</span>
|
||||
vertex(<span class="name">Traits</span>::<span class="type">vertices_size_type</span> vertex_index,
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph);
|
||||
|
||||
<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="comment">// Get the edge associated with edge_index</span>
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span>
|
||||
edge_at(<span class="name">Traits</span>::<span class="type">edges_size_type</span> edge_index,
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph);
|
||||
|
||||
<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="comment">// Get the out-edge associated with vertex and out_edge_index</span>
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span>
|
||||
out_edge_at(<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex,
|
||||
<span class="name">Traits</span>::<span class="type">degree_size_type</span> out_edge_index,
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph);
|
||||
|
||||
<span class="comment">// Get the out-edge associated with vertex and in_edge_index</span>
|
||||
<span class="name">Traits</span>::<span class="type">edge_descriptor</span>
|
||||
in_edge_at(<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex,
|
||||
<span class="name">Traits</span>::<span class="type">degree_size_type</span> in_edge_index,
|
||||
<span class="keyword">const</span> <span class="name">Graph&</span> graph);
|
||||
</pre>
|
||||
|
||||
<h4>Example</h4>
|
||||
<pre class="code">
|
||||
<span class="keyword">typedef</span> <span class="type">grid_graph</span><2> <span class="name">Graph</span>;
|
||||
<span class="keyword">typedef</span> <span class="type">graph_traits</span><<span class="name">Graph</span>> <span class="name">Traits</span>;
|
||||
|
||||
<span class="comment">// Create a 3x3, unwrapped grid_graph (Figure 3)</span>
|
||||
<span class="name">boost</span>::<span class="type">array</span><<span class="keyword">int</span>, <span class="literal">2</span>> lengths = { { <span class="literal">3</span>, <span class="literal">3</span> } };
|
||||
<span class="name">Graph</span> graph(lengths);
|
||||
|
||||
<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) {
|
||||
|
||||
<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> <<
|
||||
get(<span class="name">boost</span>::vertex_index, graph, vertex(v_index, graph)) << <span class="name">std</span>::endl;
|
||||
|
||||
}
|
||||
|
||||
<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) {
|
||||
|
||||
<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> <<
|
||||
get(<span class="name">boost</span>::edge_index, graph, edge_at(e_index, graph)) << <span class="name">std</span>::endl;
|
||||
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p style="margin-left: 10px;">
|
||||
<img src="figs/grid_graph_indexed.png" />
|
||||
<br />
|
||||
<em style="font-size: 0.8em"><b>Figure 3:</b> 3x3 unwrapped grid_graph with vertex and edge indices shown.</em>
|
||||
</p>
|
||||
<br />
|
||||
|
||||
<h3 id="member">Member Functions</h3>
|
||||
<p>
|
||||
There are several <tt>grid_graph</tt> specific member functions available:
|
||||
</p>
|
||||
<pre class="code">
|
||||
<span class="keyword">typedef</span> <span class="type">grid_graph</span><...> <span class="name">Graph</span>;
|
||||
<span class="keyword">typedef</span> <span class="type">graph_traits</span><<span class="name">Graph</span>> <span class="name">Traits</span>;
|
||||
|
||||
<span class="comment">// Returns the number of dimensions</span>
|
||||
<span class="name">std</span>::<span class="type">size_t</span> dimensions();
|
||||
|
||||
<span class="comment">// Returns the length of a dimension</span>
|
||||
<span class="name">Traits</span>::<span class="type">vertices_size_type</span> length(<span class="name">std</span>::<span class="type">size_t</span> dimension);
|
||||
|
||||
<span class="comment">// Returns true if the dimension wraps, false if not</span>
|
||||
<span class="keyword">bool</span> wrapped(<span class="name">std</span>::<span class="type">size_t</span> dimension);
|
||||
|
||||
<span class="comment">// Returns the "next" vertex in a dimension at a given distance. If the dimension
|
||||
// is unwrapped, next will stop at the last vertex in the dimension.
|
||||
</span><span class="name">Traits</span>::<span class="type">vertex_descriptor</span> next(<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex,
|
||||
<span class="name">std</span>::<span class="type">size_t</span> dimension,
|
||||
<span class="name">Traits</span>::<span class="type">vertices_size_type</span> distance = <span class="literal">1</span>);
|
||||
|
||||
<span class="comment">// Returns the "previous" vertex in a dimension at a given distance. If the
|
||||
// dimension is unwrapped, previous will stop at the beginning vertex in the dimension.
|
||||
</span><span class="name">Traits</span>::<span class="type">vertex_descriptor</span> previous(<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex,
|
||||
<span class="name">std</span>::<span class="type">size_t</span> dimension,
|
||||
<span class="name">Traits</span>::<span class="type">vertices_size_type</span> distance = <span class="literal">1</span>);
|
||||
</pre>
|
||||
|
||||
<h4>Example</h4>
|
||||
<pre class="code">
|
||||
<span class="keyword">typedef</span> <span class="type">grid_graph</span><<span class="literal">3</span>> <span class="name">Graph</span>;
|
||||
<span class="keyword">typedef</span> <span class="type">graph_traits</span><<span class="name">Graph</span>> <span class="name">Traits</span>;
|
||||
|
||||
<span class="comment">// Define a 3x5x7 grid_graph where the second dimension doesn't wrap</span>
|
||||
<span class="name">boost</span>::<span class="type">array</span><<span class="name">std</span>::<span class="type">size_t</span>, <span class="literal">3</span>> lengths = { { <span class="literal">3</span>, <span class="literal">5</span>, <span class="literal">7</span> } };
|
||||
<span class="name">boost</span>::<span class="type">array</span><<span class="keyword">bool</span>, <span class="literal">3</span>> wrapped = { { <span class="keyword">true</span>, <span class="keyword">false</span>, <span class="keyword">true</span> } };
|
||||
<span class="name">Graph</span> graph(lengths, wrapped);
|
||||
|
||||
<span class="comment">// Print number of dimensions</span>
|
||||
<span class="name">std</span>::cout << graph.dimensions() << <span class="name">std</span>::endl; <span class="comment">// prints "3"</span>
|
||||
|
||||
<span class="comment">// Print dimension lengths (same order as in the lengths array)</span>
|
||||
<span class="name">std</span>::cout << graph.length(<span class="literal">0</span>) << <span class="literal">"x"</span> << graph.length(<span class="literal">1</span>) <<
|
||||
<span class="literal">"x"</span> << graph.length(<span class="literal">2</span>) << <span class="name">std</span>::endl; <span class="comment">// prints "3x5x7"</span>
|
||||
|
||||
<span class="comment">// Print dimension wrapping (W = wrapped, U = unwrapped)</span>
|
||||
<span class="name">std</span>::cout << graph.wrapped(<span class="literal">0</span>) ? <span class="literal">"W"</span> : <span class="literal">"U"</span> << <span class="literal">", "</span> <<
|
||||
graph.wrapped(<span class="literal">1</span>) ? <span class="literal">"W"</span> : <span class="literal">"U"</span> << <span class="literal">", "</span> <<
|
||||
graph.wrapped(<span class="literal">2</span>) ? <span class="literal">"W"</span> : <span class="literal">"U"</span> << <span class="name">std</span>::endl; <span class="comment">// prints "W, U, W"</span>
|
||||
|
||||
<span class="comment">// Define a simple function to print vertices</span>
|
||||
<span class="keyword">void</span> print_vertex(<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> vertex_to_print) {
|
||||
<span class="name">std</span>::cout << <span class="literal">"("</span> << vertex_to_print[<span class="literal">0</span>] << <span class="literal">", "</span> << vertex_to_print[<span class="literal">1</span>] <<
|
||||
<span class="literal">", "</span> << vertex_to_print[<span class="literal">2</span>] << <span class="literal">")"</span> << <span class="name">std</span>::endl;
|
||||
}
|
||||
|
||||
<span class="comment">// Start with the first vertex in the graph</span>
|
||||
<span class="name">Traits</span>::<span class="type">vertex_descriptor</span> first_vertex = vertex(<span class="literal">0</span>, graph);
|
||||
print_vertex(first_vertex); <span class="comment">// prints "(0, 0, 0)"</span>
|
||||
|
||||
<span class="comment">// Print the next vertex in dimension 0</span>
|
||||
print_vertex(graph.next(first_vertex, <span class="literal">0</span>)); <span class="comment">// prints "(1, 0, 0)"</span>
|
||||
|
||||
<span class="comment">// Print the next vertex in dimension 1</span>
|
||||
print_vertex(graph.next(first_vertex, <span class="literal">1</span>)); <span class="comment">// prints "(0, 1, 0)"</span>
|
||||
|
||||
<span class="comment">// Print the 5th next vertex in dimension 2</span>
|
||||
print_vertex(graph.next(first_vertex, <span class="literal">2</span>, <span class="literal">5</span>)); <span class="comment">// prints "(0, 0, 5)"</span>
|
||||
|
||||
<span class="comment">// Print the previous vertex in dimension 0 (wraps)</span>
|
||||
print_vertex(graph.previous(first_vertex, <span class="literal">0</span>)); <span class="comment">// prints "(2, 0, 0)"</span>
|
||||
|
||||
<span class="comment">// Print the previous vertex in dimension 1 (doesn't wrap, so it's the same)</span>
|
||||
print_vertex(graph.previous(first_vertex, <span class="literal">1</span>)); <span class="comment">// prints "(0, 0, 0)"</span>
|
||||
|
||||
<span class="comment">// Print the 20th previous vertex in dimension 2 (wraps around twice)</span>
|
||||
print_vertex(graph.previous(first_vertex, <span class="literal">2</span>, <span class="literal">20</span>)); <span class="comment">// prints "(0, 0, 1)"</span>
|
||||
</pre>
|
||||
|
||||
<hr />
|
||||
Copyright © 2009 Trustees of Indiana University
|
||||
|
||||
</body>
|
||||
</html>
|
||||
19
doc/grid_graph_export_svg.sh
Executable file
19
doc/grid_graph_export_svg.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
#=======================================================================
|
||||
# Copyright 2009 Trustees of Indiana University.
|
||||
# Authors: Michael Hansen, Andrew Lumsdaine
|
||||
#
|
||||
# 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)
|
||||
#=======================================================================
|
||||
|
||||
# Unindexed, unwrapped
|
||||
inkscape --export-png grid_graph_unwrapped.png --export-id g3150 --export-id-only grid_graph_unindexed.svg
|
||||
|
||||
# Unindexed, wrapped
|
||||
inkscape --export-png grid_graph_wrapped.png grid_graph_unindexed.svg
|
||||
|
||||
# Indexed, unwrapped
|
||||
inkscape --export-png grid_graph_indexed.png grid_graph_indexed.svg
|
||||
@@ -8,6 +8,18 @@
|
||||
-->
|
||||
<Head>
|
||||
<Title>Boost Graph Library: Incremental Connected Components</Title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.code
|
||||
{
|
||||
border-left-style: groove;
|
||||
border-left-width: 1px;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
-->
|
||||
</style>
|
||||
|
||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
||||
ALINK="#ff0000">
|
||||
<IMG SRC="../../../boost.png"
|
||||
@@ -88,58 +100,77 @@ example can be found in <a
|
||||
href="../example/incremental_components.cpp"><TT>examples/incremental_components.cpp</TT></a>.
|
||||
|
||||
<P>
|
||||
<PRE>
|
||||
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::vertices_size_type size_type;
|
||||
<PRE class="code">
|
||||
using namespace boost;
|
||||
|
||||
const int N = 6;
|
||||
Graph G(N);
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::vertices_size_type VertexIndex;
|
||||
|
||||
std::vector<size_type> rank(num_vertices(G));
|
||||
std::vector<Vertex> parent(num_vertices(G));
|
||||
typedef size_type* Rank;
|
||||
typedef Vertex* Parent;
|
||||
disjoint_sets<Rank, Parent> ds(&rank[0], &parent[0]);
|
||||
const int VERTEX_COUNT = 6;
|
||||
Graph graph(VERTEX_COUNT);
|
||||
|
||||
initialize_incremental_components(G, ds);
|
||||
incremental_components(G, ds);
|
||||
std::vector<VertexIndex> rank(num_vertices(graph));
|
||||
std::vector<Vertex> parent(num_vertices(graph));
|
||||
|
||||
graph_traits<Graph>::edge_descriptor e;
|
||||
bool flag;
|
||||
boost::tie(e,flag) = add_edge(0, 1, G);
|
||||
ds.union_set(0,1);
|
||||
typedef VertexIndex* Rank;
|
||||
typedef Vertex* Parent;
|
||||
|
||||
boost::tie(e,flag) = add_edge(1, 4, G);
|
||||
ds.union_set(1,4);
|
||||
disjoint_sets<Rank, Parent> ds(&rank[0], &parent[0]);
|
||||
|
||||
boost::tie(e,flag) = add_edge(4, 0, G);
|
||||
ds.union_set(4,0);
|
||||
initialize_incremental_components(graph, ds);
|
||||
incremental_components(graph, ds);
|
||||
|
||||
boost::tie(e,flag) = add_edge(2, 5, G);
|
||||
ds.union_set(2,5);
|
||||
graph_traits<Graph>::edge_descriptor edge;
|
||||
bool flag;
|
||||
|
||||
cout << "An undirected graph:" << endl;
|
||||
print_graph(G, get(vertex_index, G));
|
||||
cout << endl;
|
||||
boost::tie(edge, flag) = add_edge(0, 1, graph);
|
||||
ds.union_set(0,1);
|
||||
|
||||
graph_traits<Graph>::vertex_iterator i,end;
|
||||
for (boost::tie(i, end) = vertices(G); i != end; ++i)
|
||||
cout << "representative[" << *i << "] = " <<
|
||||
ds.find_set(*i) << endl;;
|
||||
cout << endl;
|
||||
boost::tie(edge, flag) = add_edge(1, 4, graph);
|
||||
ds.union_set(1,4);
|
||||
|
||||
typedef component_index<unsigned int> Components;
|
||||
Components components(&parent[0], &parent[0] + parent.size());
|
||||
boost::tie(edge, flag) = add_edge(4, 0, graph);
|
||||
ds.union_set(4,0);
|
||||
|
||||
for (Components::size_type c = 0; c < components.size(); ++c) {
|
||||
cout << "component " << c << " contains: ";
|
||||
Components::value_type::iterator
|
||||
j = components[c].begin(),
|
||||
jend = components[c].end();
|
||||
for ( ; j != jend; ++j)
|
||||
cout << *j << " ";
|
||||
cout << endl;
|
||||
boost::tie(edge, flag) = add_edge(2, 5, graph);
|
||||
ds.union_set(2,5);
|
||||
|
||||
std::cout << "An undirected graph:" << std::endl;
|
||||
print_graph(graph, get(boost::vertex_index, graph));
|
||||
std::cout << std::endl;
|
||||
|
||||
BOOST_FOREACH(Vertex current_vertex, vertices(graph)) {
|
||||
std::cout << "representative[" << current_vertex << "] = " <<
|
||||
ds.find_set(current_vertex) << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
typedef component_index<VertexIndex> Components;
|
||||
|
||||
// NOTE: Because we're using vecS for the graph type, we're
|
||||
// effectively using identity_property_map for a vertex index map.
|
||||
// If we were to use listS instead, the index map would need to be
|
||||
// explicity passed to the component_index constructor.
|
||||
Components components(parent.begin(), parent.end());
|
||||
|
||||
// Iterate through the component indices
|
||||
BOOST_FOREACH(VertexIndex current_index, components) {
|
||||
std::cout << "component " << current_index << " contains: ";
|
||||
|
||||
// Iterate through the child vertex indices for [current_index]
|
||||
BOOST_FOREACH(VertexIndex child_index,
|
||||
components[current_index]) {
|
||||
std::cout << child_index << " ";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
</PRE>
|
||||
|
||||
@@ -298,19 +329,14 @@ component_index<Index>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<b>The <tt>component_index</tt> functionality is broken in Boost 1.40 and
|
||||
earlier versions (see <a
|
||||
href="https://svn.boost.org/trac/boost/ticket/3250">bug 3250</a> for more
|
||||
information).</b>
|
||||
|
||||
<p>
|
||||
|
||||
The is a class that provides an STL container-like view for the
|
||||
components of the graph. Each component is a container-like object,
|
||||
and the <TT>component_index</TT> object provides access to the
|
||||
component objects via <TT>operator[]</TT>. A <TT>component_index</TT>
|
||||
object is initialized with the parents property in the disjoint-sets
|
||||
calculated from the <TT>incremental_components()</TT> function.
|
||||
The <tt>component_index</tt> class provides an STL
|
||||
container-like view for the components of the graph. Each component is
|
||||
a container-like object, and access is provided via
|
||||
the <TT>operator[]</TT>. A <TT>component_index</TT> object is
|
||||
initialized with the parents property in the disjoint-sets calculated
|
||||
from the <TT>incremental_components()</TT> function. Optionally, a
|
||||
vertex -> index property map is passed in
|
||||
(<tt>identity_property_map</tt> is used by default).
|
||||
|
||||
<P>
|
||||
|
||||
@@ -332,82 +358,48 @@ calculated from the <TT>incremental_components()</TT> function.
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type</tt></td>
|
||||
<td>The type used for representing the number of components.</td>
|
||||
<td><tt>value_type/size_type</tt></td>
|
||||
<td>
|
||||
The type for a component index (same as <tt>Index</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type size()</tt></td>
|
||||
<td>
|
||||
Returns the number of components in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type</tt></td>
|
||||
<td><tt>iterator/const_iterator</tt></td>
|
||||
<td>
|
||||
The type for a component object. The component type has the following members.
|
||||
Iterators used to traverse the available component indices [0 to <tt>size()</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>iterator begin() const</tt></td>
|
||||
<td>
|
||||
Returns an iterator at the start of the component indices (0).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>iterator end() const</tt></td>
|
||||
<td>
|
||||
Returns an iterator past the end of the component indices (<tt>size()</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::value_type</tt></td>
|
||||
<td><tt>std::pair<component_iterator, component_iterator> operator[size_type index] const</tt></td>
|
||||
<td>
|
||||
The value type of a component object is a vertex ID.
|
||||
Returns a pair of iterators for the component at <tt>index</tt> where <tt>index</tt> is in [0, <tt>size()</tt>).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator</tt></td>
|
||||
<td>
|
||||
This iterator can be used to traverse all of the vertices
|
||||
in the component. This iterator dereferences to give a vertex ID.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::const_iterator</tt></td>
|
||||
<td>
|
||||
The const iterator.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator value_type::begin() const</tt></td>
|
||||
<td>
|
||||
Return an iterator pointing to the first vertex in the component.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type::iterator value_type::end() const</tt></td>
|
||||
<td>
|
||||
Return an iterator pointing past the end of the last vertex in the
|
||||
component.
|
||||
</td>
|
||||
<tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<tt>
|
||||
template <class ComponentsContainer>
|
||||
component_index(const ComponentsContainer& c)
|
||||
</tt>
|
||||
</td>
|
||||
<td>
|
||||
Construct the <TT>component_index</TT> using the information
|
||||
from the components container <TT>c</TT> which was the result
|
||||
of executing <TT>connected_components_on_edgelist</TT>.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>value_type operator[](size_type i)</tt></td>
|
||||
<td>
|
||||
Returns the <TT>i</TT>th component in the graph.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><tt>size_type component_index::size()</tt></td>
|
||||
<td>
|
||||
Returns the number of components in the graph.
|
||||
</td>
|
||||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
@@ -210,8 +210,7 @@ choice for the BGL.
|
||||
</pre>
|
||||
The output is:
|
||||
<pre>
|
||||
edges(g) = (0,1) (0,2) (0,3) (0,4) (2,0) (2,4) (3,0)
|
||||
(3,1) (3,4) (4,0) (4,1)
|
||||
edges(g) = (0,1) (0,3) (2,0) (3,2) (2,4) (1,3) (3,4)
|
||||
</pre>
|
||||
<p>
|
||||
<h2>The Adjacency Structure</h2>
|
||||
@@ -558,14 +557,14 @@ equipped to handle the use of multiple visitors in the same algorithm
|
||||
using std::vector;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
vector<Vertex> p(num_vertices(G)); //the predecessor array
|
||||
vector<Vertex> p(num_vertices(G), graph_traits<G>::null_vertex()); //the predecessor array
|
||||
dijkstra_shortest_paths(G, s, distance_map(&d[0]).
|
||||
visitor(make_predecessor_recorder(&p[0])));
|
||||
|
||||
cout << "parents in the tree of shortest paths:" << endl;
|
||||
for(vi = vertices(G).first; vi != vertices(G).second; ++vi) {
|
||||
cout << "parent(" << *vi;
|
||||
if (p[*vi] == Vertex())
|
||||
if (p[*vi] == graph_traits<G>::null_vertex())
|
||||
cout << ") = no parent" << endl;
|
||||
else
|
||||
cout << ") = " << p[*vi] << endl;
|
||||
|
||||
@@ -110,6 +110,9 @@
|
||||
<LI><A href="../../../boost/graph/matrix_as_graph.hpp">Matrix as Graph</A><a href="#*">*</a>
|
||||
<LI><A href="../../../boost/graph/leda_graph.hpp">Leda Graph </A><a href="#*">*</a>
|
||||
<LI><A href="./stanford_graph.html">Stanford GraphBase</A>
|
||||
<LI>Implicit Graphs
|
||||
<OL>
|
||||
<LI><A href="./grid_graph.html">Multi-dimensional grid graph</A>
|
||||
</OL>
|
||||
<LI>Iterator Adaptors
|
||||
<OL>
|
||||
|
||||
Reference in New Issue
Block a user