[857] | 1 | //=======================================================================
|
---|
| 2 | // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
|
---|
| 3 | // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
|
---|
| 4 | //
|
---|
| 5 | // Distributed under the Boost Software License, Version 1.0. (See
|
---|
| 6 | // accompanying file LICENSE_1_0.txt or copy at
|
---|
| 7 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 8 | //=======================================================================
|
---|
| 9 |
|
---|
| 10 | #ifndef BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP
|
---|
| 11 | #define BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP
|
---|
| 12 |
|
---|
| 13 | #include <boost/graph/properties.hpp>
|
---|
| 14 |
|
---|
| 15 | namespace boost {
|
---|
| 16 |
|
---|
| 17 | struct distance_compare_t { };
|
---|
| 18 | struct distance_combine_t { };
|
---|
| 19 | struct distance_inf_t { };
|
---|
| 20 | struct distance_zero_t { };
|
---|
| 21 | struct buffer_param_t { };
|
---|
| 22 | struct edge_copy_t { };
|
---|
| 23 | struct vertex_copy_t { };
|
---|
| 24 | struct vertex_isomorphism_t { };
|
---|
| 25 | struct vertex_invariant_t { };
|
---|
| 26 | struct vertex_invariant1_t { };
|
---|
| 27 | struct vertex_invariant2_t { };
|
---|
| 28 | struct edge_compare_t { };
|
---|
| 29 | struct vertex_max_invariant_t { };
|
---|
| 30 | struct orig_to_copy_t { };
|
---|
| 31 | struct root_vertex_t { };
|
---|
| 32 | struct attractive_force_t { };
|
---|
| 33 | struct repulsive_force_t { };
|
---|
| 34 | struct force_pairs_t { };
|
---|
| 35 | struct cooling_t { };
|
---|
| 36 | struct vertex_displacement_t { };
|
---|
| 37 | struct iterations_t { };
|
---|
| 38 | struct diameter_range_t { };
|
---|
| 39 | struct learning_constant_range_t { };
|
---|
| 40 |
|
---|
| 41 | namespace detail {
|
---|
| 42 | template <class T>
|
---|
| 43 | struct wrap_ref {
|
---|
| 44 | wrap_ref(T& r) : ref(r) {}
|
---|
| 45 | T& ref;
|
---|
| 46 | };
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | template <typename T, typename Tag, typename Base = no_property>
|
---|
| 50 | struct bgl_named_params : public Base
|
---|
| 51 | {
|
---|
| 52 | typedef bgl_named_params self;
|
---|
| 53 | typedef Base next_type;
|
---|
| 54 | typedef Tag tag_type;
|
---|
| 55 | typedef T value_type;
|
---|
| 56 | bgl_named_params(T v) : m_value(v) { }
|
---|
| 57 | bgl_named_params(T v, const Base& b) : Base(b), m_value(v) { }
|
---|
| 58 | T m_value;
|
---|
| 59 |
|
---|
| 60 | template <typename WeightMap>
|
---|
| 61 | bgl_named_params<WeightMap, edge_weight_t, self>
|
---|
| 62 | weight_map(const WeightMap& pmap) const {
|
---|
| 63 | typedef bgl_named_params<WeightMap, edge_weight_t, self> Params;
|
---|
| 64 | return Params(pmap, *this);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | template <typename WeightMap>
|
---|
| 68 | bgl_named_params<WeightMap, edge_weight2_t, self>
|
---|
| 69 | weight_map2(const WeightMap& pmap) const {
|
---|
| 70 | typedef bgl_named_params<WeightMap, edge_weight2_t, self> Params;
|
---|
| 71 | return Params(pmap, *this);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | template <typename DistanceMap>
|
---|
| 75 | bgl_named_params<DistanceMap, vertex_distance_t, self>
|
---|
| 76 | distance_map(const DistanceMap& pmap) const {
|
---|
| 77 | typedef bgl_named_params<DistanceMap, vertex_distance_t, self> Params;
|
---|
| 78 | return Params(pmap, *this);
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | template <typename PredecessorMap>
|
---|
| 82 | bgl_named_params<PredecessorMap, vertex_predecessor_t, self>
|
---|
| 83 | predecessor_map(const PredecessorMap& pmap) const {
|
---|
| 84 | typedef bgl_named_params<PredecessorMap, vertex_predecessor_t, self>
|
---|
| 85 | Params;
|
---|
| 86 | return Params(pmap, *this);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | template <typename RankMap>
|
---|
| 90 | bgl_named_params<RankMap, vertex_rank_t, self>
|
---|
| 91 | rank_map(const RankMap& pmap) const {
|
---|
| 92 | typedef bgl_named_params<RankMap, vertex_rank_t, self>
|
---|
| 93 | Params;
|
---|
| 94 | return Params(pmap, *this);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | template <typename RootMap>
|
---|
| 98 | bgl_named_params<RootMap, vertex_root_t, self>
|
---|
| 99 | root_map(const RootMap& pmap) const {
|
---|
| 100 | typedef bgl_named_params<RootMap, vertex_root_t, self>
|
---|
| 101 | Params;
|
---|
| 102 | return Params(pmap, *this);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | template <typename Vertex>
|
---|
| 106 | bgl_named_params<Vertex, root_vertex_t, self>
|
---|
| 107 | root_vertex(const Vertex& r) const {
|
---|
| 108 | typedef bgl_named_params<Vertex, root_vertex_t, self> Params;
|
---|
| 109 | return Params(r, *this);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | template <typename EdgeCentralityMap>
|
---|
| 113 | bgl_named_params<EdgeCentralityMap, edge_centrality_t, self>
|
---|
| 114 | edge_centrality_map(const EdgeCentralityMap& r) const {
|
---|
| 115 | typedef bgl_named_params<EdgeCentralityMap, edge_centrality_t, self> Params;
|
---|
| 116 | return Params(r, *this);
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | template <typename CentralityMap>
|
---|
| 120 | bgl_named_params<CentralityMap, vertex_centrality_t, self>
|
---|
| 121 | centrality_map(const CentralityMap& r) const {
|
---|
| 122 | typedef bgl_named_params<CentralityMap, vertex_centrality_t, self> Params;
|
---|
| 123 | return Params(r, *this);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | template <typename ColorMap>
|
---|
| 127 | bgl_named_params<ColorMap, vertex_color_t, self>
|
---|
| 128 | color_map(const ColorMap& pmap) const {
|
---|
| 129 | typedef bgl_named_params<ColorMap, vertex_color_t, self> Params;
|
---|
| 130 | return Params(pmap, *this);
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | template <typename ColorMap>
|
---|
| 134 | bgl_named_params<ColorMap, vertex_color_t, self>
|
---|
| 135 | vertex_color_map(const ColorMap& pmap) const {
|
---|
| 136 | typedef bgl_named_params<ColorMap, vertex_color_t, self> Params;
|
---|
| 137 | return Params(pmap, *this);
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | template <typename ColorMap>
|
---|
| 141 | bgl_named_params<ColorMap, edge_color_t, self>
|
---|
| 142 | edge_color_map(const ColorMap& pmap) const {
|
---|
| 143 | typedef bgl_named_params<ColorMap, edge_color_t, self> Params;
|
---|
| 144 | return Params(pmap, *this);
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | template <typename CapacityMap>
|
---|
| 148 | bgl_named_params<CapacityMap, edge_capacity_t, self>
|
---|
| 149 | capacity_map(CapacityMap pmap) {
|
---|
| 150 | typedef bgl_named_params<CapacityMap, edge_capacity_t, self> Params;
|
---|
| 151 | return Params(pmap, *this);
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | template <typename Residual_CapacityMap>
|
---|
| 155 | bgl_named_params<Residual_CapacityMap, edge_residual_capacity_t, self>
|
---|
| 156 | residual_capacity_map(Residual_CapacityMap pmap) {
|
---|
| 157 | typedef bgl_named_params<Residual_CapacityMap,
|
---|
| 158 | edge_residual_capacity_t, self>
|
---|
| 159 | Params;
|
---|
| 160 | return Params(pmap, *this);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | template <typename ReverseMap>
|
---|
| 164 | bgl_named_params<ReverseMap, edge_reverse_t, self>
|
---|
| 165 | reverse_edge_map(ReverseMap pmap) {
|
---|
| 166 | typedef bgl_named_params<ReverseMap,
|
---|
| 167 | edge_reverse_t, self>
|
---|
| 168 | Params;
|
---|
| 169 | return Params(pmap, *this);
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | template <typename DiscoverTimeMap>
|
---|
| 173 | bgl_named_params<DiscoverTimeMap, vertex_discover_time_t, self>
|
---|
| 174 | discover_time_map(const DiscoverTimeMap& pmap) const {
|
---|
| 175 | typedef bgl_named_params<DiscoverTimeMap, vertex_discover_time_t, self>
|
---|
| 176 | Params;
|
---|
| 177 | return Params(pmap, *this);
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | template <typename IndexMap>
|
---|
| 181 | bgl_named_params<IndexMap, vertex_index_t, self>
|
---|
| 182 | vertex_index_map(const IndexMap& pmap) const {
|
---|
| 183 | typedef bgl_named_params<IndexMap, vertex_index_t, self> Params;
|
---|
| 184 | return Params(pmap, *this);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | template <typename IndexMap>
|
---|
| 188 | bgl_named_params<IndexMap, vertex_index1_t, self>
|
---|
| 189 | vertex_index1_map(const IndexMap& pmap) const {
|
---|
| 190 | typedef bgl_named_params<IndexMap, vertex_index1_t, self> Params;
|
---|
| 191 | return Params(pmap, *this);
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | template <typename IndexMap>
|
---|
| 195 | bgl_named_params<IndexMap, vertex_index2_t, self>
|
---|
| 196 | vertex_index2_map(const IndexMap& pmap) const {
|
---|
| 197 | typedef bgl_named_params<IndexMap, vertex_index2_t, self> Params;
|
---|
| 198 | return Params(pmap, *this);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | template <typename Visitor>
|
---|
| 202 | bgl_named_params<Visitor, graph_visitor_t, self>
|
---|
| 203 | visitor(const Visitor& vis) const {
|
---|
| 204 | typedef bgl_named_params<Visitor, graph_visitor_t, self> Params;
|
---|
| 205 | return Params(vis, *this);
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | template <typename Compare>
|
---|
| 209 | bgl_named_params<Compare, distance_compare_t, self>
|
---|
| 210 | distance_compare(Compare cmp) const {
|
---|
| 211 | typedef bgl_named_params<Compare, distance_compare_t, self> Params;
|
---|
| 212 | return Params(cmp, *this);
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | template <typename Combine>
|
---|
| 216 | bgl_named_params<Combine, distance_combine_t, self>
|
---|
| 217 | distance_combine(Combine cmb) const {
|
---|
| 218 | typedef bgl_named_params<Combine, distance_combine_t, self> Params;
|
---|
| 219 | return Params(cmb, *this);
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | template <typename Init>
|
---|
| 223 | bgl_named_params<Init, distance_inf_t, self>
|
---|
| 224 | distance_inf(Init init) const {
|
---|
| 225 | typedef bgl_named_params<Init, distance_inf_t, self> Params;
|
---|
| 226 | return Params(init, *this);
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | template <typename Init>
|
---|
| 230 | bgl_named_params<Init, distance_zero_t, self>
|
---|
| 231 | distance_zero(Init init) const {
|
---|
| 232 | typedef bgl_named_params<Init, distance_zero_t, self> Params;
|
---|
| 233 | return Params(init, *this);
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | template <typename Buffer>
|
---|
| 237 | bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t, self>
|
---|
| 238 | buffer(Buffer& b) const {
|
---|
| 239 | typedef bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t, self>
|
---|
| 240 | Params;
|
---|
| 241 | return Params(detail::wrap_ref<Buffer>(b), *this);
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | template <typename Copier>
|
---|
| 245 | bgl_named_params<Copier, edge_copy_t, self>
|
---|
| 246 | edge_copy(const Copier& c) const {
|
---|
| 247 | typedef bgl_named_params<Copier, edge_copy_t, self> Params;
|
---|
| 248 | return Params(c, *this);
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | template <typename Copier>
|
---|
| 252 | bgl_named_params<Copier, vertex_copy_t, self>
|
---|
| 253 | vertex_copy(const Copier& c) const {
|
---|
| 254 | typedef bgl_named_params<Copier, vertex_copy_t, self> Params;
|
---|
| 255 | return Params(c, *this);
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | template <typename Orig2CopyMap>
|
---|
| 259 | bgl_named_params<Orig2CopyMap, orig_to_copy_t, self>
|
---|
| 260 | orig_to_copy(const Orig2CopyMap& c) const {
|
---|
| 261 | typedef bgl_named_params<Orig2CopyMap, orig_to_copy_t, self> Params;
|
---|
| 262 | return Params(c, *this);
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | template <typename IsoMap>
|
---|
| 266 | bgl_named_params<IsoMap, vertex_isomorphism_t, self>
|
---|
| 267 | isomorphism_map(const IsoMap& c) const {
|
---|
| 268 | typedef bgl_named_params<IsoMap, vertex_isomorphism_t, self> Params;
|
---|
| 269 | return Params(c, *this);
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 | template <typename VertexInvar>
|
---|
| 273 | bgl_named_params<VertexInvar, vertex_invariant_t, self>
|
---|
| 274 | vertex_invariant(const VertexInvar& c) const {
|
---|
| 275 | typedef bgl_named_params<VertexInvar, vertex_invariant_t, self> Params;
|
---|
| 276 | return Params(c, *this);
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | template <typename VertexDisplacement>
|
---|
| 280 | bgl_named_params<VertexDisplacement, vertex_displacement_t, self>
|
---|
| 281 | displacement_map(const VertexDisplacement& c) const {
|
---|
| 282 | typedef bgl_named_params<VertexDisplacement, vertex_displacement_t, self> Params;
|
---|
| 283 | return Params(c, *this);
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 | template <typename AttractiveForce>
|
---|
| 287 | bgl_named_params<AttractiveForce, attractive_force_t, self>
|
---|
| 288 | attractive_force(const AttractiveForce& c) {
|
---|
| 289 | typedef bgl_named_params<AttractiveForce, attractive_force_t, self> Params;
|
---|
| 290 | return Params(c, *this);
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | template <typename RepulsiveForce>
|
---|
| 294 | bgl_named_params<RepulsiveForce, repulsive_force_t, self>
|
---|
| 295 | repulsive_force(const RepulsiveForce& c) {
|
---|
| 296 | typedef bgl_named_params<RepulsiveForce, repulsive_force_t, self> Params;
|
---|
| 297 | return Params(c, *this);
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | template <typename ForcePairs>
|
---|
| 301 | bgl_named_params<ForcePairs, force_pairs_t, self>
|
---|
| 302 | force_pairs(const ForcePairs& c) {
|
---|
| 303 | typedef bgl_named_params<ForcePairs, force_pairs_t, self> Params;
|
---|
| 304 | return Params(c, *this);
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | template <typename Cooling>
|
---|
| 308 | bgl_named_params<Cooling, cooling_t, self>
|
---|
| 309 | cooling(const Cooling& c) {
|
---|
| 310 | typedef bgl_named_params<Cooling, cooling_t, self> Params;
|
---|
| 311 | return Params(c, *this);
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | template <typename TP>
|
---|
| 315 | bgl_named_params<TP, iterations_t, self>
|
---|
| 316 | iterations(const TP& c) {
|
---|
| 317 | typedef bgl_named_params<TP, iterations_t, self> Params;
|
---|
| 318 | return Params(c, *this);
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | template<typename TP>
|
---|
| 322 | bgl_named_params<std::pair<TP, TP>, diameter_range_t, self>
|
---|
| 323 | diameter_range(const std::pair<TP, TP>& c) {
|
---|
| 324 | typedef bgl_named_params<std::pair<TP, TP>, diameter_range_t, self> Params;
|
---|
| 325 | return Params(c, *this);
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | template<typename TP>
|
---|
| 329 | bgl_named_params<std::pair<TP, TP>, learning_constant_range_t, self>
|
---|
| 330 | learning_constant_range(const std::pair<TP, TP>& c) {
|
---|
| 331 | typedef bgl_named_params<std::pair<TP, TP>, learning_constant_range_t, self>
|
---|
| 332 | Params;
|
---|
| 333 | return Params(c, *this);
|
---|
| 334 | }
|
---|
| 335 | };
|
---|
| 336 |
|
---|
| 337 | template <typename WeightMap>
|
---|
| 338 | bgl_named_params<WeightMap, edge_weight_t>
|
---|
| 339 | weight_map(WeightMap pmap) {
|
---|
| 340 | typedef bgl_named_params<WeightMap, edge_weight_t> Params;
|
---|
| 341 | return Params(pmap);
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | template <typename WeightMap>
|
---|
| 345 | bgl_named_params<WeightMap, edge_weight2_t>
|
---|
| 346 | weight_map2(WeightMap pmap) {
|
---|
| 347 | typedef bgl_named_params<WeightMap, edge_weight2_t> Params;
|
---|
| 348 | return Params(pmap);
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | template <typename DistanceMap>
|
---|
| 352 | bgl_named_params<DistanceMap, vertex_distance_t>
|
---|
| 353 | distance_map(DistanceMap pmap) {
|
---|
| 354 | typedef bgl_named_params<DistanceMap, vertex_distance_t> Params;
|
---|
| 355 | return Params(pmap);
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | template <typename PredecessorMap>
|
---|
| 359 | bgl_named_params<PredecessorMap, vertex_predecessor_t>
|
---|
| 360 | predecessor_map(PredecessorMap pmap) {
|
---|
| 361 | typedef bgl_named_params<PredecessorMap, vertex_predecessor_t> Params;
|
---|
| 362 | return Params(pmap);
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | template <typename RankMap>
|
---|
| 366 | bgl_named_params<RankMap, vertex_rank_t>
|
---|
| 367 | rank_map(RankMap pmap) {
|
---|
| 368 | typedef bgl_named_params<RankMap, vertex_rank_t> Params;
|
---|
| 369 | return Params(pmap);
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | template <typename RootMap>
|
---|
| 373 | bgl_named_params<RootMap, vertex_root_t>
|
---|
| 374 | root_map(RootMap pmap) {
|
---|
| 375 | typedef bgl_named_params<RootMap, vertex_root_t> Params;
|
---|
| 376 | return Params(pmap);
|
---|
| 377 | }
|
---|
| 378 |
|
---|
| 379 | template <typename Vertex>
|
---|
| 380 | bgl_named_params<Vertex, root_vertex_t>
|
---|
| 381 | root_vertex(const Vertex& r) {
|
---|
| 382 | typedef bgl_named_params<Vertex, root_vertex_t> Params;
|
---|
| 383 | return Params(r);
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | template <typename EdgeCentralityMap>
|
---|
| 387 | bgl_named_params<EdgeCentralityMap, edge_centrality_t>
|
---|
| 388 | edge_centrality_map(const EdgeCentralityMap& r) {
|
---|
| 389 | typedef bgl_named_params<EdgeCentralityMap, edge_centrality_t> Params;
|
---|
| 390 | return Params(r);
|
---|
| 391 | }
|
---|
| 392 |
|
---|
| 393 | template <typename CentralityMap>
|
---|
| 394 | bgl_named_params<CentralityMap, vertex_centrality_t>
|
---|
| 395 | centrality_map(const CentralityMap& r) {
|
---|
| 396 | typedef bgl_named_params<CentralityMap, vertex_centrality_t> Params;
|
---|
| 397 | return Params(r);
|
---|
| 398 | }
|
---|
| 399 |
|
---|
| 400 | template <typename ColorMap>
|
---|
| 401 | bgl_named_params<ColorMap, vertex_color_t>
|
---|
| 402 | color_map(ColorMap pmap) {
|
---|
| 403 | typedef bgl_named_params<ColorMap, vertex_color_t> Params;
|
---|
| 404 | return Params(pmap);
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 | template <typename CapacityMap>
|
---|
| 408 | bgl_named_params<CapacityMap, edge_capacity_t>
|
---|
| 409 | capacity_map(CapacityMap pmap) {
|
---|
| 410 | typedef bgl_named_params<CapacityMap, edge_capacity_t> Params;
|
---|
| 411 | return Params(pmap);
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | template <typename Residual_CapacityMap>
|
---|
| 415 | bgl_named_params<Residual_CapacityMap, edge_residual_capacity_t>
|
---|
| 416 | residual_capacity_map(Residual_CapacityMap pmap) {
|
---|
| 417 | typedef bgl_named_params<Residual_CapacityMap, edge_residual_capacity_t>
|
---|
| 418 | Params;
|
---|
| 419 | return Params(pmap);
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | template <typename ReverseMap>
|
---|
| 423 | bgl_named_params<ReverseMap, edge_reverse_t>
|
---|
| 424 | reverse_edge_map(ReverseMap pmap) {
|
---|
| 425 | typedef bgl_named_params<ReverseMap, edge_reverse_t>
|
---|
| 426 | Params;
|
---|
| 427 | return Params(pmap);
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | template <typename DiscoverTimeMap>
|
---|
| 431 | bgl_named_params<DiscoverTimeMap, vertex_discover_time_t>
|
---|
| 432 | discover_time_map(DiscoverTimeMap pmap) {
|
---|
| 433 | typedef bgl_named_params<DiscoverTimeMap, vertex_discover_time_t> Params;
|
---|
| 434 | return Params(pmap);
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | template <typename IndexMap>
|
---|
| 438 | bgl_named_params<IndexMap, vertex_index_t>
|
---|
| 439 | vertex_index_map(IndexMap pmap) {
|
---|
| 440 | typedef bgl_named_params<IndexMap, vertex_index_t> Params;
|
---|
| 441 | return Params(pmap);
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | template <typename IndexMap>
|
---|
| 445 | bgl_named_params<IndexMap, vertex_index1_t>
|
---|
| 446 | vertex_index1_map(const IndexMap& pmap) {
|
---|
| 447 | typedef bgl_named_params<IndexMap, vertex_index1_t> Params;
|
---|
| 448 | return Params(pmap);
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | template <typename IndexMap>
|
---|
| 452 | bgl_named_params<IndexMap, vertex_index2_t>
|
---|
| 453 | vertex_index2_map(const IndexMap& pmap) {
|
---|
| 454 | typedef bgl_named_params<IndexMap, vertex_index2_t> Params;
|
---|
| 455 | return Params(pmap);
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | template <typename Visitor>
|
---|
| 459 | bgl_named_params<Visitor, graph_visitor_t>
|
---|
| 460 | visitor(const Visitor& vis) {
|
---|
| 461 | typedef bgl_named_params<Visitor, graph_visitor_t> Params;
|
---|
| 462 | return Params(vis);
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 | template <typename Compare>
|
---|
| 466 | bgl_named_params<Compare, distance_compare_t>
|
---|
| 467 | distance_compare(Compare cmp) {
|
---|
| 468 | typedef bgl_named_params<Compare, distance_compare_t> Params;
|
---|
| 469 | return Params(cmp);
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | template <typename Combine>
|
---|
| 473 | bgl_named_params<Combine, distance_combine_t>
|
---|
| 474 | distance_combine(Combine cmb) {
|
---|
| 475 | typedef bgl_named_params<Combine, distance_combine_t> Params;
|
---|
| 476 | return Params(cmb);
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 | template <typename Init>
|
---|
| 480 | bgl_named_params<Init, distance_inf_t>
|
---|
| 481 | distance_inf(Init init) {
|
---|
| 482 | typedef bgl_named_params<Init, distance_inf_t> Params;
|
---|
| 483 | return Params(init);
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | template <typename Init>
|
---|
| 487 | bgl_named_params<Init, distance_zero_t>
|
---|
| 488 | distance_zero(Init init) {
|
---|
| 489 | typedef bgl_named_params<Init, distance_zero_t> Params;
|
---|
| 490 | return Params(init);
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 | template <typename Buffer>
|
---|
| 494 | bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t>
|
---|
| 495 | buffer(Buffer& b) {
|
---|
| 496 | typedef bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t> Params;
|
---|
| 497 | return Params(detail::wrap_ref<Buffer>(b));
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | template <typename Copier>
|
---|
| 501 | bgl_named_params<Copier, edge_copy_t>
|
---|
| 502 | edge_copy(const Copier& c) {
|
---|
| 503 | typedef bgl_named_params<Copier, edge_copy_t> Params;
|
---|
| 504 | return Params(c);
|
---|
| 505 | }
|
---|
| 506 |
|
---|
| 507 | template <typename Copier>
|
---|
| 508 | bgl_named_params<Copier, vertex_copy_t>
|
---|
| 509 | vertex_copy(const Copier& c) {
|
---|
| 510 | typedef bgl_named_params<Copier, vertex_copy_t> Params;
|
---|
| 511 | return Params(c);
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | template <typename Orig2CopyMap>
|
---|
| 515 | bgl_named_params<Orig2CopyMap, orig_to_copy_t>
|
---|
| 516 | orig_to_copy(const Orig2CopyMap& c) {
|
---|
| 517 | typedef bgl_named_params<Orig2CopyMap, orig_to_copy_t> Params;
|
---|
| 518 | return Params(c);
|
---|
| 519 | }
|
---|
| 520 |
|
---|
| 521 | template <typename IsoMap>
|
---|
| 522 | bgl_named_params<IsoMap, vertex_isomorphism_t>
|
---|
| 523 | isomorphism_map(const IsoMap& c) {
|
---|
| 524 | typedef bgl_named_params<IsoMap, vertex_isomorphism_t> Params;
|
---|
| 525 | return Params(c);
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 | template <typename VertexInvar>
|
---|
| 529 | bgl_named_params<VertexInvar, vertex_invariant_t>
|
---|
| 530 | vertex_invariant(const VertexInvar& c) {
|
---|
| 531 | typedef bgl_named_params<VertexInvar, vertex_invariant_t> Params;
|
---|
| 532 | return Params(c);
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | template <typename VertexDisplacement>
|
---|
| 536 | bgl_named_params<VertexDisplacement, vertex_displacement_t>
|
---|
| 537 | displacement_map(const VertexDisplacement& c) {
|
---|
| 538 | typedef bgl_named_params<VertexDisplacement, vertex_displacement_t> Params;
|
---|
| 539 | return Params(c);
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 | template <typename AttractiveForce>
|
---|
| 543 | bgl_named_params<AttractiveForce, attractive_force_t>
|
---|
| 544 | attractive_force(const AttractiveForce& c) {
|
---|
| 545 | typedef bgl_named_params<AttractiveForce, attractive_force_t> Params;
|
---|
| 546 | return Params(c);
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 | template <typename RepulsiveForce>
|
---|
| 550 | bgl_named_params<RepulsiveForce, repulsive_force_t>
|
---|
| 551 | repulsive_force(const RepulsiveForce& c) {
|
---|
| 552 | typedef bgl_named_params<RepulsiveForce, repulsive_force_t> Params;
|
---|
| 553 | return Params(c);
|
---|
| 554 | }
|
---|
| 555 |
|
---|
| 556 | template <typename ForcePairs>
|
---|
| 557 | bgl_named_params<ForcePairs, force_pairs_t>
|
---|
| 558 | force_pairs(const ForcePairs& c) {
|
---|
| 559 | typedef bgl_named_params<ForcePairs, force_pairs_t> Params;
|
---|
| 560 | return Params(c);
|
---|
| 561 | }
|
---|
| 562 |
|
---|
| 563 | template <typename Cooling>
|
---|
| 564 | bgl_named_params<Cooling, cooling_t>
|
---|
| 565 | cooling(const Cooling& c) {
|
---|
| 566 | typedef bgl_named_params<Cooling, cooling_t> Params;
|
---|
| 567 | return Params(c);
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 | template <typename T>
|
---|
| 571 | bgl_named_params<T, iterations_t>
|
---|
| 572 | iterations(const T& c) {
|
---|
| 573 | typedef bgl_named_params<T, iterations_t> Params;
|
---|
| 574 | return Params(c);
|
---|
| 575 | }
|
---|
| 576 |
|
---|
| 577 | template<typename T>
|
---|
| 578 | bgl_named_params<std::pair<T, T>, diameter_range_t>
|
---|
| 579 | diameter_range(const std::pair<T, T>& c) {
|
---|
| 580 | typedef bgl_named_params<std::pair<T, T>, diameter_range_t> Params;
|
---|
| 581 | return Params(c);
|
---|
| 582 | }
|
---|
| 583 |
|
---|
| 584 | template<typename T>
|
---|
| 585 | bgl_named_params<std::pair<T, T>, learning_constant_range_t>
|
---|
| 586 | learning_constant_range(const std::pair<T, T>& c) {
|
---|
| 587 | typedef bgl_named_params<std::pair<T, T>, learning_constant_range_t>
|
---|
| 588 | Params;
|
---|
| 589 | return Params(c);
|
---|
| 590 | }
|
---|
| 591 |
|
---|
| 592 | //===========================================================================
|
---|
| 593 | // Functions for extracting parameters from bgl_named_params
|
---|
| 594 |
|
---|
| 595 | template <class Tag1, class Tag2, class T1, class Base>
|
---|
| 596 | inline
|
---|
| 597 | typename property_value< bgl_named_params<T1,Tag1,Base>, Tag2>::type
|
---|
| 598 | get_param(const bgl_named_params<T1,Tag1,Base>& p, Tag2 tag2)
|
---|
| 599 | {
|
---|
| 600 | enum { match = detail::same_property<Tag1,Tag2>::value };
|
---|
| 601 | typedef typename
|
---|
| 602 | property_value< bgl_named_params<T1,Tag1,Base>, Tag2>::type T2;
|
---|
| 603 | T2* t2 = 0;
|
---|
| 604 | typedef detail::property_value_dispatch<match> Dispatcher;
|
---|
| 605 | return Dispatcher::const_get_value(p, t2, tag2);
|
---|
| 606 | }
|
---|
| 607 |
|
---|
| 608 |
|
---|
| 609 | namespace detail {
|
---|
| 610 | // MSVC++ workaround
|
---|
| 611 | template <class Param>
|
---|
| 612 | struct choose_param_helper {
|
---|
| 613 | template <class Default> struct result { typedef Param type; };
|
---|
| 614 | template <typename Default>
|
---|
| 615 | static const Param& apply(const Param& p, const Default&) { return p; }
|
---|
| 616 | };
|
---|
| 617 | template <>
|
---|
| 618 | struct choose_param_helper<error_property_not_found> {
|
---|
| 619 | template <class Default> struct result { typedef Default type; };
|
---|
| 620 | template <typename Default>
|
---|
| 621 | static const Default& apply(const error_property_not_found&, const Default& d)
|
---|
| 622 | { return d; }
|
---|
| 623 | };
|
---|
| 624 | } // namespace detail
|
---|
| 625 |
|
---|
| 626 | template <class P, class Default>
|
---|
| 627 | const typename detail::choose_param_helper<P>::template result<Default>::type&
|
---|
| 628 | choose_param(const P& param, const Default& d) {
|
---|
| 629 | return detail::choose_param_helper<P>::apply(param, d);
|
---|
| 630 | }
|
---|
| 631 |
|
---|
| 632 | template <typename T>
|
---|
| 633 | inline bool is_default_param(const T&) { return false; }
|
---|
| 634 |
|
---|
| 635 | inline bool is_default_param(const detail::error_property_not_found&)
|
---|
| 636 | { return true; }
|
---|
| 637 |
|
---|
| 638 | namespace detail {
|
---|
| 639 |
|
---|
| 640 | struct choose_parameter {
|
---|
| 641 | template <class P, class Graph, class Tag>
|
---|
| 642 | struct bind_ {
|
---|
| 643 | typedef const P& const_result_type;
|
---|
| 644 | typedef const P& result_type;
|
---|
| 645 | typedef P type;
|
---|
| 646 | };
|
---|
| 647 |
|
---|
| 648 | template <class P, class Graph, class Tag>
|
---|
| 649 | static typename bind_<P, Graph, Tag>::const_result_type
|
---|
| 650 | const_apply(const P& p, const Graph&, Tag&)
|
---|
| 651 | { return p; }
|
---|
| 652 |
|
---|
| 653 | template <class P, class Graph, class Tag>
|
---|
| 654 | static typename bind_<P, Graph, Tag>::result_type
|
---|
| 655 | apply(const P& p, Graph&, Tag&)
|
---|
| 656 | { return p; }
|
---|
| 657 | };
|
---|
| 658 |
|
---|
| 659 | struct choose_default_param {
|
---|
| 660 | template <class P, class Graph, class Tag>
|
---|
| 661 | struct bind_ {
|
---|
| 662 | typedef typename property_map<Graph, Tag>::type
|
---|
| 663 | result_type;
|
---|
| 664 | typedef typename property_map<Graph, Tag>::const_type
|
---|
| 665 | const_result_type;
|
---|
| 666 | typedef typename property_map<Graph, Tag>::const_type
|
---|
| 667 | type;
|
---|
| 668 | };
|
---|
| 669 |
|
---|
| 670 | template <class P, class Graph, class Tag>
|
---|
| 671 | static typename bind_<P, Graph, Tag>::const_result_type
|
---|
| 672 | const_apply(const P&, const Graph& g, Tag tag) {
|
---|
| 673 | return get(tag, g);
|
---|
| 674 | }
|
---|
| 675 | template <class P, class Graph, class Tag>
|
---|
| 676 | static typename bind_<P, Graph, Tag>::result_type
|
---|
| 677 | apply(const P&, Graph& g, Tag tag) {
|
---|
| 678 | return get(tag, g);
|
---|
| 679 | }
|
---|
| 680 | };
|
---|
| 681 |
|
---|
| 682 | template <class Param>
|
---|
| 683 | struct choose_property_map {
|
---|
| 684 | typedef choose_parameter type;
|
---|
| 685 | };
|
---|
| 686 | template <>
|
---|
| 687 | struct choose_property_map<detail::error_property_not_found> {
|
---|
| 688 | typedef choose_default_param type;
|
---|
| 689 | };
|
---|
| 690 |
|
---|
| 691 | template <class Param, class Graph, class Tag>
|
---|
| 692 | struct choose_pmap_helper {
|
---|
| 693 | typedef typename choose_property_map<Param>::type Selector;
|
---|
| 694 | typedef typename Selector:: template bind_<Param, Graph, Tag> Bind;
|
---|
| 695 | typedef Bind type;
|
---|
| 696 | typedef typename Bind::result_type result_type;
|
---|
| 697 | typedef typename Bind::const_result_type const_result_type;
|
---|
| 698 | typedef typename Bind::type result;
|
---|
| 699 | };
|
---|
| 700 |
|
---|
| 701 | // used in the max-flow algorithms
|
---|
| 702 | template <class Graph, class P, class T, class R>
|
---|
| 703 | struct edge_capacity_value
|
---|
| 704 | {
|
---|
| 705 | typedef bgl_named_params<P, T, R> Params;
|
---|
| 706 | typedef typename property_value< Params, edge_capacity_t>::type Param;
|
---|
| 707 | typedef typename detail::choose_pmap_helper<Param, Graph,
|
---|
| 708 | edge_capacity_t>::result CapacityEdgeMap;
|
---|
| 709 | typedef typename property_traits<CapacityEdgeMap>::value_type type;
|
---|
| 710 | };
|
---|
| 711 |
|
---|
| 712 | } // namespace detail
|
---|
| 713 |
|
---|
| 714 |
|
---|
| 715 | // Use this function instead of choose_param() when you want
|
---|
| 716 | // to avoid requiring get(tag, g) when it is not used.
|
---|
| 717 | template <typename Param, typename Graph, typename PropertyTag>
|
---|
| 718 | typename
|
---|
| 719 | detail::choose_pmap_helper<Param,Graph,PropertyTag>::const_result_type
|
---|
| 720 | choose_const_pmap(const Param& p, const Graph& g, PropertyTag tag)
|
---|
| 721 | {
|
---|
| 722 | typedef typename
|
---|
| 723 | detail::choose_pmap_helper<Param,Graph,PropertyTag>::Selector Choice;
|
---|
| 724 | return Choice::const_apply(p, g, tag);
|
---|
| 725 | }
|
---|
| 726 |
|
---|
| 727 | template <typename Param, typename Graph, typename PropertyTag>
|
---|
| 728 | typename detail::choose_pmap_helper<Param,Graph,PropertyTag>::result_type
|
---|
| 729 | choose_pmap(const Param& p, Graph& g, PropertyTag tag)
|
---|
| 730 | {
|
---|
| 731 | typedef typename
|
---|
| 732 | detail::choose_pmap_helper<Param,Graph,PropertyTag>::Selector Choice;
|
---|
| 733 | return Choice::apply(p, g, tag);
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | } // namespace boost
|
---|
| 737 |
|
---|
| 738 | #endif // BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP
|
---|