2
0
mirror of https://github.com/boostorg/graph.git synced 2026-02-27 17:12:11 +00:00

Merged Boost.Graph, Boost.Graph.Parallel, and Boost.PropertyMap changes from trunk

[SVN r84299]
This commit is contained in:
Jeremiah Willcock
2013-05-16 15:38:05 +00:00
parent 22b521ecf4
commit 67f7bcfa96
31 changed files with 1376 additions and 404 deletions

View File

@@ -15,7 +15,7 @@
<BR Clear>
<H1><A NAME="sec:johnson">
<H1><A NAME="sec:johnson"></A>
<TT>johnson_all_pairs_shortest_paths</TT>
</H1>
@@ -75,10 +75,12 @@ and <a href="IncidenceGraph.html">Incidence Graph</a>.
OUT: <tt>DistanceMatrix&amp; D</tt>
<blockquote>
The length of the shortest path between each pair of vertices
<i>u,v</i> in the graph is stored in <tt>D[u][v]</tt>. The set of
types {<tt>DistanceMatrix, vertices_size_type, D</tt>} must be a model
<i>u,v</i> in the graph is stored in <tt>D[u][v]</tt>. The tuple of
types (<tt>DistanceMatrix, vertices_size_type, D</tt>) must be a model
of <a href="BasicMatrix.html">BasicMatrix</a> where <tt>D</tt> is the
value type of the <tt>DistanceMap</tt>.
value type of the <tt>DistanceMap</tt>. There must be implicit conversions
between the value type of the distance matrix and the value type of the weight
map.
</blockquote>
@@ -86,12 +88,11 @@ value type of the <tt>DistanceMap</tt>.
IN: <tt>weight_map(WeightMap w_map)</tt>
<blockquote>
The weight or ``length'' of each edge in the graph.
The weight or "length" of each edge in the graph.
The type <tt>WeightMap</tt> must be a model of
<a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map</a>. The edge descriptor type of
the graph needs to be usable as the key type for the weight
map. The value type for the map must be
<i>Addable</i> with the value type of the distance map.<br>
map. The value type of the weight map must support a subtraction operation.<br>
<b>Default:</b> <tt>get(edge_weight, g)</tt>
</blockquote>
@@ -112,7 +113,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>
</blockquote>
@@ -128,7 +129,8 @@ IN: <tt>distance_compare(CompareFunction cmp)</tt>
This function is use to compare distances to determine
which vertex is closer to the source vertex.
The <tt>CompareFunction</tt> type must be a model of
\stlconcept{BinaryPredicate} and have argument types that
<a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">Binary Predicate</a>
and have argument types that
match the value type of the <tt>WeightMap</tt> property map.<br>
<b>Default:</b> <tt>std::less&lt;DT&gt;</tt> with
<tt>DT=typename&nbsp;property_traits&lt;WeightMap&gt;::value_type</tt>
@@ -139,11 +141,8 @@ IN: <tt>distance_combine(CombineFunction cmb)</tt>
This function is used to combine distances to compute the distance
of a path. The <tt>CombineFunction</tt> type must be a model of <a
href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary
Function</a>. The first argument type of the binary function must
match the value type of the <tt>DistanceMap</tt> property map and
the second argument type must match the value type of the
<tt>WeightMap</tt> property map. The result type must be the same
type as the distance value type.<br>
Function</a>. Both argument types and the return type of the binary function
must match the value type of the <tt>WeightMap</tt> property map. This operation is required to act as the sum operation for the weight type; in particular, it must be the inverse of the binary <tt>-</tt> operator on that type.<br>
<b>Default:</b> <tt>std::plus&lt;DT&gt;</tt> with
<tt>DT=typename&nbsp;property_traits&lt;WeightMap&gt;::value_type</tt>
</blockquote>
@@ -152,7 +151,7 @@ IN: <tt>distance_inf(DT inf)</tt>
<blockquote>
This value is used to initialize the distance for each
vertex before the start of the algorithm.
The type <tt>DT</tt> must be the value type of the <tt>WeigthMap</tt>.<br>
The type <tt>DT</tt> must be the value type of the <tt>WeightMap</tt>.<br>
<b>Default:</b> <tt>std::numeric_limits::max()</tt>
</blockquote>
@@ -160,7 +159,7 @@ IN: <tt>distance_zero(DT zero)</tt>
<blockquote>
This value is used to initialize the distance for the source
vertex before the start of the algorithm. The type <tt>DT</tt>
must be the value type of the <tt>WeigthMap</tt>.<br>
must be the value type of the <tt>WeightMap</tt>.<br>
<b>Default:</b> <tt>0</tt>
</blockquote>

View File

@@ -0,0 +1,284 @@
<html>
<!--
Copyright (c) Fernando Vilas 2013
Some content from the Stoer-Wagner Min Cut documentation,
Copyright (c) Daniel Trebbien 2010
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: Maximum Adjacency Search</Title>
<body>
<img src="../../../boost.png" alt="C++ Boost" width="277" height="86">
<h1><a name="sec:maximum-adjacency-search"></a>
<tt>maximum_adjacency_search</tt>
</h1>
<p>
<pre>
<em>// named parameter versions</em>
template &lt;class Graph, class class P, class T, class R&gt;
void
maximum_adjacency_search(const Graph&amp; g,
const bgl_named_params&lt;P, T, R&gt;&amp; params);
<i>// non-named parameter versions</i>
template &lt;class Graph, class WeightMap, class MASVisitor&gt;
void
maximum_adjacency_search(const Graph&amp; g, WeightMap weights, MASVisitor vis,
const typename graph_traits&lt;Graph&gt;::vertex_descriptor start);
</pre>
<p>
The <tt>maximum_adjacency_search()</tt> function performs a traversal
of the vertices in an undirected graph. The next vertex visited is the
vertex that has the most visited neighbors at any time. In the case of
an unweighted, undirected graph, the number of visited neighbors of the
very last vertex visited in the graph is also the number of edge-disjoint
paths between that vertex and the next-to-last vertex visited. These can be
retrieved from a visitor, an example of which is in the test harness
mas_test.cpp.
</p>
<p>
The <tt>maximum_adjacency_search()</tt> function invokes user-defined
actions at certain event-points within the algorithm. This provides a
mechanism for adapting the generic MAS algorithm to the many situations
in which it can be used. In the pseudo-code below, the event points
for MAS are the labels on the right. The user-defined actions must be
provided in the form of a visitor object, that is, an object whose type
meets the requirements for a MAS Visitor.
</p>
<table>
<tr>
<td valign="top">
<pre>
MAS(<i>G</i>)
<b>for</b> each vertex <i>u in V</i>
<i>reach_count[u] := 0</i>
<b>end for</b>
// for the starting vertex s
<i>reach_count[s] := 1</i>
<b>for</b> each unvisited vertex <i>u in V</i>
<b>call</b> MAS-VISIT(<i>G</i>, <i>u</i>)
remove u from the list on unvisited vertices
<b>for</b> each out edge from <i>u</i> to <i>t</i>
<b>if</b> <i>t</i> has not yet been visited
increment <i>reach_count[t]</i>
<b>end if</b>
<b>end for</b> each out edge
<b>call</b> MAS-VISIT(<i>G</i>, <i>u</i>)
<b>end for</b> each unvisited vertex
<pre>
</td>
<td valign="top">
<pre>
-
-
initialize vertex <i>u</i>
-
-
-
-
examine vertex <i>u</i>
-
examine edge <i>(u,t)</i>
-
-
-
-
finish vertex <i>u</i>
-
</pre>
</td>
</tr>
</table>
<h3>Where Defined</h3>
<p>
<a href="../../../boost/graph/maximum_adjacency_search.hpp"><tt>boost/graph/maximum_adjacency_search.hpp</tt></a></p>
<h3>Parameters</h3>
IN: <tt>const UndirectedGraph&amp; g</tt></p>
<blockquote>
A connected, directed graph. The graph type must
be a model of <a href="./IncidenceGraph.html">Incidence Graph</a>
and <a href="./VertexListGraph.html">Vertex List Graph</a>.<br>
</blockquote>
<h3>Named Parameters</h3>
<p>IN: <tt>WeightMap weights</tt></p>
<blockquote>
The weight or length of each edge in the graph. The
<tt>WeightMap</tt> type must be a model of
<a href="../../property_map/doc/ReadablePropertyMap.html">Readable
Property Map</a> and its value type must be <a class="external"
href="http://www.sgi.com/tech/stl/LessThanComparable.html">
Less Than Comparable</a> and summable. The key type of this map
needs to be the graph's edge descriptor type.
<b>Default:</b> <tt>get(edge_weight, g)</tt><br>
</blockquote>
IN: <tt>visitor(MASVisitor vis)</tt></p>
<blockquote>
A visitor object that is invoked inside the algorithm at the
event-points specified by the MAS Visitor concept. The visitor
object is passed by value <a href="#1">[1]</a>. <br>
<b>Default:</b> <tt>mas_visitor&lt;null_visitor&gt;</tt><br>
</blockquote>
IN: <tt>root_vertex(typename
graph_traits&lt;VertexListGraph&gt;::vertex_descriptor start)</tt></p>
<blockquote>
This specifies the vertex that the depth-first search should
originate from. The type is the type of a vertex descriptor for the
given graph.<br>
<b>Default:</b> <tt>*vertices(g).first</tt><br>
</blockquote>
<h4>Expert Parameters</h4>
<p>IN: <tt>vertex_index_map(VertexIndexMap vertexIndices)</tt> </p>
<blockquote>
This maps each vertex to an integer in the range
[0, <tt>num_vertices(g)</tt>). This is only necessary if the default is
used for the assignment, index-in-heap, or distance maps.
<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
key type must be the graph's vertex descriptor type.<br>
<b>Default:</b> <tt>get(boost::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>adjacency_list</tt> with <tt>VertexList=listS</tt> does
not have an internal <tt>vertex_index</tt> property.
</blockquote>
<p>UTIL: <tt>vertex_assignment_map(AssignmentMap assignments)</tt></p>
<blockquote>
<tt>AssignmentMap</tt> must be a model of <a
href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write Property
Map</a>. The key and value types must be the graph's vertex descriptor
type.<br>
<b>Default:</b> A <tt>boost::iterator_property_map</tt> using a
<tt>std::vector</tt> of <tt>num_vertices(g)</tt> vertex descriptors and
<tt>vertexIndices</tt> for the index map.
</blockquote>
<p>UTIL: <tt>max_priority_queue(MaxPriorityQueue&amp; pq)</tt></p>
<blockquote>
<tt>MaxPriorityQueue</tt> must be a model of <a
href="./KeyedUpdatableQueue.html">Keyed Updatable Queue</a> and a
max-<a href="./UpdatableQueue.html#concept%3AUpdatablePriorityQueue">
Updatable Priority Queue</a>. The value type must be the graph's vertex
descriptor and the key type must be the weight type.
<b>Default:</b> A <tt>boost::d_ary_heap_indirect</tt> using a default
index-in-heap and distance map.
</blockquote>
<p>UTIL: <tt>index_in_heap_map(IndexInHeapMap indicesInHeap)</tt></p>
<blockquote>
This parameter only has an effect when the default max-priority queue is used.<br>
<tt>IndexInHeapMap</tt> must be a model of <a
href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write Property
Map</a>. The key type must be the graph's vertex descriptor type. The
value type must be a size type
(<tt>typename&nbsp;std::vector&lt;vertex_descriptor&gt;::size_type</tt>).<br>
<b>Default:</b> A <tt>boost::iterator_property_map</tt> using a
<tt>std::vector</tt> of <tt>num_vertices(g)</tt> size type objects and
<tt>vertexIndices</tt> for the index map.
</blockquote>
<p>UTIL: <tt>distance_map(DistanceMap wAs)</tt></p>
<blockquote>
This parameter only has an effect when the default max-priority queue is used.<br>
<tt>DistanceMap</tt> must be a model of <a
href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write Property
Map</a>. The key type must be the graph's vertex descriptor type. The
value type must be the weight type
(<tt>typename&nbsp;boost::property_traits&lt;WeightMap&gt;::value_type</tt>).
<br>
<b>Default:</b> A <tt>boost::iterator_property_map</tt> using a
<tt>std::vector</tt> of <tt>num_vertices(g)</tt> weight type objects
and <tt>vertexIndices</tt> for the index map.
</blockquote>
<h3>Returns</h3>
<p>void</p>
<h3>Throws</h3>
<p><tt>bad_graph</tt>
<blockquote>
If <tt>num_vertices(g)</tt> is less than 2
</blockquote></p>
<p><tt>std::invalid_argument</tt>
<blockquote>
If a max-priority queue is given as an argument and it is not empty
</blockquote>.
<h3><a name="SECTION001340300000000000000">
Complexity</a>
</h3>
<p>
The time complexity is <i>O(E + V)</i>.
</p>
<h3>References</h3>
<ul>
<li>David Matula (1993). <q><a href="http://dl.acm.org/citation.cfm?id=313872&dl=ACM&coll=DL&CFID=85991501&CFTOKEN=44461131">A linear time 2 + epsilon approximation algorightm for edge connectivity</a></q>
</li>
<li>Cai, Weiqing and Matula, David W.
Partitioning by maximum adjacency search of graphs.
Partitioning Data Sets: Dimacs Workshop, April 19-21, 1993.
Vol 19. Page 55. 1995. Amer Mathematical Society</li>
}
</ul>
<h3>Visitor Event Points</h3>
<ul>
<li><b><tt>vis.initialize_vertex(s, g)</tt></b> is invoked on every
vertex of the graph before the start of the graph search.</li>
<li><b><tt>vis.start_vertex(s, g)</tt></b> is invoked on the source
vertex once before processing its out edges.</li>
<li><b><tt>vis.examine_edge(e, g)</tt></b> is invoked on every out-edge
of each vertex after it is started.</li>
<li><b><tt>vis.finish_vertex(u, g)</tt></b> is invoked on a vertex after
all of its out edges have been examined and the reach counts of the
unvisited targets have been updated.</li>
</ul>
<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.</p>
<hr>
<table>
<tr valign=top>
<td nowrap>Copyright &copy; 2012</td><td>
Fernando Vilas
</td></tr></table>
</body>
</html>

View File

@@ -466,7 +466,7 @@ A <a href="http://www.sgi.com/tech/stl/functors.html">function object</a> or fun
</blockquote>
IN: <tt>Label_Allocator la</tt>
<blockquote>
An object of type <tt>Label_Allocator</tt> specifying a strategy for the memory management of the labels. It must offer the same interface as <tt>std::allocator<lt;r_c_shortest_paths_label&lt;Graph, Resource_Container&gt; &gt;</tt>. There is a default type <tt>default_r_c_shortest_paths_allocator</tt> for this parameter using the STL standard allocator. If the third or the fourth overload of the function is used, an object of this type is used as <tt>Label_Allocator</tt> parameter. If the first or the second overload is used, one must specify both a <tt>Label_Allocator</tt> and a <tt>Visitor</tt> parameter. If one wants to develop a user-defined type only for <tt>Visitor</tt>, one can use <tt>default_r_c_shortest_paths_allocator</tt> as <tt>Label_Allocator</tt> parameter. If one wants to use a specialized allocator, one can specify an arbitrary type as template parameter for the value type to the allocator; it is rebound to the correct type.
An object of type <tt>Label_Allocator</tt> specifying a strategy for the memory management of the labels. It must offer the same interface as <tt>std::allocator&lt;r_c_shortest_paths_label&lt;Graph, Resource_Container&gt; &gt;</tt>. There is a default type <tt>default_r_c_shortest_paths_allocator</tt> for this parameter using the STL standard allocator. If the third or the fourth overload of the function is used, an object of this type is used as <tt>Label_Allocator</tt> parameter. If the first or the second overload is used, one must specify both a <tt>Label_Allocator</tt> and a <tt>Visitor</tt> parameter. If one wants to develop a user-defined type only for <tt>Visitor</tt>, one can use <tt>default_r_c_shortest_paths_allocator</tt> as <tt>Label_Allocator</tt> parameter. If one wants to use a specialized allocator, one can specify an arbitrary type as template parameter for the value type to the allocator; it is rebound to the correct type.
</blockquote>
IN: <tt>Visitor vis</tt>
<blockquote>

