00001 00027 #ifndef MSMAZES_CORE_DEBUG_MAKE_INDEX_MAP_HPP 00028 #define MSMAZES_CORE_DEBUG_MAKE_INDEX_MAP_HPP 00029 00030 #include <boost/utility.hpp> // boost::tie 00031 #include <boost/property_map.hpp> // boost::property_traits and boost::put 00032 #include <boost/graph/graph_traits.hpp> // boost::graph_traits 00033 #include <boost/graph/graph_selectors.hpp> // BGL vertex & edge list selectors. 00034 #include <boost/graph/adjacency_list.hpp> // boost::adjacency_list 00035 #include <boost/graph/adjacency_matrix.hpp> // boost::adjacency_matrix 00036 00037 namespace msmazes { 00038 00040 00051 template < 00052 typename EdgeListSelector 00053 , typename DirectionalSelector 00054 , typename VertexProperty 00055 , typename EdgeProperty 00056 , typename GraphProperty 00057 , typename VertexIndexMap 00058 > 00059 inline void 00060 makeIndexMap( 00061 boost::adjacency_list< 00062 EdgeListSelector 00063 , boost::vecS 00064 , DirectionalSelector 00065 , VertexProperty 00066 , EdgeProperty 00067 , GraphProperty 00068 >& g 00069 , VertexIndexMap index_map 00070 ) 00071 { 00072 /* 00073 * An adjacency_list object whose vertex container is a std::vector 00074 * has a prebuilt index map. 00075 */ 00076 } 00077 00079 00090 template < 00091 typename DirectionalSelector 00092 , typename VertexProperty 00093 , typename EdgeProperty 00094 , typename GraphProperty 00095 , typename VertexIndexMap 00096 > 00097 inline void 00098 makeIndexMap( 00099 boost::adjacency_matrix< 00100 DirectionalSelector 00101 , VertexProperty 00102 , EdgeProperty 00103 , GraphProperty 00104 >& g 00105 , VertexIndexMap index_map 00106 ) 00107 { 00108 /* 00109 * All adjacency_matrix objects have prebuilt index maps. 00110 */ 00111 } 00112 00114 00125 template < 00126 typename VertexListGraph 00127 , typename VertexIndexMap 00128 > 00129 void 00130 makeIndexMap( 00131 VertexListGraph& g 00132 , VertexIndexMap index_map 00133 ) 00134 { 00135 typename boost::property_traits<VertexIndexMap>::value_type index; 00136 typename boost::graph_traits<VertexListGraph>::vertex_iterator vi, vend; 00137 00138 for (boost::tie(vi, vend) = boost::vertices(g); vi != vend; ++vi, ++index) 00139 { 00140 boost::put(index_map, *vi, index); 00141 } 00142 } 00143 } // namespace msmazes 00144 00145 #endif /* MSMAZES_CORE_DEBUG_MAKE_INDEX_MAP_HPP */
Multi-State Mazes in C++ is hosted by . Use the Table of Contents for navigation.