diff --git a/doc/breadth_first_search.html b/doc/breadth_first_search.html
new file mode 100644
index 00000000..e5e17e0a
--- /dev/null
+++ b/doc/breadth_first_search.html
@@ -0,0 +1,163 @@
+
+
+
+
+ Boost Graph Library: Breadth-First Search
+
+
+ 
breadth_first_search
+
+// named paramter version
+template <class Graph, class P, class T, class R>
+void breadth_first_search(Graph& G,
+ typename graph_traits<Graph>::vertex_descriptor s,
+ const bgl_named_params<P, T, R>& params);
+
+// non-named parameter version
+template <class Graph, class Buffer, class BFSVisitor,
+ class ColorMap>
+void breadth_first_search(const Graph& g,
+ typename graph_traits<Graph>::vertex_descriptor s,
+ Buffer& Q, BFSVisitor vis, ColorMap color);
+
+ The breadth_first_search() function performs a breadth-first traversal [49] of a directed or undirected graph. A breadth-first traversal visits vertices that are closer to the source before visiting vertices that are further away. In this context "distance" is defined as the number of edges in the shortest path from the source vertex. The breadth_first_search() function can be used to compute the shortest path from the source to all reachable vertices and the resulting shortest-path distances. For more definitions related to BFS see section Breadth-First Search.
+ BFS uses two data structures to to implement the traversal: a color marker for each vertex and a queue. White vertices are undiscovered while gray vertices are discovered but have undiscovered adjacent vertices. Black vertices are discovered and are adjacent to only other black or gray vertices. The algorithm proceeds by removing a vertex u from the queue and examining each out-edge (u,v). If an adjacent vertex v is not already discovered, it is colored gray and placed in the queue. After all of the out-edges are examined, vertex u is colored black and the process is repeated. Pseudo-code for the BFS algorithm is a listed below.
+
+
+
+
+
+BFS(G, s)
+ for each vertex u in V[G]
+ color[u] := WHITE
+ d[u] := infinity
+ p[u] := u
+ end for
+ color[s] := GRAY
+ d[s] := 0
+ ENQUEUE(Q, s)
+ while (Q != Ø)
+ u := DEQUEUE(Q)
+ for each vertex v in Adj[u]
+ if (color[v] = WHITE)
+ color[v] := GRAY
+ d[v] := d[u] + 1
+ p[v] := u
+ ENQUEUE(Q, v)
+ else
+ if (color[v] = GRAY)
+ ...
+ else
+ ...
+ end for
+ color[u] := BLACK
+ end while
+ return (d, p)
+
+ |
+
+
+
+initialize vertex u
+
+
+
+
+
+
+discover vertex s
+
+examine vertex u
+examine edge (u,v)
+(u,v) is a tree edge
+
+
+
+discover vertex v
+(u,v) is a non-tree edge
+
+(u,v) has a gray target
+
+(u,v) has a black target
+
+finish vertex u
+
+ |
+
+
+
+ The breadth_first_search() function can be extended with user-defined actions that will be called a certain event points. The actions must be provided in the form of a visitor object, that is, an object whose type meets the requirements for a BFS Visitor. In the above pseudo-code, the event points are the labels on the right. Also a description of each event point is given below. By default, the breadth_first_search() function does not carry out any actions, not even recording distances or predecessors. However these can be easily added using the distance_recorder and predecessor_recorder event visitors.
+
+ Where Defined
+ boost/graph/breadth_first_search.hpp
+
+ Parameters
+ IN: Graph& g
+
+ A directed or undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph.
+
+ IN: vertex_descriptor s
+
+ The source vertex where the search is started.
+
+
+ Named Parameters
+ IN: visitor(BFSVisitor vis)
+
+ A visitor object that is invoked inside the algorithm at the event-points specified by the BFS Visitor concept. The visitor object is passed by value [1].
+ Default: bfs_visitor<null_visitor>
+
+ UTIL/OUT: color_map(ColorMap color)
+
+ This is used by the algorithm to keep track of its progress through the graph. The user need not initialize the color map before calling breadth_first_search() since the algorithm initializes the color of every vertex to white at the start of the algorihtm. If you need to perform multiple breadth-first searches on a graph (for example, if there are some disconnected components) then use the breadth_first_visit() function and do your own color initialization.
+ The type ColorMap must be a model of Read/Write Property Map and its key type must be the graph's vertex descriptor type and the value type of the color map must model ColorValue.
+ Default: an iterator_property_map created from a std::vector<default_color_type> of size num_vertices(g) and using the i_map for the index map.
+
+ IN: vertex_index_map(VertexIndexMap i_map)
+
+ This maps each vertex to an integer in the range [0, num_vertices(g)). This parameter is only necessary when the default color property map is used. The type VertexIndexMap must be a model of Readable Property Map. 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.
+ Default: get(vertex_index, g)
+
+ UTIL: buffer(Buffer& Q)
+
+ The queue used to determine the order in which vertices will be discovered. If a FIFO queue is used, then the traversal will be according to the usual BFS ordering. Other types of queues can be used, but the traversal order will be different. For example, Dijkstra's algorithm can be implemented using a priority queue. The type Buffer must be a model of Buffer.
+ The value_type of the buffer must be the vertex_descriptor type for the graph.
+ Default: boost::queue<vertex_descriptor>
+
+
+ Complexity
+ The time complexity is O(E + V).
+
+ Visitor Event Points
+
+ - vis.initialize_vertex(v, g) is invoked on every vertex before the start of the search.
+ - vis.examine_vertex(u, g) is invoked in each vertex as it is removed from the queue.
+ - vis.examine_edge(e, g) is invoked on every out-edge of each vertex immediately after the vertex is removed from the queue.
+ - vis.tree_edge(e, g) is invoked (in addition to examine_edge()) if the edge is a tree edge. The target vertex of edge e is discovered at this time.
+ - vis.discover_vertex(u, g) is invoked the first time the algorithm encounters vertex u. All vertices closer to the source vertex have been discovered, and vertices further from the source have not yet been discovered.
+ - vis.non_tree_edge(e, g) is invoked (in addition to examine_edge()) if the edge is not a tree edge.
+ - vis.gray_target(e, g) is invoked (in addition to non_tree_edge()) if the target vertex is colored gray at the time of examination. The color gray indicates that the vertex is currently in the queue.
+ - vis.black_target(e, g) is invoked (in addition to non_tree_edge()) if the target vertex is colored black at the time of examination. The color black indicates that the vertex is no longer in the queue.
+ - vis.finish_vertex(u, g) is invoked after all of the out edges of u have been examined and all of the adjacent vertices have been discovered.
+
+
+ Example
+ The example in example/bfs-example.cpp demonstrates using the BGL Breadth-first search algorithm on the graph from Figure 5. The file example/bfs-example2.cpp contains the same example, except that the adacency_list class used has VertexList and EdgeList set to listS.
+
+ See Also
+ bfs_visitor and depth_first_search()
+
+ Notes
+ [1] 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.
+
+
+
+ Use, modification, and distribution are subject to the Boost Software License, Version 1.0 at http://www.boost.org/LICENSE_1_0.txt
+
+
+
diff --git a/doc/breadth_first_visit.html b/doc/breadth_first_visit.html
new file mode 100644
index 00000000..cd7aa3ea
--- /dev/null
+++ b/doc/breadth_first_visit.html
@@ -0,0 +1,89 @@
+
+
+
+
+ Boost Graph Library: Breadth-First Visit
+
+
+ 
breadth_first_visit
+
+// named paramter version
+ template <class IncidenceGraph, class P, class T, class R>
+ void breadth_first_visit(IncidenceGraph& G,
+ typename graph_traits<IncidenceGraph>::vertex_descriptor s,
+ const bgl_named_params<P, T, R>& params);
+
+// non-named parameter version
+ template <class IncidenceGraph, class Buffer, class BFSVisitor, class ColorMap>
+ void breadth_first_visit
+ (const IncidenceGraph& g,
+ typename graph_traits<IncidenceGraph>::vertex_descriptor s,
+ Buffer& Q, BFSVisitor vis, ColorMap color);
+
+ This function is basically the same as breadth_first_search() except that the color markers are not initialized in the algorithm. The user is responsible for making sure the color for every vertex is white before calling the algorithm. With this difference, the graph type is only required to be an Incidence Graph instead of a Vertex List Graph. Also, this difference allows for more flexibility in the color property map. For example, one could use a map that only implements a partial function on the vertices, which could be more space efficient when the search only reaches a small portion of the graph.
+
+ Where Defined
+ boost/graph/breadth_first_search.hpp
+
+ Parameters
+ IN: IncidenceGraph& g
+
+ A directed or undirected graph. The graph type must be a model of Incidence Graph.
+
+ IN: vertex_descriptor s
+
+ The source vertex where the search is started.
+
+
+ Named Parameters
+ IN: visitor(BFSVisitor vis)
+
+ A visitor object that is invoked inside the algorithm at the event-points specified by the BFS Visitor concept. The visitor object is passed by value [1].
+ Default: bfs_visitor<null_visitor>
+
+ UTIL/OUT: color_map(ColorMap color)
+
+ This is used by the algorithm to keep track of its progress through the graph. The type ColorMap must be a model of Read/Write Property Map and its key type must be the graph's vertex descriptor type and the value type of the color map must model ColorValue.
+ Default: an iterator_property_map created from a std::vector<default_color_type> of size num_vertices(g) and using the i_map for the index map.
+
+ UTIL: buffer(Buffer& Q)
+
+ The queue used to determine the order in which vertices will be discovered. If a FIFO queue is used, then the traversal will be according to the usual BFS ordering. Other types of queues can be used, but the traversal order will be different. For example, Dijkstra's algorithm can be implemented using a priority queue. The type Buffer must be a model of Buffer.
+ The value_type of the buffer must be the vertex_descriptor type for the graph.
+ Default: boost::queue<vertex_descriptor>
+
+
+
+ Complexity
+ The time complexity is O(E).
+
+ Visitor Event Points
+
+ - vis.initialize_vertex(v, g) is invoked on every vertex before the start of the search.
+ - vis.examine_vertex(u, g) is invoked in each vertex as it is removed from the queue.
+ - vis.examine_edge(e, g) is invoked on every out-edge of each vertex immediately after the vertex is removed from the queue.
+ - vis.tree_edge(e, g) is invoked (in addition to examine_edge()) if the edge is a tree edge. The target vertex of edge e is discovered at this time.
+ - vis.discover_vertex(u, g) is invoked the first time the algorithm encounters vertex u. All vertices closer to the source vertex have been discovered, and vertices further from the source have not yet been discovered.
+ - vis.non_tree_edge(e, g) is invoked (in addition to examine_edge()) if the edge is not a tree edge.
+ - vis.gray_target(e, g) is invoked (in addition to non_tree_edge()) if the target vertex is colored gray at the time of examination. The color gray indicates that the vertex is currently in the queue.
+ - vis.black_target(e, g) is invoked (in addition to non_tree_edge()) if the target vertex is colored black at the time of examination. The color black indicates that the vertex is no longer in the queue.
+ - vis.finish_vertex(u, g) is invoked after all of the out edges of u have been examined and all of the adjacent vertices have been discovered.
+
+
+ See Also
+ breadth_first_search(), bfs_visitor, and depth_first_search()
+
+ Notes
+ [1] 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.
+
+
+
+ Use, modification, and distribution are subject to the Boost Software License, Version 1.0 at http://www.boost.org/LICENSE_1_0.txt
+
+
+
diff --git a/doc/ddnw_random_paths.html b/doc/ddnw_random_paths.html
new file mode 100644
index 00000000..aa0adffe
--- /dev/null
+++ b/doc/ddnw_random_paths.html
@@ -0,0 +1,172 @@
+
+
+
+
+ Boost Graph Library: Dijkstra-DAG Negative-Weighted Random Paths
+
+
+ 
Dijkstra-DAG Negative-Weighted Random Paths
+
+// default version
+template <typename InputGraph, typename RandomNumberGenerator,
+ typename OutputPredecessorMap, typename UtilGraph>
+void ddnw_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomNumberGenerator& random_weight, OutputPredecessorMap out_pred_map,
+ UtilGraph& dag)
+
+
+// named parameter version
+template <typename InputGraph, typename RandomNumberGenerator,
+ typename IP, typename IT, typename IR,
+ typename UP, typename UT, typename UR>
+void ddnw_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomNumberGenerator& random_weight, UtilGraph& dag,
+ const bgl_named_params<IP, IT, IR>& in_params,
+ const bgl_named_params<UP, UT, UR>& u_params)
+
+
+// kitchen-sink version
+template <typename InputGraph, typename RandomNumberGenerator,
+ typename OutputPredecessorMap, typename InputDistanceMap,
+ typename InputIndexMap, typename InputColorMap,
+ typename CompareFunctor, typename CombineFunctor,
+ typename DistanceInfinity, typename DistanceZero,
+ typename InputEventVisitorList, typename UtilGraph,
+ typename UtilPredecessorMap, typename UtilDistanceMap,
+ typename UtilIndexMap, typename UtilColorMap,
+ typename UtilEventVisitorList>
+void ddnw_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomNumberGenerator& random_weight, OutputPredecessorMap out_pred_map,
+ InputDistanceMap in_dist_map, InputIndexMap in_index_map,
+ InputColorMap in_color_map, CompareFunctor compare, CombineFunctor combine,
+ DistanceInfinity infinity, DistanceZero zero, InputEventVisitorList in_vis,
+ UtilGraph& dag, UtilPredecessorMap u_pred_map, UtilDistanceMap u_dist_map,
+ UtilIndexMap u_index_map, UtilColorMap u_color_map,
+ UtilEventVisitorList dag_vis)
+
+
+ This algorithm creates random paths in the input graph, all from the specified source vertex, and places them in the output predecessor map.
+ The implementation carries out the following steps:
+
+ - Run Dijkstra's Random Paths algorithm on the input graph.
+ - For the utility graph, make copies of only the forward and cross edges with respect to the previous traversal. This ensures that the utility graph is acyclic.
+ - Negate the edge weights in the utility graph.
+ - Run dag_shortest_paths on the utility graph. Because of the previous negation, this essentially becomes a longest simple path algorithm. In general, the LSP problem is NP-complete, but directed acyclic graphs make up a special case.
+ - Put the resulting random paths in the output predecessor map.
+
+ Because the algorithm requires two graphs, the named-parameter function variant requires two named-parameter arguments. Furthermore, a default utility graph cannot be provided without defining a specific graph implementation (e.g. adjacency_list).
+
+ Where Defined
+ boost/graph/ddnw_random_paths.hpp
+
+ Parameters
+ IN: InputGraph& in_g
+
+ The input graph. The type InputGraph must be a model of Vertex And Edge List Graph, and edge_weight_t must be a read/write interior property of the graph.
+
+ IN: graph_traits<InputGraph>::vertex_descriptor source
+
+ The source vertex. The random paths tree will be rooted at this vertex.
+
+ IN: RandomNumberGenerator& random_weight
+
+ The random number generator used to put random weights in the graph's internal weight map. The type RandomNumberGenerator must also be a legal template argument in the randomize_property function.
+
+
+ UTIL: UtilGraph& dag
+
+ The utility graph. The type UtilGraph must be a model of Vertex And Edge List Graph and EdgeMutableGraphConcept, the associated directed_category type must be convertible to directed_tag, and edge_weight_t must be a read/write interior property of the graph. Furthermore, dag must contain no edges, and num_vertices(dag) == num_vertices(in_g); the behavior of this algorithm is undefined otherwise. Upon completion of the algorithm, dag will retain its original state.
+
+
+ InputGraph Named Parameters
+ OUT: predecessor_map(OutputPredecessorMap out_pred_map)
+
+ The predecessor map records the edges in the random paths. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the random paths. If p[u] = u then u is either the source vertex or a vertex that is not reachable from the source. The PredecessorMap type must be a Read/Write Property Map whose key and value types are graph_traits<InputGraph>::vertex_descriptor.
Default: get(vertex_predecessor_t(), g)
+
+ IN: vertex_index_map(InputIndexMap in_index_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ UTIL/OUT: distance_map(InputDistanceMap in_dist_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_compare(CompareFunctor compare)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_combine(CombineFunctor combine)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_inf(D infinity)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_zero(D zero)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ UTIL/OUT: color_map(InputColorMap in_color_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ OUT: visitor(InputEventVisitorList in_vis)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+
+ UtilGraph Named Parameters
+ OUT: predecessor_map(UtilPredecessorMap u_pred_map)
+
+ The predecessor map records the edges in the random paths. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the random paths. If p[u] = u then u is either the source vertex or a vertex that is not reachable from the source. The PredecessorMap type must be a Read/Write Property Map whose key and value types are the same as the vertex descriptor type of the graph.
Default: An associative property map built on top of an std::map whose key and value types are graph_traits<UtilGraph>::vertex_descriptor.
+
+ UTIL/OUT: distance_map(UtilDistanceMap u_dist_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dag_shortest_paths.
+
+ IN: vertex_index_map(UtilIndexMap in_index_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dag_shortest_paths.
+
+ UTIL/OUT: color_map(UtilColorMap u_color_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dag_shortest_paths.
+
+ OUT: visitor(UtilEventVisitorList dag_vis)
+
+ Serves the same function, has the same requirements, and uses the same default as in dag_shortest_paths.
+
+
+ Complexity
+ The time complexity is O((V + E) log V), or just O(E log V) if all vertices are reachable from the source.
+
+ Visitor Event Points
+ The visitor event points for the input visitor are the same as in dijkstra_shortest_paths. The visitor event points for the utility visitor are the same as in dag_shortest_paths.
+
+ Example
+ See example/make_random_paths.cpp for an example of using the Dijkstra-DAG Negative-Weighted Random Paths algorithm.
+
+ Performance
+ In terms of randomness, this algorithm fares better than Dijkstra's version, but not as well as the Loop-Erased Random Paths algorithm.
+
+ Test
+ The test program test/make_random_paths.cpp can be used to verify that ddnw_random_paths works as expected.
+
+
+
+
+ | Copyright © 2004 |
+ Cromwell D. Enage |
+
+
+ Covered by 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).
+
+
+
diff --git a/doc/dijkstra_random_paths.html b/doc/dijkstra_random_paths.html
new file mode 100644
index 00000000..7ce2bfff
--- /dev/null
+++ b/doc/dijkstra_random_paths.html
@@ -0,0 +1,121 @@
+
+
+
+
+ Boost Graph Library: Dijkstra's Random Paths
+
+
+ 
dijkstra_random_paths
+
+// default version
+template <typename Graph, typename RandomNumberGenerator,
+ typename PredecessorMap>
+void dijkstra_random_paths(
+ Graph& g,
+ typename graph_traits<Graph>::vertex_descriptor source,
+ RandomNumberGenerator& random_weight, PredecessorMap pred_map)
+
+
+// named parameter version
+template <typename Graph, typename RandomNumberGenerator,
+ typename Param, typename Tag, typename Rest>
+void dijkstra_random_paths(
+ Graph& g,
+ typename graph_traits<Graph>::vertex_descriptor source,
+ RandomNumberGenerator& random_weight,
+ const bgl_named_params<Param, Tag, Rest>& params)
+
+
+// kitchen-sink version
+template <typename Graph, typename RandomNumberGenerator,
+ typename PredecessorMap, typename DistanceMap,
+ typename VertexIndexMap, typename VertexColorMap,
+ typename CompareFunctor, typename CombineFunctor,
+ typename DistanceInfinity, typename DistanceZero,
+ typename EventVisitorList>
+void dijkstra_random_paths(
+ Graph& g,
+ typename graph_traits<Graph>::vertex_descriptor source,
+ RandomNumberGenerator& random_weight, PredecessorMap pred_map,
+ DistanceMap dist_map, VertexIndexMap index_map, VertexColorMap color_map,
+ CompareFunctor compare, CombineFunctor combine, DistanceInfinity infinity,
+ DistanceZero zero, EventVisitorList vis)
+
+
+ This algorithm creates random paths in the input graph, all from the specified source vertex, and places them in the output predecessor map.
+ The implementation runs on top of Dijkstra's shortest-pahts algorithm using random edge weights; the resulting paths tend to be short as well.
+
+ Where Defined
+ boost/graph/dijkstra_random_paths.hpp
+
+ Parameters
+ IN: Graph& g
+
+ The graph object on which the algorithm will be applied. The type Graph must be a model of Vertex And Edge List Graph, and edge_weight_t must be a read/write interior property of the graph.
+
+ IN: graph_traits<Graph>::vertex_descriptor source
+
+ The source vertex. All distances will be calculated from this vertex, and the random paths tree will be rooted at this vertex.
+
+
+ Named Parameters
+ OUT: predecessor_map(PredecessorMap p_map)
+
+ The predecessor map records the edges in the random paths. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the random paths. If p[u] = u then u is either the source vertex or a vertex that is not reachable from the source. The PredecessorMap type must be a Read/Write Property Map whose key and value types are the same as the vertex descriptor type of the graph.
Default: get(vertex_predecessor_t(), g)
+
+ IN: vertex_index_map(VertexIndexMap i_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ UTIL/OUT: distance_map(DistanceMap d_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_compare(CompareFunction cmp)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_combine(CombineFunction cmb)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_inf(D inf)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ IN: distance_zero(D zero)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ UTIL/OUT: color_map(ColorMap c_map)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+ OUT: visitor(EventVisitorList vis)
+
+ Serves the same function, has the same requirements, and uses the same default as in dijkstra_shortest_paths.
+
+
+ Complexity
+ The time complexity is O((V + E) log V), or just O(E log V) if all vertices are reachable from the source.
+
+ Visitor Event Points
+ Same as in dijkstra_shortest_paths.
+
+ Example
+ See example/make_random_paths.cpp for an example of using Dijkstra's Random Paths algorithm.
+
+ Test
+ The test program test/make_random_paths.cpp can be used to verify that dijkstra_random_paths works as expected.
+
+
+
+
+ | Copyright © 2004 |
+ Cromwell D. Enage |
+
+
+ Covered by 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).
+
+
+
diff --git a/doc/loop_erased_random_paths.html b/doc/loop_erased_random_paths.html
new file mode 100644
index 00000000..0f784197
--- /dev/null
+++ b/doc/loop_erased_random_paths.html
@@ -0,0 +1,124 @@
+
+
+
+
+ Boost Graph Library: Loop-Erased Random Paths
+
+
+ 
loop_erased_random_paths
+
+// default version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename OutputPredecessorMap, typename UtilGraph>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, OutputPredecessorMap out_pred_map, UtilGraph& u_g)
+
+
+// named parameter version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename IP, typename IT, typename IR,
+ typename UP, typename UT, typename UR>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, UtilGraph& u_g,
+ const bgl_named_params<IP, IT, IR>& in_params,
+ const bgl_named_params<UP, UT, UR>& u_params)
+
+
+// kitchen-sink version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename OutputPredecessorMap, typename InputIndexMap,
+ typename InputColorMap, typename UtilGraph, typename UtilIndexMap,
+ typename UtilColorMap>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, OutputPredecessorMap out_pred_map,
+ InputIndexMap in_index_map, InputColorMap in_color_map,
+ UtilGraph& u_g, UtilIndexMap u_index_map, UtilColorMap u_color_map)
+
+
+ This algorithm creates random paths in the input graph, all from the specified source vertex, and places them in the output predecessor map. The implementation is based on an algorithm by James Gary Propp and David Bruce Wilson, located at http://dbwilson.com/ja/ja.ps.gz.ps on page 28. (See http://dbwilson.com/ja/ for output formats other than Postscript.)
+ The output predecessor map may form a forest instead of a tree; the implementation returns false in this case. How you deal with the result depends on whether you need all the paths (solved by while(!loop_erased_random_paths(...)){}) or just the path to a particular target vertex (see the example).
+ Because the algorithm requires two graphs, the named-parameter function variant requires two named-parameter arguments.
+
+ Where Defined
+ boost/graph/loop_erased_random_paths.hpp
+
+ Parameters
+ IN: InputGraph& in_g
+
+ The input graph. The type InputGraph must be a model of Vertex List Graph and Adjacency Graph.
+
+ IN: graph_traits<Graph>::vertex_descriptor source
+
+ The source vertex. The random paths tree will be rooted at this vertex.
+
+ IN: RandomIndexGenerator& rig
+
+ The base random number generator used to help choose random predecessors for vertices. The type RandomIndexGenerator must be a model of STL Random Number Generator. (You may use the boost::random_number_generator for this purpose.)
+
+ UTIL: UtilGraph& u_g
+
+ The utility graph, used by the algorithm to create a transposed copy of the input graph in order to efficiently find random predecessors. The type UtilGraph must be a model of Vertex List Graph, Adjacency Graph, and EdgeMutableGraphConcept.
+ Further preconditions: u_g must contain no edges, and num_vertices(u_g) == num_vertices(in_g)
+
+
+ InputGraph Named Parameters
+ OUT: predecessor_map(OutputPredecessorMap out_pred_map)
+
+ The predecessor map records the edges in the random paths. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the random paths. If p[u] = u then u is either the source vertex or a vertex that is not reachable from the source. The PredecessorMap type must be a Read/Write Property Map whose key and value types are graph_traits<InputGraph>::vertex_descriptor.
+ Default: get(vertex_predecessor_t(), g)
+
+ IN: vertex_index_map(InputIndexMap in_index_map)
+
+ Aids in bidirectional mapping between the graphs' vertex sets.
+ Default: get(vertex_index_t(), in_g)
+
+ UTIL/OUT: color_map(InputColorMap in_color_map)
+
+ Used by the algorithm to mark a vertex as part of the random tree.
+ Default: An iterator_property_map created from a std::vector<typename graph_traits<InputGraph>::vertex_descriptor> of size num_vertices(in_g) and using in_index_map for the index map.
+
+
+ UtilGraph Named Parameters
+ IN: vertex_index_map(UtilIndexMap in_index_map)
+
+ Aids in bidirectional mapping between the graphs' vertex sets.
+ Default: get(vertex_index_t(), u_g)
+
+ UTIL/OUT: color_map(UtilColorMap u_color_map)
+
+ Used by the algorithm to prevent loops from entering the random tree.
+ Default: An iterator_property_map created from a std::vector<typename graph_traits<UtilGraph>::vertex_descriptor> of size num_vertices(in_g) and using u_index_map for the index map.
+
+
+ Complexity
+ The time complexity is O(V + E).
+
+ Visitor Event Points
+ Should there be?
+
+ Example
+ See example/make_random_paths.cpp for an example of using the Loop-Erased Random Paths algorithm.
+
+ Performance
+ In terms of randomness, this is the library's best implementation so far.
+
+ Test
+ The test program test/make_random_paths.cpp can be used to verify that loop_erased_random_paths works as expected.
+
+
+
+
+ | Copyright © 2004 |
+ Cromwell D. Enage |
+
+
+ Covered by 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).
+
+
+
diff --git a/doc/loop_erased_random_paths0.html b/doc/loop_erased_random_paths0.html
new file mode 100644
index 00000000..6c5581f5
--- /dev/null
+++ b/doc/loop_erased_random_paths0.html
@@ -0,0 +1,158 @@
+
+
+
+
+ Boost Graph Library: Loop-Erased Random Paths
+
+
+ 
loop_erased_random_paths
+
+// generic default version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename OutputPredecessorMap, typename UtilGraph>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, OutputPredecessorMap out_pred_map, UtilGraph& u_g)
+
+
+// generic named parameter version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename IP, typename IT, typename IR,
+ typename UP, typename UT, typename UR>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, UtilGraph& u_g,
+ const bgl_named_params<IP, IT, IR>& in_params,
+ const bgl_named_params<UP, UT, UR>& u_params)
+
+
+// generic kitchen-sink version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename OutputPredecessorMap, typename InputIndexMap,
+ typename InputColorMap, typename UtilGraph, typename UtilIndexMap,
+ typename UtilColorMap>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, OutputPredecessorMap out_pred_map,
+ InputIndexMap in_index_map, InputColorMap in_color_map,
+ UtilGraph& u_g, UtilIndexMap u_index_map, UtilColorMap u_color_map)
+
+
+// specialized default version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename OutputPredecessorMap>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, OutputPredecessorMap out_pred_map)
+
+
+// specialized named parameter version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename IP, typename IT, typename IR>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig,
+ const bgl_named_params<IP, IT, IR>& in_params)
+
+
+// specialized kitchen-sink version
+template <typename InputGraph, typename RandomIndexGenerator,
+ typename OutputPredecessorMap, typename InputIndexMap,
+ typename InputColorMap>
+bool loop_erased_random_paths(
+ InputGraph& in_g,
+ typename graph_traits<InputGraph>::vertex_descriptor source,
+ RandomIndexGenerator& rig, OutputPredecessorMap out_pred_map,
+ InputIndexMap in_index_map, InputColorMap in_color_map)
+
+
+ This algorithm creates random paths in the input graph, all from the specified source vertex, and places them in the output predecessor map. The implementation is based on an algorithm by James Gary Propp and David Bruce Wilson, located at http://dbwilson.com/ja/ja.ps.gz.ps on page 28. (See http://dbwilson.com/ja/ for output formats other than Postscript.)
+ The output predecessor map may form a forest instead of a tree; the implementation returns false in this case. How you deal with the result depends on whether you need all the paths (solved by while(!loop_erased_random_paths(...)){}) or just the path to a particular target vertex (see the example).
+ The specialized versions of the algorithm (the ones that don't take in a utility graph parameter) will work (i.e. compile) if and only if the input graph is either undirected or bidirectional.
+ Because the generic versions of the algorithm requires two graphs, the named-parameter function variant requires two named-parameter arguments.
+
+ Where Defined
+ boost/graph/loop_erased_random_paths.hpp
+
+ Parameters
+ IN: InputGraph& in_g
+
+ The input graph. The type InputGraph must be a model of Vertex List Graph and Adjacency Graph.
+
+ IN: graph_traits<InputGraph>::vertex_descriptor source source
+
+ The source vertex. The random paths tree will be rooted at this vertex.
+
+ IN: RandomIndexGenerator& rig
+
+ The base random number generator used to help choose random predecessors for vertices. The type RandomIndexGenerator must be a model of STL Random Number Generator. (You may use the boost::random_number_generator for this purpose.)
+
+ UTIL: UtilGraph& u_g
+
+ The utility graph, used by the algorithm to create a transposed copy of the input graph in order to efficiently find random predecessors. The type UtilGraph must be a model of Vertex List Graph, Adjacency Graph, and EdgeMutableGraphConcept.
+ Further preconditions: u_g must contain no edges, and num_vertices(u_g) == num_vertices(in_g)
+ Note: The specialized versions of the algorithm do not take in this parameter.
+
+
+ InputGraph Named Parameters
+ OUT: predecessor_map(OutputPredecessorMap out_pred_map)
+
+ The predecessor map records the edges in the random paths. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the random paths. If p[u] = u then u is either the source vertex or a vertex that is not reachable from the source. The PredecessorMap type must be a Read/Write Property Map whose key and value types are graph_traits<InputGraph>::vertex_descriptor.
+ Default: get(vertex_predecessor_t(), g)
+
+ IN: vertex_index_map(InputIndexMap in_index_map)
+
+ Aids in bidirectional mapping between the graphs' vertex sets.
+ Default: get(vertex_index_t(), in_g)
+
+ UTIL/OUT: color_map(InputColorMap in_color_map)
+
+ Used by the algorithm to mark a vertex as part of the random tree.
+ Default: An iterator_property_map created from a std::vector<typename graph_traits<InputGraph>::vertex_descriptor> of size num_vertices(in_g) and using in_index_map for the index map.
+
+
+ UtilGraph Named Parameters
+ IN: vertex_index_map(UtilIndexMap in_index_map)
+
+ Aids in bidirectional mapping between the graphs' vertex sets.
+ Default: get(vertex_index_t(), u_g)
+ Note: The specialized versions of the algorithm do not take in this parameter.
+
+ UTIL/OUT: color_map(UtilColorMap u_color_map)
+
+ Used by the algorithm to prevent loops from entering the random tree.
+ Default: An iterator_property_map created from a std::vector<typename graph_traits<UtilGraph>::vertex_descriptor> of size num_vertices(in_g) and using u_index_map for the index map.
+ Note: The specialized versions of the algorithm do not take in this parameter.
+
+
+ Complexity
+ The time complexity is O(V + E).
+
+ Visitor Event Points
+ Should there be?
+
+ Example
+ See example/make_random_paths.cpp for an example of using the Loop-Erased Random Paths algorithm.
+
+ Performance
+ In terms of randomness, this is the library's best implementation so far.
+
+ Test
+ The test program test/make_random_paths.cpp can be used to verify that loop_erased_random_paths works as expected.
+
+
+
+
+ | Copyright © 2004 |
+ Cromwell D. Enage |
+
+
+ Covered by 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).
+
+
+
diff --git a/doc/tarjan_offline_lca.html b/doc/tarjan_offline_lca.html
new file mode 100644
index 00000000..1bc88bb0
--- /dev/null
+++ b/doc/tarjan_offline_lca.html
@@ -0,0 +1,103 @@
+
+
+
+
+ Boost Graph Library: Tarjan's Offline Least Common Ancestor Algorithm
+
+
+ 
Tarjan's Offline Least Common Ancestor Algorithm
+
+// default version
+template <typename Graph, typename AncestorMatrix>
+void tarjan_offline_lca(
+ const Graph& in_g, typename graph_traits<Graph>::vertex_descriptor source,
+ AncestorMatrix& ancestor_matrix)
+
+
+// kitchen-sink version
+template <typename Graph, typename AncestorMatrix, typename DisjointSets,
+ typename PredecessorMap, typename VertexColorMap,
+ typename EventVisitorList>
+void tarjan_offline_lca(
+ const Graph& in_g, typename graph_traits<Graph>::vertex_descriptor source,
+ AncestorMatrix& ancestor_matrix, DisjointSets dsets,
+ PredecessorMap ancestor_map, VertexColorMap color_map, EventVisitorList vis)
+
+
+ The least common ancestor (LCA) of two vertices is the vertex that fulfills the following conditions:
+
+ - Both input vertices are its descendants.
+ - None of its descendants fulfill the previous condition.
+
+ This algorithm precalculates the LCA of all pairs of vertices in the graph and stores the results in the output ancestor matrix.
+ TODO: Implement an output format that is more true to the original algorithm (i.e. only calculates the results for a specified set of vertex pairs) but is still generic. The target time complexity is O(N * V log V), where N is the (relatively small) size of the input set of vertex pairs for which the LCA actually needs to be calculated.
+
+ Where Defined
+ boost/graph/tarjan_offline_lca.hpp
+
+ Parameters
+ IN: Graph& g
+
+ The input graph.
+ Preconditions:
+
+
+ IN: graph_traits<Graph>::vertex_descriptor source
+
+ The root of the tree graph.
+
+ OUT: AncestorMatrix& ancestor_matrix
+
+ The output matrix that will store the results of the LCA calculations.
+ Preconditions:
+
+ - The type AncestorMatrix must implement the () operator, whose two arguments must be of type graph_traits<Graph>::vertex_descriptor and whose return type must also be graph_traits<Graph>::vertex_descriptor.
+ - The matrix object must contain at least num_vertices(g) rows and at least num_vertices(g) columns of elements.
+
+ Postcondition: The LCA of vertices x and y in g is ancestor_matrix(x, y).
+
+ UTIL/OUT: DisjointSets dsets
+
+ The algorithm makes a set for each vertex during its discovery by the depth-first traversal. During post-traversal of a vertex, it unionizes the vertex with all of its children so that, instead of making X2 LCA calculations for X children, at most N LCA calculations will be made. Currently, N = num_vertices(g); see the TODO above.
+
+ UTIL/OUT: predecessor_map(PredecessorMap out_pred_map)
+
+ The predecessor map records the edges in the tree. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the tree. If p[u] = u then u is either the source vertex or a vertex that is not reachable from the source. The PredecessorMap type must be a Read/Write Property Map whose key and value types are graph_traits<Graph>::vertex_descriptor.
+ Default: A dummy associative_property_map.
+
+ UTIL/OUT: vertex_color_map(VertexColorMap color_map)
+
+ Used by the algorithm to mark a vertex as part of the tree.
+ Default: An iterator_property_map created from a std::vector<typename graph_traits<InputGraph>::vertex_descriptor> of size num_vertices(g) and using get(vertex_index_t(), g) for the index map.
+
+
+ Complexity
+ The current time complexity is O(V2 log V) until a better output format is implemented; see the TODO above.
+
+ Visitor Event Points
+ Same as in depth_first_search.
+
+ Example
+ See example/tarjan_offline_lca.cpp for an example of using Tarjan's Offline Least Common Ancestor Algorithm.
+
+ Performance
+ Recursion could be a problem, but the current absence of a post-traversal event filter (neither on_back_edge nor on_forward_or_cross_edge would fire if this example program had used them) precludes usage of either the depth_first_search or undirected_dfs built-in functions.
+
+ Test
+ The test program test/tarjan_offline_lca.cpp can be used to verify that tarjan_offline_lca works as expected.
+
+
+
+
+ | Copyright © 2004 |
+ Cromwell D. Enage |
+
+
+ Covered by 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).
+
+
+
diff --git a/example/make_random_paths.cpp b/example/make_random_paths.cpp
new file mode 100644
index 00000000..f251b483
--- /dev/null
+++ b/example/make_random_paths.cpp
@@ -0,0 +1,643 @@
+/* make_random_paths.cpp source file
+ *
+ * Copyright 2004 Cromwell D. Enage. Covered by 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)
+ */
+
+/*
+ * Defines the std::ios class and std::cout, its global output instance.
+ */
+#include
+
+/*
+ * Defines the std::list class template and its iterators.
+ */
+#include
+
+/*
+ * Defines the std::map class template.
+ */
+#include