123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef BOOST_GRAPH_PARALLEL_PROPERTIES_HPP
- #define BOOST_GRAPH_PARALLEL_PROPERTIES_HPP
- #ifndef BOOST_GRAPH_USE_MPI
- #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
- #endif
- #include <boost/graph/properties.hpp>
- #include <boost/property_map/parallel/distributed_property_map.hpp>
- namespace boost {
-
-
- template<typename Property>
- struct property_reduce
- {
- template<typename Value>
- class apply : public parallel::basic_reduce<Value> {};
- };
-
-
- template<>
- struct property_reduce<vertex_color_t>
- {
- template<typename Color>
- class apply
- {
- typedef color_traits<Color> traits;
-
- public:
- BOOST_STATIC_CONSTANT(bool, non_default_resolver = true);
- template<typename Key>
- Color operator()(const Key&) const { return traits::white(); }
-
- template<typename Key>
- Color operator()(const Key&, Color local, Color remote) const {
- if (local == traits::white()) return remote;
- else if (remote == traits::black()) return remote;
- else return local;
- }
- };
- };
-
- template<>
- struct property_reduce<vertex_distance_t>
- {
- template<typename T>
- class apply
- {
- public:
- BOOST_STATIC_CONSTANT(bool, non_default_resolver = true);
- template<typename Key>
- T operator()(const Key&) const { return (std::numeric_limits<T>::max)(); }
- template<typename Key>
- T operator()(const Key&, T x, T y) const { return x < y? x : y; }
- };
- };
- template<>
- struct property_reduce<vertex_predecessor_t>
- {
- template<typename T>
- class apply
- {
- public:
- BOOST_STATIC_CONSTANT(bool, non_default_resolver = true);
- template<typename Key>
- T operator()(Key key) const { return key; }
- template<typename Key>
- T operator()(Key key, T, T y) const { return y; }
- };
- };
- template<typename Property, typename PropertyMap>
- inline void set_property_map_role(Property p, PropertyMap pm)
- {
- typedef typename property_traits<PropertyMap>::value_type value_type;
- typedef property_reduce<Property> property_red;
- typedef typename property_red::template apply<value_type> reduce;
- pm.set_reduce(reduce());
- }
- }
- #endif
|