2 // (C) Copyright François Faure, iMAGIS-GRAVIR / UJF, 2001.
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
9 // 03 May 2001 Jeremy Siek
10 // Generalized the property map iterator and moved that
11 // part to boost/property_map.hpp. Also modified to
12 // differentiate between const/mutable graphs and
13 // added a workaround to avoid partial specialization.
15 // 02 May 2001 François Faure
18 #ifndef BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
19 #define BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
21 #include <boost/property_map_iterator.hpp>
22 #include <boost/graph/properties.hpp>
23 #include <boost/pending/ct_if.hpp>
24 #include <boost/type_traits/same_traits.hpp>
28 //======================================================================
29 // graph property iterator range
31 template <class Graph, class PropertyTag>
32 class graph_property_iter_range {
33 typedef typename property_map<Graph, PropertyTag>::type map_type;
34 typedef typename property_map<Graph, PropertyTag>::const_type
36 typedef typename property_kind<PropertyTag>::type Kind;
37 typedef typename ct_if<is_same<Kind, vertex_property_tag>::value,
38 typename graph_traits<Graph>::vertex_iterator,
39 typename graph_traits<Graph>::edge_iterator>::type iter;
41 typedef typename property_map_iterator_generator<map_type, iter>::type
43 typedef typename property_map_iterator_generator<const_map_type, iter>
44 ::type const_iterator;
45 typedef std::pair<iterator, iterator> type;
46 typedef std::pair<const_iterator, const_iterator> const_type;
51 template<class Graph,class Tag>
52 typename graph_property_iter_range<Graph,Tag>::type
53 get_property_iter_range_kind(Graph& graph, const Tag& tag,
54 const vertex_property_tag& )
56 typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
57 return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
58 iter(vertices(graph).second, get(tag, graph)));
61 template<class Graph,class Tag>
62 typename graph_property_iter_range<Graph,Tag>::const_type
63 get_property_iter_range_kind(const Graph& graph, const Tag& tag,
64 const vertex_property_tag& )
66 typedef typename graph_property_iter_range<Graph,Tag>
67 ::const_iterator iter;
68 return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
69 iter(vertices(graph).second, get(tag, graph)));
73 template<class Graph,class Tag>
74 typename graph_property_iter_range<Graph,Tag>::type
75 get_property_iter_range_kind(Graph& graph, const Tag& tag,
76 const edge_property_tag& )
78 typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
79 return std::make_pair(iter(edges(graph).first, get(tag, graph)),
80 iter(edges(graph).second, get(tag, graph)));
83 template<class Graph,class Tag>
84 typename graph_property_iter_range<Graph,Tag>::const_type
85 get_property_iter_range_kind(const Graph& graph, const Tag& tag,
86 const edge_property_tag& )
88 typedef typename graph_property_iter_range<Graph,Tag>
89 ::const_iterator iter;
90 return std::make_pair(iter(edges(graph).first, get(tag, graph)),
91 iter(edges(graph).second, get(tag, graph)));
96 //======================================================================
97 // get an iterator range of properties
99 template<class Graph, class Tag>
100 typename graph_property_iter_range<Graph, Tag>::type
101 get_property_iter_range(Graph& graph, const Tag& tag)
103 typedef typename property_kind<Tag>::type Kind;
104 return detail::get_property_iter_range_kind(graph, tag, Kind());
107 template<class Graph, class Tag>
108 typename graph_property_iter_range<Graph, Tag>::const_type
109 get_property_iter_range(const Graph& graph, const Tag& tag)
111 typedef typename property_kind<Tag>::type Kind;
112 return detail::get_property_iter_range_kind(graph, tag, Kind());
118 #endif // BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP