#ifndef BFS_DISTMAP_8737 #define BFS_DISTMAP_8737 /* Use distance map (or anything else which suits the following requirements) as a color map. Write operations are just ignored. Read operations work as follows: When the value in the underlying map equals a specified value, e.g. -1 in a distance map, or the null pointer in a predecessor map, the 'White' value is returned, otherwise the 'Black' value is returned. Note: This only is usable for application where there is no need to distinguish gray and black non-tree edge targets. Note: Setting the value in the underlying map so that it no longer corresponds to a 'White' value will have to be done by the visitor on the discover_vertex event. */ /* Template parameters: - Graph - ColorValue (default value: int?) - ReadablePropertyMap (underlying map) */ /* Runtime parameters: - Graph g - ReadablePropertyMap pm - ReadablePropertyMap::value_type white (must be == comparable) */ #include #include #include template class MapAsColorMap { private: typename boost::property_traits::value_type white_; const ReadablePropertyMap& pm_; public: typedef typename boost::graph_traits::vertex_descriptor key_type; typedef ColorValue value_type; typedef ColorValue reference; typedef boost::read_write_property_map_tag category; ColorValue get(key_type key); MapAsColorMap(const ReadablePropertyMap& pm, typename boost::property_traits::value_type white): // int white): white_(white), pm_(pm) {}; }; template MapAsColorMap make_map_as_colormap(Graph& g, ReadablePropertyMap& pm, ColorValue c, typename boost::property_traits::value_type white) { return MapAsColorMap(pm, white); } template ColorValue MapAsColorMap::get(key_type key) { return (boost::get(pm_, key)==white_) ? boost::color_traits::white() : boost::color_traits::black(); } template ColorValue get(MapAsColorMap pmap, typename boost::graph_traits::vertex_descriptor key) { return pmap.get(key); } template void put(MapAsColorMap pmap, typename boost::graph_traits::vertex_descriptor key, typename boost::property_traits::value_type value) {} #endif