diff --git a/include/boost/graph/properties.hpp b/include/boost/graph/properties.hpp index aac72ec7..e97559c9 100644 --- a/include/boost/graph/properties.hpp +++ b/include/boost/graph/properties.hpp @@ -26,6 +26,7 @@ #define BOOST_GRAPH_PROPERTIES_HPP #include +#include #include #include @@ -243,6 +244,40 @@ namespace boost { return degree_property_map(g); } + //======================================================================== + // Iterator Property Map Generating Functions contributed by + // Kevin Vanhorn. (see also the property map generating functions + // in boost/property_map.hpp) + + // A helper function for creating a vertex property map out of a + // random access iterator and the internal vertex index map from a + // graph. + template + inline + iterator_property_map< + RandomAccessIterator, + typename property_map::type, + typename std::iterator_traits::value_type, + typename std::iterator_traits::reference + > + make_iterator_vertex_map(RandomAccessIterator iter, const PropertyGraph& g) + { + return make_iterator_property_map(iter, get(vertex_index, g)); + } + + template + inline + iterator_property_map< + typename RandomAccessContainer::iterator, + typename property_map::type, + typename RandomAccessContainer::value_type, + typename RandomAccessContainer::reference + > + make_container_vertex_map(RandomAccessContainer& c, const PropertyGraph& g) + { + assert(c.size() >= num_vertices(g)); + return it_to_vertex_map(c.begin(), g); + } } // namespace boost