View File

@@ -287,6 +287,7 @@
<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>
<LI><A href="maximum_adjacency_search.html"><tt>maximum_adjacency_search</tt></A>
</ol>
</li>

View File

@@ -87,13 +87,16 @@ bool vf2_subgraph_iso(const GraphSmall&amp; graph_small,
graph that preserves the edge structure of the graphs. <em>M</em> is said to be a
graph-subgraph isomorphism if and only if <em>M</em> is an isomorphism between
<em>G<sub>1</sub></em> and a subgraph of <em>G<sub>2</sub></em>.
An induced subgraph of a graph <em>G = (V, E)</em> is a normal subgraph
<em>G' = (V', E')</em> with the extra condition that all edges of <em>G</em>
which have both endpoints in <em>V'</em> are in <em>E'</em>.
</p>
<p>
This function finds all graph-subgraph isomorphism mappings between
This function finds all induced subgraph isomorphisms between
graphs <tt>graph_small</tt> and <tt>graph_large</tt> and outputs them to
<tt>user_callback</tt>. It continues until <tt>user_callback</tt>
returns true or the search space has been fully explored. <tt>vf2_subgraph_iso</tt>
returns false or the search space has been fully explored. <tt>vf2_subgraph_iso</tt>
returns true if a graph-subgraph isomorphism exists and false otherwise.
<tt>EdgeEquivalencePredicate</tt> and
<tt>VertexEquivalencePredicate</tt> predicates are used to test whether
@@ -182,8 +185,8 @@ bool operator()(CorrespondenceMap1To2 f, CorrespondenceMap2To1 g) const
and <tt>CorresondenceMap2To1</tt> types are models
of <a href="../../property_map/doc/ReadablePropertyMap.html">Readable
Property Map</a> and map equivalent vertices across the two
graphs given to <tt>vf2_subgraph_iso</tt> (or <tt>vf2_graph_iso</tt>). For
instance, if <tt>v</tt> is
graphs given to <tt>vf2_subgraph_iso</tt> (or <tt>vf2_graph_iso</tt> or
<tt>vf2_subgraph_mono</tt>). For instance, if <tt>v</tt> is
from <tt>graph_small</tt>, <tt>w</tt> is from <tt>graph_large</tt>,
and the vertices can be considered equivalent,
then <tt>get(f, v)</tt> will be <tt>w</tt> and <tt>get(g, w)</tt>
@@ -279,13 +282,22 @@ bool operator()(CorrespondenceMap1To2 f, CorrespondenceMap2To1 g) const
function
</p>
<p><tt>vf2_graph_iso(...)</tt></p>
<p><tt>vf2_subgraph_mono(...)</tt></p>
<p>
for isomorphism testing take the same parameters as the corresponding
functions <tt>vf2_subgraph_iso</tt> for subgraph isomorphism testing.
The algorithm finds all isomorphism mappings between graphs
<tt>graph1</tt> and <tt>graph2</tt> and outputs them to
<tt>user_callback</tt>. It continues until <tt>user_callback</tt>
returns true or the search space has been fully explored. As before,
for isomorphism and (not necessarily induced) subgraph isomorphism testing,
taking the same parameters as the corresponding functions <tt>vf2_subgraph_iso</tt>
for induced subgraph isomorphism testing.
For <tt>vf2_graph_iso</tt> the algorithm finds all isomorphism mappings between
graphs <tt>graph1</tt> and <tt>graph2</tt> and outputs them to
<tt>user_callback</tt>.
For <tt>vf2_graph_mono</tt> the algorithm finds all mappings of <tt>graph_small</tt>
to subgraphs of <tt>graph_large</tt>.
Note that, as opposed to <tt>vf2_subgraph_iso</tt>,
these subgraphs need not to be induced subgraphs.
</p>
<p>
Both algorithms continues until <tt>user_callback</tt>
returns false or the search space has been fully explored. As before,
<tt>EdgeEquivalencePredicate</tt> and
<tt>VertexEquivalencePredicate</tt> predicates are used to test
whether edges and vertices are equivalent. By default
@@ -511,7 +523,9 @@ vf2_subgraph_iso(graph1, graph2, callback, vertex_order_by_mult(graph1),
<hr>
<p>
Copyright &copy; 2012, Flavio De Lorenzi
(<a href="mailto:fdlorenzi@gmail.com">fdlorenzi@gmail.com</a>)
(<a href="mailto:fdlorenzi@gmail.com">fdlorenzi@gmail.com</a>) <br />
Copyright &copy; 2013, Jakob Lykke Andersen, University of Southern Denmark
(<a href="mailto:jlandersen@imada.sdu.dk">jlandersen@imada.sdu.dk</a>)
</p>
</body>
</html>