123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #ifndef BOOST_GRAPH_DETAIL_GEODESIC_HPP
- #define BOOST_GRAPH_DETAIL_GEODESIC_HPP
- #include <functional>
- #include <boost/config.hpp>
- #include <boost/graph/graph_concepts.hpp>
- #include <boost/graph/numeric_values.hpp>
- #include <boost/concept/assert.hpp>
- namespace boost
- {
- namespace detail {
-
-
- template <typename Graph,
- typename DistanceMap,
- typename Combinator,
- typename Distance>
- inline Distance
- combine_distances(const Graph& g,
- DistanceMap dist,
- Combinator combine,
- Distance init)
- {
- BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
- typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
- typedef typename graph_traits<Graph>::vertex_iterator VertexIterator;
- BOOST_CONCEPT_ASSERT(( ReadablePropertyMapConcept<DistanceMap,Vertex> ));
- BOOST_CONCEPT_ASSERT(( NumericValueConcept<Distance> ));
- typedef numeric_values<Distance> DistanceNumbers;
- BOOST_CONCEPT_ASSERT(( AdaptableBinaryFunction<Combinator,Distance,Distance,Distance> ));
-
-
-
-
- Distance ret = init;
- VertexIterator i, end;
- for(boost::tie(i, end) = vertices(g); i != end; ++i) {
- Vertex v = *i;
- if(get(dist, v) != DistanceNumbers::infinity()) {
- ret = combine(ret, get(dist, v));
- }
- else {
- ret = DistanceNumbers::infinity();
- break;
- }
- }
- return ret;
- }
-
-
- template <typename T>
- struct maximize : public std::binary_function<T, T, T>
- {
- T operator ()(T x, T y) const
- { BOOST_USING_STD_MAX(); return max BOOST_PREVENT_MACRO_SUBSTITUTION (x, y); }
- };
-
-
-
-
- template <typename T>
- struct reciprocal : public std::unary_function<T, T>
- {
- typedef std::unary_function<T, T> function_type;
- typedef typename function_type::result_type result_type;
- typedef typename function_type::argument_type argument_type;
- T operator ()(T t)
- { return T(1) / t; }
- };
- }
- template <typename Graph, typename DistanceType, typename ResultType>
- struct geodesic_measure
- {
- typedef DistanceType distance_type;
- typedef ResultType result_type;
- typedef typename graph_traits<Graph>::vertices_size_type size_type;
- typedef numeric_values<distance_type> distance_values;
- typedef numeric_values<result_type> result_values;
- static inline distance_type infinite_distance()
- { return distance_values::infinity(); }
- static inline result_type infinite_result()
- { return result_values::infinity(); }
- static inline result_type zero_result()
- { return result_values::zero(); }
- };
- }
- #endif
|