diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index 840bce54..fad2c208 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -139,7 +139,7 @@ public: euclidean_heuristic(vertex_descriptor goal):m_goal(goal) {}; double operator()(vertex_descriptor v) { - return sqrt(pow(m_goal[0] - v[0], 2) + pow(m_goal[1] - v[1], 2)); + return sqrt(pow(double(m_goal[0] - v[0]), 2) + pow(double(m_goal[1] - v[1]), 2)); } private: diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index 4df80764..5461d3dc 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -95,6 +95,12 @@ namespace boost { typedef edge_weight_map type; typedef edge_weight_map const_type; }; + + template<> + struct property_map< const ring_graph, edge_weight_t > { + typedef edge_weight_map type; + typedef edge_weight_map const_type; + }; } // Tag values that specify the traversal type in graph::traversal_category. @@ -374,7 +380,7 @@ edges_size_type num_edges(const ring_graph& g) { // AdjacencyMatrix valid expressions std::pair edge(vertex_descriptor u, vertex_descriptor v, const ring_graph& g) { - if (abs(u-v) == 1 && + if ((u == v + 1 || v == u + 1) && u >= 0 && u < num_vertices(g) && v >= 0 && v < num_vertices(g)) return std::pair(edge_descriptor(u, v), true); else diff --git a/include/boost/graph/compressed_sparse_row_graph.hpp b/include/boost/graph/compressed_sparse_row_graph.hpp index 1a1cd674..59e8bb4a 100644 --- a/include/boost/graph/compressed_sparse_row_graph.hpp +++ b/include/boost/graph/compressed_sparse_row_graph.hpp @@ -43,6 +43,7 @@ #include #include #include +#include namespace boost { @@ -1284,22 +1285,51 @@ get_property(const BOOST_CSR_GRAPH_TYPE& g, Tag tag) return get_property_value(g.m_property, tag); } +template +struct csr_property_map_helper {}; +// Kind == void for invalid property tags, so we can use that to SFINAE out + template -struct property_map { - typedef typename detail::property_kind_from_graph::type kind; - typedef typename boost::mpl::if_< - boost::is_same, - vertex_all_t, - typename boost::mpl::if_< - boost::is_same, - edge_all_t, - graph_all_t>::type>::type all_tag; - typedef typename property_traits::type>::key_type key_type; - typedef typename property_traits::type>::value_type plist_type; - typedef transform_value_property_map, typename property_map::type> type; - typedef transform_value_property_map, typename property_map::const_type> const_type; +struct csr_property_map_helper { + typedef vertex_all_t all_tag; + typedef typename property_traits::type>::key_type key_type; + typedef VertexProperty plist_type; + typedef typename property_map::type all_type; + typedef typename property_map::const_type all_const_type; + typedef transform_value_property_map, all_type> type; + typedef transform_value_property_map, all_const_type> const_type; }; +template +struct csr_property_map_helper { + typedef edge_all_t all_tag; + typedef typename property_traits::type>::key_type key_type; + typedef EdgeProperty plist_type; + typedef typename property_map::type all_type; + typedef typename property_map::const_type all_const_type; + typedef transform_value_property_map, all_type> type; + typedef transform_value_property_map, all_const_type> const_type; +}; + +template +struct csr_property_map_helper { + typedef graph_all_t all_tag; + typedef BOOST_CSR_GRAPH_TYPE* key_type; + typedef GraphProperty plist_type; + typedef typename property_map::type all_type; + typedef typename property_map::const_type all_const_type; + typedef transform_value_property_map, all_type> type; + typedef transform_value_property_map, all_const_type> const_type; +}; + +template +struct property_map: + csr_property_map_helper< + BOOST_CSR_GRAPH_TYPE, + Tag, + typename detail::property_kind_from_graph + ::type> {}; + template typename property_map::type get(Tag tag, BOOST_CSR_GRAPH_TYPE& g) { @@ -1367,6 +1397,13 @@ struct property_map typedef typename BOOST_CSR_GRAPH_TYPE::forward_type::inherited_edge_properties::const_edge_map_type const_type; }; +template +struct property_map +{ + typedef boost::ref_property_map type; + typedef boost::ref_property_map const_type; +}; + template inline typed_identity_property_map get(vertex_index_t, const BOOST_CSR_GRAPH_TYPE&) @@ -1513,6 +1550,48 @@ put(edge_all_t, put(get(edge_all, g), e, val); } +template +inline typename property_map::type +get(graph_all_t, BOOST_CSR_GRAPH_TYPE& g) +{ + return typename property_map::type(g.m_property); +} + +template +inline typename property_map::const_type +get(graph_all_t, const BOOST_CSR_GRAPH_TYPE& g) +{ + return typename property_map::const_type(g.m_property); +} + +template +inline GraphProperty& +get(graph_all_t, + BOOST_CSR_GRAPH_TYPE& g, + BOOST_CSR_GRAPH_TYPE*) +{ + return g.m_property; +} + +template +inline const GraphProperty& +get(graph_all_t, + const BOOST_CSR_GRAPH_TYPE& g, + BOOST_CSR_GRAPH_TYPE*) +{ + return g.m_property; +} + +template +inline void +put(graph_all_t, + BOOST_CSR_GRAPH_TYPE& g, + BOOST_CSR_GRAPH_TYPE*, + const GraphProperty& val) +{ + g.m_property = val; +} + #undef BOOST_CSR_GRAPH_TYPE #undef BOOST_CSR_GRAPH_TEMPLATE_PARMS #undef BOOST_DIR_CSR_GRAPH_TYPE