File indexing completed on 2025-01-18 09:37:10
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_GRAPH_DETAIL_GEODESIC_HPP
0008 #define BOOST_GRAPH_DETAIL_GEODESIC_HPP
0009
0010 #include <functional>
0011 #include <boost/config.hpp>
0012 #include <boost/graph/graph_concepts.hpp>
0013 #include <boost/graph/numeric_values.hpp>
0014 #include <boost/concept/assert.hpp>
0015
0016
0017
0018 namespace boost
0019 {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 namespace detail
0043 {
0044
0045
0046 template < typename Graph, typename DistanceMap, typename Combinator,
0047 typename Distance >
0048 inline Distance combine_distances(
0049 const Graph& g, DistanceMap dist, Combinator combine, Distance init)
0050 {
0051 BOOST_CONCEPT_ASSERT((VertexListGraphConcept< Graph >));
0052 typedef typename graph_traits< Graph >::vertex_descriptor Vertex;
0053 typedef typename graph_traits< Graph >::vertex_iterator VertexIterator;
0054 BOOST_CONCEPT_ASSERT(
0055 (ReadablePropertyMapConcept< DistanceMap, Vertex >));
0056 BOOST_CONCEPT_ASSERT((NumericValueConcept< Distance >));
0057 typedef numeric_values< Distance > DistanceNumbers;
0058
0059
0060
0061
0062
0063
0064
0065
0066 Distance ret = init;
0067 VertexIterator i, end;
0068 for (boost::tie(i, end) = vertices(g); i != end; ++i)
0069 {
0070 Vertex v = *i;
0071 if (get(dist, v) != DistanceNumbers::infinity())
0072 {
0073 ret = combine(ret, get(dist, v));
0074 }
0075 else
0076 {
0077 ret = DistanceNumbers::infinity();
0078 break;
0079 }
0080 }
0081 return ret;
0082 }
0083
0084
0085
0086 template < typename T > struct maximize
0087 {
0088 typedef T result_type;
0089 typedef T first_argument_type;
0090 typedef T second_argument_type;
0091 T operator()(T x, T y) const
0092 {
0093 BOOST_USING_STD_MAX();
0094 return max BOOST_PREVENT_MACRO_SUBSTITUTION(x, y);
0095 }
0096 };
0097
0098
0099
0100
0101
0102 template < typename T > struct reciprocal
0103 {
0104 typedef T result_type;
0105 typedef T argument_type;
0106 T operator()(T t) { return T(1) / t; }
0107 };
0108 }
0109
0110
0111
0112
0113 template < typename Graph, typename DistanceType, typename ResultType >
0114 struct geodesic_measure
0115 {
0116 typedef DistanceType distance_type;
0117 typedef ResultType result_type;
0118 typedef typename graph_traits< Graph >::vertices_size_type size_type;
0119
0120 typedef numeric_values< distance_type > distance_values;
0121 typedef numeric_values< result_type > result_values;
0122
0123 static inline distance_type infinite_distance()
0124 {
0125 return distance_values::infinity();
0126 }
0127
0128 static inline result_type infinite_result()
0129 {
0130 return result_values::infinity();
0131 }
0132
0133 static inline result_type zero_result() { return result_values::zero(); }
0134 };
0135
0136 }
0137
0138 #endif