Studying the Boost Graph Library will help greatly in understanding the implementations of these algorithms.
Classes | |
class | msmazes::DefaultRandomPathEdgePredicate |
The type of the default edge-checking predicate passed to the msmazes::makeRandomPaths() function template. More... | |
class | msmazes::DefaultCrossEdgeRemovalIntruder |
The type of the default intruder passed to the msmazes::removeCrossEdges() function template. More... | |
Functions | |
template<typename Graph> | |
bool | msmazes::hasInEdges (typename boost::graph_traits< Graph >::vertex_descriptor target_v, const Graph &g) |
Returns true if the graph contains any incoming edges to target_v, false otherwise. | |
template<typename Graph> | |
void | msmazes::removeInEdges (typename boost::graph_traits< Graph >::vertex_descriptor target_v, Graph &g) |
Removes all of target_v 's incoming edges from the graph. | |
template<typename PredecessorMap, typename FrontInsertionSequence> | |
bool | msmazes::makePath (typename boost::property_traits< PredecessorMap >::key_type source, typename boost::property_traits< PredecessorMap >::key_type target, const PredecessorMap p_map, FrontInsertionSequence &path) |
Stores the target vertex and its entire set of predecessors through the source vertex in the specified path container. | |
template<typename InputGraph, typename Vertex, typename Shuffler, typename OutputPredecessorMap, typename RandomPathEdgePredicate> | |
bool | msmazes::makeRandomPaths (InputGraph &input_graph_arg, Vertex source_vertex_arg, Shuffler &shuffler_arg, OutputPredecessorMap output_predecessor_map_arg, RandomPathEdgePredicate visitor_arg) |
Outputs random paths from the graph to the predecessor map. | |
template<typename Params> | |
void | msmazes::makeRandomPaths_with_named_params (Params &p) |
Packed-argument version of makeRandomPaths() . | |
template<typename PathIterator, typename InputGraph, typename PredecessorMap, typename VertexIndexMap, typename VertexColorMap, typename VertexRankMap, typename Buffer, typename CrossEdgeRemovalIntruder> | |
void | msmazes::removeCrossEdges (PathIterator path_begin, PathIterator path_end, InputGraph &g, PredecessorMap predecessor_map, VertexIndexMap index_map, VertexColorMap color_map, VertexRankMap rank_map, Buffer &Q, CrossEdgeRemovalIntruder &intruder) |
Converts the specified digraph to a maze with the specified solution path, using any specified utility maps. | |
template<typename Params> | |
void | msmazes::removeCrossEdges_with_named_params (Params &p) |
Packed-argument version of removeCrossEdges() . |
|
Returns
|
|
Removes every edge
|
|
Attempts to extract a path from the input predecessor map, using the specified vertices as the path's endpoints, and store it in the specified container. Returns
|
|
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 All programs using this function template must define BOOST_PARAMETER_MAX_ARITY as 5 or more.
The example below shows how to output a number of random paths from the source vertex to a particular target vertex. typedef boost::adjacency_list<> Graph; typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; typedef std::map<Vertex,Vertex> VertexMap; typedef std::list<Vertex> Path; typedef boost::associative_property_map<VertexMap> PredecessorMap; typedef boost::random_number_generator<boost::mt19937,unsigned int> Shuffler; Graph g(24); // Builds a graph with 24 vertices Vertex source_vertex = boost::vertex(0, g); Vertex target_vertex = boost::vertex(23, g); VertexMap v_map; PredecessorMap pred_map(v_map); std::list<Vertex> path; boost::mt19937 rng_engine; Shuffler shuffler(rng_engine); initGraph(g); // Bunch of boost::add_edge() calls int num_runs = 5; // Output five random paths while (num_runs > 0) { msmazes::makeRandomPaths(g, source_vertex, shuffler, pred_map); if (msmazes::makePath(source_vertex, target_vertex, pred_map, path)) { // Process output path ... --num_runs; } path.clear(); } You can also pass the arguments by name. The following function call is equivalent to the one above: msmazes::makeRandomPaths( msmazes::input_graph_arg = g , msmazes::source_vertex_arg = source_vertex , msmazes::shuffler_arg = shuffler , msmazes::output_predecessor_map_arg = pred_map ); Use the parameter table above to look up the parameter names. |
|
Outputs random paths from the graph to the predecessor map, both of which are named arguments in the specified Argument Pack object. See the |
|
Removes cross-edges, with respect to the main path described by the range All programs using this function template must define BOOST_PARAMETER_MAX_ARITY as 9 or more.
The example below illustrates the typical usage of this algorithm. typedef boost::adjacency_list<> Graph; typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; typedef std::map<Vertex,Vertex> VertexMap; typedef std::list<Vertex> Path; typedef boost::associative_property_map<VertexMap> PredecessorMap; typedef boost::random_number_generator<boost::mt19937,unsigned int> Shuffler; Graph g(24); // Builds a graph with 24 vertices Vertex source_vertex = boost::vertex(0, g); Vertex target_vertex = boost::vertex(23, g); VertexMap v_map; PredecessorMap pred_map(v_map); std::list<Vertex> path; boost::mt19937 rng_engine; Shuffler shuffler(rng_engine); initGraph(g); // Bunch of boost::add_edge() calls bool path_not_made = true; while (path_not_made) { path_not_made = false; msmazes::makeRandomPaths(g, source_vertex, shuffler, pred_map); if (msmazes::makePath(source_vertex, target_vertex, pred_map, path)) { msmazes::removeCrossEdges(path.begin(), path.end(), g); } else { path_not_made = true; path.clear(); } } You can also pass the arguments by name. The following function call is equivalent to the one above: msmazes::removeCrossEdges( msmazes::path_begin_arg = path.begin() , msmazes::path_end_arg = path.end() , msmazes::input_graph_arg = g ); Use the parameter table above to look up the parameter names. |
|
Converts the digraph to a maze. The digraph is a named argument in the specified Argument Pack object. See the |
Multi-State Mazes in C++ is hosted by . Use the Table of Contents for navigation.