File indexing completed on 2025-01-30 09:43:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
0019 #define BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
0020
0021 #include <boost/property_map/property_map_iterator.hpp>
0022 #include <boost/graph/properties.hpp>
0023 #include <boost/mpl/if.hpp>
0024 #include <boost/type_traits/same_traits.hpp>
0025
0026 namespace boost
0027 {
0028
0029
0030
0031
0032 template < class Graph, class PropertyTag > class graph_property_iter_range
0033 {
0034 typedef typename property_map< Graph, PropertyTag >::type map_type;
0035 typedef
0036 typename property_map< Graph, PropertyTag >::const_type const_map_type;
0037 typedef typename property_kind< PropertyTag >::type Kind;
0038 typedef typename mpl::if_c< is_same< Kind, vertex_property_tag >::value,
0039 typename graph_traits< Graph >::vertex_iterator,
0040 typename graph_traits< Graph >::edge_iterator >::type iter;
0041
0042 public:
0043 typedef typename property_map_iterator_generator< map_type, iter >::type
0044 iterator;
0045 typedef
0046 typename property_map_iterator_generator< const_map_type, iter >::type
0047 const_iterator;
0048 typedef std::pair< iterator, iterator > type;
0049 typedef std::pair< const_iterator, const_iterator > const_type;
0050 };
0051
0052 namespace detail
0053 {
0054
0055 template < class Graph, class Tag >
0056 typename graph_property_iter_range< Graph, Tag >::type
0057 get_property_iter_range_kind(
0058 Graph& graph, const Tag& tag, const vertex_property_tag&)
0059 {
0060 typedef typename graph_property_iter_range< Graph, Tag >::iterator iter;
0061 return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
0062 iter(vertices(graph).second, get(tag, graph)));
0063 }
0064
0065 template < class Graph, class Tag >
0066 typename graph_property_iter_range< Graph, Tag >::const_type
0067 get_property_iter_range_kind(
0068 const Graph& graph, const Tag& tag, const vertex_property_tag&)
0069 {
0070 typedef typename graph_property_iter_range< Graph, Tag >::const_iterator
0071 iter;
0072 return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
0073 iter(vertices(graph).second, get(tag, graph)));
0074 }
0075
0076 template < class Graph, class Tag >
0077 typename graph_property_iter_range< Graph, Tag >::type
0078 get_property_iter_range_kind(
0079 Graph& graph, const Tag& tag, const edge_property_tag&)
0080 {
0081 typedef typename graph_property_iter_range< Graph, Tag >::iterator iter;
0082 return std::make_pair(iter(edges(graph).first, get(tag, graph)),
0083 iter(edges(graph).second, get(tag, graph)));
0084 }
0085
0086 template < class Graph, class Tag >
0087 typename graph_property_iter_range< Graph, Tag >::const_type
0088 get_property_iter_range_kind(
0089 const Graph& graph, const Tag& tag, const edge_property_tag&)
0090 {
0091 typedef typename graph_property_iter_range< Graph, Tag >::const_iterator
0092 iter;
0093 return std::make_pair(iter(edges(graph).first, get(tag, graph)),
0094 iter(edges(graph).second, get(tag, graph)));
0095 }
0096
0097 }
0098
0099
0100
0101
0102 template < class Graph, class Tag >
0103 typename graph_property_iter_range< Graph, Tag >::type get_property_iter_range(
0104 Graph& graph, const Tag& tag)
0105 {
0106 typedef typename property_kind< Tag >::type Kind;
0107 return detail::get_property_iter_range_kind(graph, tag, Kind());
0108 }
0109
0110 template < class Graph, class Tag >
0111 typename graph_property_iter_range< Graph, Tag >::const_type
0112 get_property_iter_range(const Graph& graph, const Tag& tag)
0113 {
0114 typedef typename property_kind< Tag >::type Kind;
0115 return detail::get_property_iter_range_kind(graph, tag, Kind());
0116 }
0117
0118 }
0119
0120 #endif