2252 |
2252 |
2253 /// \brief Arc map combined from two original arc maps |
2253 /// \brief Arc map combined from two original arc maps |
2254 /// |
2254 /// |
2255 /// This map adaptor class adapts two arc maps of the underlying |
2255 /// This map adaptor class adapts two arc maps of the underlying |
2256 /// digraph to get an arc map of the undirected graph. |
2256 /// digraph to get an arc map of the undirected graph. |
2257 /// Its value type is inherited from the first arc map type |
2257 /// Its value type is inherited from the first arc map type (\c FW). |
2258 /// (\c %ForwardMap). |
2258 /// \tparam FW The type of the "foward" arc map. |
2259 template <typename ForwardMap, typename BackwardMap> |
2259 /// \tparam BK The type of the "backward" arc map. |
|
2260 template <typename FW, typename BK> |
2260 class CombinedArcMap { |
2261 class CombinedArcMap { |
2261 public: |
2262 public: |
2262 |
2263 |
2263 /// The key type of the map |
2264 /// The key type of the map |
2264 typedef typename Parent::Arc Key; |
2265 typedef typename Parent::Arc Key; |
2265 /// The value type of the map |
2266 /// The value type of the map |
2266 typedef typename ForwardMap::Value Value; |
2267 typedef typename FW::Value Value; |
2267 |
2268 |
2268 typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag; |
2269 typedef typename MapTraits<FW>::ReferenceMapTag ReferenceMapTag; |
2269 |
2270 |
2270 typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue; |
2271 typedef typename MapTraits<FW>::ReturnValue ReturnValue; |
2271 typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue; |
2272 typedef typename MapTraits<FW>::ConstReturnValue ConstReturnValue; |
2272 typedef typename MapTraits<ForwardMap>::ReturnValue Reference; |
2273 typedef typename MapTraits<FW>::ReturnValue Reference; |
2273 typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference; |
2274 typedef typename MapTraits<FW>::ConstReturnValue ConstReference; |
2274 |
2275 |
2275 /// Constructor |
2276 /// Constructor |
2276 CombinedArcMap(ForwardMap& forward, BackwardMap& backward) |
2277 CombinedArcMap(FW& forward, BK& backward) |
2277 : _forward(&forward), _backward(&backward) {} |
2278 : _forward(&forward), _backward(&backward) {} |
2278 |
2279 |
2279 /// Sets the value associated with the given key. |
2280 /// Sets the value associated with the given key. |
2280 void set(const Key& e, const Value& a) { |
2281 void set(const Key& e, const Value& a) { |
2281 if (Parent::direction(e)) { |
2282 if (Parent::direction(e)) { |
2303 } |
2304 } |
2304 } |
2305 } |
2305 |
2306 |
2306 protected: |
2307 protected: |
2307 |
2308 |
2308 ForwardMap* _forward; |
2309 FW* _forward; |
2309 BackwardMap* _backward; |
2310 BK* _backward; |
2310 |
2311 |
2311 }; |
2312 }; |
2312 |
2313 |
2313 /// \brief Returns a combined arc map |
2314 /// \brief Returns a combined arc map |
2314 /// |
2315 /// |
2315 /// This function just returns a combined arc map. |
2316 /// This function just returns a combined arc map. |
2316 template <typename ForwardMap, typename BackwardMap> |
2317 template <typename FW, typename BK> |
2317 static CombinedArcMap<ForwardMap, BackwardMap> |
2318 static CombinedArcMap<FW, BK> |
2318 combinedArcMap(ForwardMap& forward, BackwardMap& backward) { |
2319 combinedArcMap(FW& forward, BK& backward) { |
2319 return CombinedArcMap<ForwardMap, BackwardMap>(forward, backward); |
2320 return CombinedArcMap<FW, BK>(forward, backward); |
2320 } |
2321 } |
2321 |
2322 |
2322 template <typename ForwardMap, typename BackwardMap> |
2323 template <typename FW, typename BK> |
2323 static CombinedArcMap<const ForwardMap, BackwardMap> |
2324 static CombinedArcMap<const FW, BK> |
2324 combinedArcMap(const ForwardMap& forward, BackwardMap& backward) { |
2325 combinedArcMap(const FW& forward, BK& backward) { |
2325 return CombinedArcMap<const ForwardMap, |
2326 return CombinedArcMap<const FW, BK>(forward, backward); |
2326 BackwardMap>(forward, backward); |
2327 } |
2327 } |
2328 |
2328 |
2329 template <typename FW, typename BK> |
2329 template <typename ForwardMap, typename BackwardMap> |
2330 static CombinedArcMap<FW, const BK> |
2330 static CombinedArcMap<ForwardMap, const BackwardMap> |
2331 combinedArcMap(FW& forward, const BK& backward) { |
2331 combinedArcMap(ForwardMap& forward, const BackwardMap& backward) { |
2332 return CombinedArcMap<FW, const BK>(forward, backward); |
2332 return CombinedArcMap<ForwardMap, |
2333 } |
2333 const BackwardMap>(forward, backward); |
2334 |
2334 } |
2335 template <typename FW, typename BK> |
2335 |
2336 static CombinedArcMap<const FW, const BK> |
2336 template <typename ForwardMap, typename BackwardMap> |
2337 combinedArcMap(const FW& forward, const BK& backward) { |
2337 static CombinedArcMap<const ForwardMap, const BackwardMap> |
2338 return CombinedArcMap<const FW, const BK>(forward, backward); |
2338 combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) { |
|
2339 return CombinedArcMap<const ForwardMap, |
|
2340 const BackwardMap>(forward, backward); |
|
2341 } |
2339 } |
2342 |
2340 |
2343 }; |
2341 }; |
2344 |
2342 |
2345 /// \brief Returns a read-only Undirector adaptor |
2343 /// \brief Returns a read-only Undirector adaptor |
3404 |
3402 |
3405 /// \brief Node map combined from two original node maps |
3403 /// \brief Node map combined from two original node maps |
3406 /// |
3404 /// |
3407 /// This map adaptor class adapts two node maps of the original digraph |
3405 /// This map adaptor class adapts two node maps of the original digraph |
3408 /// to get a node map of the split digraph. |
3406 /// to get a node map of the split digraph. |
3409 /// Its value type is inherited from the first node map type |
3407 /// Its value type is inherited from the first node map type (\c IN). |
3410 /// (\c InNodeMap). |
3408 /// \tparam IN The type of the node map for the in-nodes. |
3411 template <typename InNodeMap, typename OutNodeMap> |
3409 /// \tparam OUT The type of the node map for the out-nodes. |
|
3410 template <typename IN, typename OUT> |
3412 class CombinedNodeMap { |
3411 class CombinedNodeMap { |
3413 public: |
3412 public: |
3414 |
3413 |
3415 /// The key type of the map |
3414 /// The key type of the map |
3416 typedef Node Key; |
3415 typedef Node Key; |
3417 /// The value type of the map |
3416 /// The value type of the map |
3418 typedef typename InNodeMap::Value Value; |
3417 typedef typename IN::Value Value; |
3419 |
3418 |
3420 typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag; |
3419 typedef typename MapTraits<IN>::ReferenceMapTag ReferenceMapTag; |
3421 typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue; |
3420 typedef typename MapTraits<IN>::ReturnValue ReturnValue; |
3422 typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue; |
3421 typedef typename MapTraits<IN>::ConstReturnValue ConstReturnValue; |
3423 typedef typename MapTraits<InNodeMap>::ReturnValue Reference; |
3422 typedef typename MapTraits<IN>::ReturnValue Reference; |
3424 typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference; |
3423 typedef typename MapTraits<IN>::ConstReturnValue ConstReference; |
3425 |
3424 |
3426 /// Constructor |
3425 /// Constructor |
3427 CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) |
3426 CombinedNodeMap(IN& in_map, OUT& out_map) |
3428 : _in_map(in_map), _out_map(out_map) {} |
3427 : _in_map(in_map), _out_map(out_map) {} |
3429 |
3428 |
3430 /// Returns the value associated with the given key. |
3429 /// Returns the value associated with the given key. |
3431 Value operator[](const Key& key) const { |
3430 Value operator[](const Key& key) const { |
3432 if (SplitNodesBase<const DGR>::inNode(key)) { |
3431 if (SplitNodesBase<const DGR>::inNode(key)) { |
3454 } |
3453 } |
3455 } |
3454 } |
3456 |
3455 |
3457 private: |
3456 private: |
3458 |
3457 |
3459 InNodeMap& _in_map; |
3458 IN& _in_map; |
3460 OutNodeMap& _out_map; |
3459 OUT& _out_map; |
3461 |
3460 |
3462 }; |
3461 }; |
3463 |
3462 |
3464 |
3463 |
3465 /// \brief Returns a combined node map |
3464 /// \brief Returns a combined node map |
3466 /// |
3465 /// |
3467 /// This function just returns a combined node map. |
3466 /// This function just returns a combined node map. |
3468 template <typename InNodeMap, typename OutNodeMap> |
3467 template <typename IN, typename OUT> |
3469 static CombinedNodeMap<InNodeMap, OutNodeMap> |
3468 static CombinedNodeMap<IN, OUT> |
3470 combinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) { |
3469 combinedNodeMap(IN& in_map, OUT& out_map) { |
3471 return CombinedNodeMap<InNodeMap, OutNodeMap>(in_map, out_map); |
3470 return CombinedNodeMap<IN, OUT>(in_map, out_map); |
3472 } |
3471 } |
3473 |
3472 |
3474 template <typename InNodeMap, typename OutNodeMap> |
3473 template <typename IN, typename OUT> |
3475 static CombinedNodeMap<const InNodeMap, OutNodeMap> |
3474 static CombinedNodeMap<const IN, OUT> |
3476 combinedNodeMap(const InNodeMap& in_map, OutNodeMap& out_map) { |
3475 combinedNodeMap(const IN& in_map, OUT& out_map) { |
3477 return CombinedNodeMap<const InNodeMap, OutNodeMap>(in_map, out_map); |
3476 return CombinedNodeMap<const IN, OUT>(in_map, out_map); |
3478 } |
3477 } |
3479 |
3478 |
3480 template <typename InNodeMap, typename OutNodeMap> |
3479 template <typename IN, typename OUT> |
3481 static CombinedNodeMap<InNodeMap, const OutNodeMap> |
3480 static CombinedNodeMap<IN, const OUT> |
3482 combinedNodeMap(InNodeMap& in_map, const OutNodeMap& out_map) { |
3481 combinedNodeMap(IN& in_map, const OUT& out_map) { |
3483 return CombinedNodeMap<InNodeMap, const OutNodeMap>(in_map, out_map); |
3482 return CombinedNodeMap<IN, const OUT>(in_map, out_map); |
3484 } |
3483 } |
3485 |
3484 |
3486 template <typename InNodeMap, typename OutNodeMap> |
3485 template <typename IN, typename OUT> |
3487 static CombinedNodeMap<const InNodeMap, const OutNodeMap> |
3486 static CombinedNodeMap<const IN, const OUT> |
3488 combinedNodeMap(const InNodeMap& in_map, const OutNodeMap& out_map) { |
3487 combinedNodeMap(const IN& in_map, const OUT& out_map) { |
3489 return CombinedNodeMap<const InNodeMap, |
3488 return CombinedNodeMap<const IN, const OUT>(in_map, out_map); |
3490 const OutNodeMap>(in_map, out_map); |
|
3491 } |
3489 } |
3492 |
3490 |
3493 /// \brief Arc map combined from an arc map and a node map of the |
3491 /// \brief Arc map combined from an arc map and a node map of the |
3494 /// original digraph. |
3492 /// original digraph. |
3495 /// |
3493 /// |
3496 /// This map adaptor class adapts an arc map and a node map of the |
3494 /// This map adaptor class adapts an arc map and a node map of the |
3497 /// original digraph to get an arc map of the split digraph. |
3495 /// original digraph to get an arc map of the split digraph. |
3498 /// Its value type is inherited from the original arc map type |
3496 /// Its value type is inherited from the original arc map type (\c AM). |
3499 /// (\c ArcMap). |
3497 /// \tparam AM The type of the arc map. |
3500 template <typename ArcMap, typename NodeMap> |
3498 /// \tparam NM the type of the node map. |
|
3499 template <typename AM, typename NM> |
3501 class CombinedArcMap { |
3500 class CombinedArcMap { |
3502 public: |
3501 public: |
3503 |
3502 |
3504 /// The key type of the map |
3503 /// The key type of the map |
3505 typedef Arc Key; |
3504 typedef Arc Key; |
3506 /// The value type of the map |
3505 /// The value type of the map |
3507 typedef typename ArcMap::Value Value; |
3506 typedef typename AM::Value Value; |
3508 |
3507 |
3509 typedef typename MapTraits<ArcMap>::ReferenceMapTag ReferenceMapTag; |
3508 typedef typename MapTraits<AM>::ReferenceMapTag ReferenceMapTag; |
3510 typedef typename MapTraits<ArcMap>::ReturnValue ReturnValue; |
3509 typedef typename MapTraits<AM>::ReturnValue ReturnValue; |
3511 typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReturnValue; |
3510 typedef typename MapTraits<AM>::ConstReturnValue ConstReturnValue; |
3512 typedef typename MapTraits<ArcMap>::ReturnValue Reference; |
3511 typedef typename MapTraits<AM>::ReturnValue Reference; |
3513 typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReference; |
3512 typedef typename MapTraits<AM>::ConstReturnValue ConstReference; |
3514 |
3513 |
3515 /// Constructor |
3514 /// Constructor |
3516 CombinedArcMap(ArcMap& arc_map, NodeMap& node_map) |
3515 CombinedArcMap(AM& arc_map, NM& node_map) |
3517 : _arc_map(arc_map), _node_map(node_map) {} |
3516 : _arc_map(arc_map), _node_map(node_map) {} |
3518 |
3517 |
3519 /// Returns the value associated with the given key. |
3518 /// Returns the value associated with the given key. |
3520 Value operator[](const Key& arc) const { |
3519 Value operator[](const Key& arc) const { |
3521 if (SplitNodesBase<const DGR>::origArc(arc)) { |
3520 if (SplitNodesBase<const DGR>::origArc(arc)) { |