269 protected: |
252 protected: |
270 RevGraphWrapper() { } |
253 RevGraphWrapper() { } |
271 public: |
254 public: |
272 RevGraphWrapper(_Graph& _graph) { setGraph(_graph); } |
255 RevGraphWrapper(_Graph& _graph) { setGraph(_graph); } |
273 }; |
256 }; |
274 // template<typename Graph> |
|
275 // class RevGraphWrapper : public GraphWrapper<Graph> { |
|
276 // public: |
|
277 // typedef GraphWrapper<Graph> Parent; |
|
278 // protected: |
|
279 // RevGraphWrapper() : GraphWrapper<Graph>() { } |
|
280 // public: |
|
281 // RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { } |
|
282 // RevGraphWrapper(const RevGraphWrapper<Graph>& gw) : Parent(gw) { } |
|
283 |
|
284 // typedef typename GraphWrapper<Graph>::Node Node; |
|
285 // typedef typename GraphWrapper<Graph>::Edge Edge; |
|
286 // //remark: OutEdgeIt and InEdgeIt cannot be typedef-ed to each other |
|
287 // //because this does not work is some of them are not defined in the |
|
288 // //original graph. The problem with this is that typedef-ed stuff |
|
289 // //are instantiated in c++. |
|
290 // class OutEdgeIt : public Edge { |
|
291 // const RevGraphWrapper<Graph>* gw; |
|
292 // friend class GraphWrapper<Graph>; |
|
293 // public: |
|
294 // OutEdgeIt() { } |
|
295 // OutEdgeIt(Invalid i) : Edge(i) { } |
|
296 // OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : |
|
297 // Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { } |
|
298 // OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : |
|
299 // Edge(e), gw(&_gw) { } |
|
300 // OutEdgeIt& operator++() { |
|
301 // *(static_cast<Edge*>(this))= |
|
302 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
303 // return *this; |
|
304 // } |
|
305 // }; |
|
306 // class InEdgeIt : public Edge { |
|
307 // const RevGraphWrapper<Graph>* gw; |
|
308 // friend class GraphWrapper<Graph>; |
|
309 // public: |
|
310 // InEdgeIt() { } |
|
311 // InEdgeIt(Invalid i) : Edge(i) { } |
|
312 // InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : |
|
313 // Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { } |
|
314 // InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : |
|
315 // Edge(e), gw(&_gw) { } |
|
316 // InEdgeIt& operator++() { |
|
317 // *(static_cast<Edge*>(this))= |
|
318 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
319 // return *this; |
|
320 // } |
|
321 // }; |
|
322 |
|
323 // using GraphWrapper<Graph>::first; |
|
324 // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { |
|
325 // i=OutEdgeIt(*this, p); return i; |
|
326 // } |
|
327 // InEdgeIt& first(InEdgeIt& i, const Node& p) const { |
|
328 // i=InEdgeIt(*this, p); return i; |
|
329 // } |
|
330 |
|
331 // Node source(const Edge& e) const { |
|
332 // return GraphWrapper<Graph>::target(e); } |
|
333 // Node target(const Edge& e) const { |
|
334 // return GraphWrapper<Graph>::source(e); } |
|
335 |
|
336 // // KEEP_MAPS(Parent, RevGraphWrapper); |
|
337 |
|
338 // }; |
|
339 |
257 |
340 |
258 |
341 template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap> |
259 template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap> |
342 class SubGraphWrapperBase : public GraphWrapperBase<_Graph> { |
260 class SubGraphWrapperBase : public GraphWrapperBase<_Graph> { |
343 public: |
261 public: |
514 setNodeFilterMap(_node_filter_map); |
432 setNodeFilterMap(_node_filter_map); |
515 setEdgeFilterMap(_edge_filter_map); |
433 setEdgeFilterMap(_edge_filter_map); |
516 } |
434 } |
517 }; |
435 }; |
518 |
436 |
519 // template<typename Graph, typename NodeFilterMap, |
|
520 // typename EdgeFilterMap> |
|
521 // class SubGraphWrapper : public GraphWrapper<Graph> { |
|
522 // public: |
|
523 // typedef GraphWrapper<Graph> Parent; |
|
524 // protected: |
|
525 // NodeFilterMap* node_filter_map; |
|
526 // EdgeFilterMap* edge_filter_map; |
|
527 |
|
528 // SubGraphWrapper() : GraphWrapper<Graph>(), |
|
529 // node_filter_map(0), edge_filter_map(0) { } |
|
530 // void setNodeFilterMap(NodeFilterMap& _node_filter_map) { |
|
531 // node_filter_map=&_node_filter_map; |
|
532 // } |
|
533 // void setEdgeFilterMap(EdgeFilterMap& _edge_filter_map) { |
|
534 // edge_filter_map=&_edge_filter_map; |
|
535 // } |
|
536 |
|
537 // public: |
|
538 // SubGraphWrapper(Graph& _graph, NodeFilterMap& _node_filter_map, |
|
539 // EdgeFilterMap& _edge_filter_map) : |
|
540 // GraphWrapper<Graph>(_graph), node_filter_map(&_node_filter_map), |
|
541 // edge_filter_map(&_edge_filter_map) { } |
|
542 |
|
543 // typedef typename GraphWrapper<Graph>::Node Node; |
|
544 // class NodeIt : public Node { |
|
545 // const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; |
|
546 // friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; |
|
547 // public: |
|
548 // NodeIt() { } |
|
549 // NodeIt(Invalid i) : Node(i) { } |
|
550 // NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : |
|
551 // Node(typename Graph::NodeIt(*(_gw.graph))), gw(&_gw) { |
|
552 // while (*static_cast<Node*>(this)!=INVALID && |
|
553 // !(*(gw->node_filter_map))[*this]) |
|
554 // *(static_cast<Node*>(this))= |
|
555 // ++(typename Graph::NodeIt(*(gw->graph), *this)); |
|
556 // } |
|
557 // NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, |
|
558 // const Node& n) : |
|
559 // Node(n), gw(&_gw) { } |
|
560 // NodeIt& operator++() { |
|
561 // *(static_cast<Node*>(this))= |
|
562 // ++(typename Graph::NodeIt(*(gw->graph), *this)); |
|
563 // while (*static_cast<Node*>(this)!=INVALID && |
|
564 // !(*(gw->node_filter_map))[*this]) |
|
565 // *(static_cast<Node*>(this))= |
|
566 // ++(typename Graph::NodeIt(*(gw->graph), *this)); |
|
567 // return *this; |
|
568 // } |
|
569 // }; |
|
570 // typedef typename GraphWrapper<Graph>::Edge Edge; |
|
571 // class OutEdgeIt : public Edge { |
|
572 // const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; |
|
573 // friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; |
|
574 // public: |
|
575 // OutEdgeIt() { } |
|
576 // OutEdgeIt(Invalid i) : Edge(i) { } |
|
577 // OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : |
|
578 // Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { |
|
579 // while (*static_cast<Edge*>(this)!=INVALID && |
|
580 // !(*(gw->edge_filter_map))[*this]) |
|
581 // *(static_cast<Edge*>(this))= |
|
582 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
583 // } |
|
584 // OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, |
|
585 // const Edge& e) : |
|
586 // Edge(e), gw(&_gw) { } |
|
587 // OutEdgeIt& operator++() { |
|
588 // *(static_cast<Edge*>(this))= |
|
589 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
590 // while (*static_cast<Edge*>(this)!=INVALID && |
|
591 // !(*(gw->edge_filter_map))[*this]) |
|
592 // *(static_cast<Edge*>(this))= |
|
593 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
594 // return *this; |
|
595 // } |
|
596 // }; |
|
597 // class InEdgeIt : public Edge { |
|
598 // const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; |
|
599 // friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; |
|
600 // public: |
|
601 // InEdgeIt() { } |
|
602 // // InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { } |
|
603 // InEdgeIt(Invalid i) : Edge(i) { } |
|
604 // InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : |
|
605 // Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { |
|
606 // while (*static_cast<Edge*>(this)!=INVALID && |
|
607 // !(*(gw->edge_filter_map))[*this]) |
|
608 // *(static_cast<Edge*>(this))= |
|
609 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
610 // } |
|
611 // InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, |
|
612 // const Edge& e) : |
|
613 // Edge(e), gw(&_gw) { } |
|
614 // InEdgeIt& operator++() { |
|
615 // *(static_cast<Edge*>(this))= |
|
616 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
617 // while (*static_cast<Edge*>(this)!=INVALID && |
|
618 // !(*(gw->edge_filter_map))[*this]) |
|
619 // *(static_cast<Edge*>(this))= |
|
620 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
621 // return *this; |
|
622 // } |
|
623 // }; |
|
624 // class EdgeIt : public Edge { |
|
625 // const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; |
|
626 // friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; |
|
627 // public: |
|
628 // EdgeIt() { } |
|
629 // EdgeIt(Invalid i) : Edge(i) { } |
|
630 // EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : |
|
631 // Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { |
|
632 // while (*static_cast<Edge*>(this)!=INVALID && |
|
633 // !(*(gw->edge_filter_map))[*this]) |
|
634 // *(static_cast<Edge*>(this))= |
|
635 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
636 // } |
|
637 // EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, |
|
638 // const Edge& e) : |
|
639 // Edge(e), gw(&_gw) { } |
|
640 // EdgeIt& operator++() { |
|
641 // *(static_cast<Edge*>(this))= |
|
642 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
643 // while (*static_cast<Edge*>(this)!=INVALID && |
|
644 // !(*(gw->edge_filter_map))[*this]) |
|
645 // *(static_cast<Edge*>(this))= |
|
646 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
647 // return *this; |
|
648 // } |
|
649 // }; |
|
650 |
|
651 // NodeIt& first(NodeIt& i) const { |
|
652 // i=NodeIt(*this); return i; |
|
653 // } |
|
654 // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { |
|
655 // i=OutEdgeIt(*this, p); return i; |
|
656 // } |
|
657 // InEdgeIt& first(InEdgeIt& i, const Node& p) const { |
|
658 // i=InEdgeIt(*this, p); return i; |
|
659 // } |
|
660 // EdgeIt& first(EdgeIt& i) const { |
|
661 // i=EdgeIt(*this); return i; |
|
662 // } |
|
663 |
|
664 // /// This function hides \c n in the graph, i.e. the iteration |
|
665 // /// jumps over it. This is done by simply setting the value of \c n |
|
666 // /// to be false in the corresponding node-map. |
|
667 // void hide(const Node& n) const { node_filter_map->set(n, false); } |
|
668 |
|
669 // /// This function hides \c e in the graph, i.e. the iteration |
|
670 // /// jumps over it. This is done by simply setting the value of \c e |
|
671 // /// to be false in the corresponding edge-map. |
|
672 // void hide(const Edge& e) const { edge_filter_map->set(e, false); } |
|
673 |
|
674 // /// The value of \c n is set to be true in the node-map which stores |
|
675 // /// hide information. If \c n was hidden previuosly, then it is shown |
|
676 // /// again |
|
677 // void unHide(const Node& n) const { node_filter_map->set(n, true); } |
|
678 |
|
679 // /// The value of \c e is set to be true in the edge-map which stores |
|
680 // /// hide information. If \c e was hidden previuosly, then it is shown |
|
681 // /// again |
|
682 // void unHide(const Edge& e) const { edge_filter_map->set(e, true); } |
|
683 |
|
684 // /// Returns true if \c n is hidden. |
|
685 // bool hidden(const Node& n) const { return !(*node_filter_map)[n]; } |
|
686 |
|
687 // /// Returns true if \c n is hidden. |
|
688 // bool hidden(const Edge& e) const { return !(*edge_filter_map)[e]; } |
|
689 |
|
690 // /// \warning This is a linear time operation and works only if |
|
691 // /// \c Graph::NodeIt is defined. |
|
692 // int nodeNum() const { |
|
693 // int i=0; |
|
694 // for (NodeIt n(*this); n!=INVALID; ++n) ++i; |
|
695 // return i; |
|
696 // } |
|
697 |
|
698 // /// \warning This is a linear time operation and works only if |
|
699 // /// \c Graph::EdgeIt is defined. |
|
700 // int edgeNum() const { |
|
701 // int i=0; |
|
702 // for (EdgeIt e(*this); e!=INVALID; ++e) ++i; |
|
703 // return i; |
|
704 // } |
|
705 |
|
706 // // KEEP_MAPS(Parent, SubGraphWrapper); |
|
707 // }; |
|
708 |
437 |
709 |
438 |
710 /*! \brief A wrapper for hiding nodes from a graph. |
439 /*! \brief A wrapper for hiding nodes from a graph. |
711 |
440 |
712 \warning Graph wrappers are in even more experimental state than the other |
441 \warning Graph wrappers are in even more experimental state than the other |
1264 setForwardFilterMap(_forward_filter); |
993 setForwardFilterMap(_forward_filter); |
1265 setBackwardFilterMap(_backward_filter); |
994 setBackwardFilterMap(_backward_filter); |
1266 } |
995 } |
1267 }; |
996 }; |
1268 |
997 |
1269 // template<typename Graph, |
|
1270 // typename ForwardFilterMap, typename BackwardFilterMap> |
|
1271 // class SubBidirGraphWrapper : public GraphWrapper<Graph> { |
|
1272 // public: |
|
1273 // typedef GraphWrapper<Graph> Parent; |
|
1274 // protected: |
|
1275 // ForwardFilterMap* forward_filter; |
|
1276 // BackwardFilterMap* backward_filter; |
|
1277 |
|
1278 // SubBidirGraphWrapper() : GraphWrapper<Graph>() { } |
|
1279 // void setForwardFilterMap(ForwardFilterMap& _forward_filter) { |
|
1280 // forward_filter=&_forward_filter; |
|
1281 // } |
|
1282 // void setBackwardFilterMap(BackwardFilterMap& _backward_filter) { |
|
1283 // backward_filter=&_backward_filter; |
|
1284 // } |
|
1285 |
|
1286 // public: |
|
1287 |
|
1288 // SubBidirGraphWrapper(Graph& _graph, ForwardFilterMap& _forward_filter, |
|
1289 // BackwardFilterMap& _backward_filter) : |
|
1290 // GraphWrapper<Graph>(_graph), |
|
1291 // forward_filter(&_forward_filter), backward_filter(&_backward_filter) { } |
|
1292 // SubBidirGraphWrapper(const SubBidirGraphWrapper<Graph, |
|
1293 // ForwardFilterMap, BackwardFilterMap>& gw) : |
|
1294 // Parent(gw), |
|
1295 // forward_filter(gw.forward_filter), |
|
1296 // backward_filter(gw.backward_filter) { } |
|
1297 |
|
1298 // class Edge; |
|
1299 // class OutEdgeIt; |
|
1300 // friend class Edge; |
|
1301 // friend class OutEdgeIt; |
|
1302 |
|
1303 // template<typename T> class EdgeMap; |
|
1304 |
|
1305 // typedef typename GraphWrapper<Graph>::Node Node; |
|
1306 |
|
1307 // typedef typename Graph::Edge GraphEdge; |
|
1308 // /// SubBidirGraphWrapper<..., ..., ...>::Edge is inherited from |
|
1309 // /// Graph::Edge. It contains an extra bool flag which is true |
|
1310 // /// if and only if the |
|
1311 // /// edge is the backward version of the original edge. |
|
1312 // class Edge : public Graph::Edge { |
|
1313 // friend class SubBidirGraphWrapper<Graph, |
|
1314 // ForwardFilterMap, BackwardFilterMap>; |
|
1315 // template<typename T> friend class EdgeMap; |
|
1316 // protected: |
|
1317 // bool backward; //true, iff backward |
|
1318 // public: |
|
1319 // Edge() { } |
|
1320 // /// \todo =false is needed, or causes problems? |
|
1321 // /// If \c _backward is false, then we get an edge corresponding to the |
|
1322 // /// original one, otherwise its oppositely directed pair is obtained. |
|
1323 // Edge(const typename Graph::Edge& e, bool _backward/*=false*/) : |
|
1324 // Graph::Edge(e), backward(_backward) { } |
|
1325 // Edge(Invalid i) : Graph::Edge(i), backward(true) { } |
|
1326 // bool operator==(const Edge& v) const { |
|
1327 // return (this->backward==v.backward && |
|
1328 // static_cast<typename Graph::Edge>(*this)== |
|
1329 // static_cast<typename Graph::Edge>(v)); |
|
1330 // } |
|
1331 // bool operator!=(const Edge& v) const { |
|
1332 // return (this->backward!=v.backward || |
|
1333 // static_cast<typename Graph::Edge>(*this)!= |
|
1334 // static_cast<typename Graph::Edge>(v)); |
|
1335 // } |
|
1336 // }; |
|
1337 |
|
1338 // class OutEdgeIt : public Edge { |
|
1339 // friend class SubBidirGraphWrapper<Graph, |
|
1340 // ForwardFilterMap, BackwardFilterMap>; |
|
1341 // protected: |
|
1342 // const SubBidirGraphWrapper<Graph, |
|
1343 // ForwardFilterMap, BackwardFilterMap>* gw; |
|
1344 // public: |
|
1345 // OutEdgeIt() { } |
|
1346 // OutEdgeIt(Invalid i) : Edge(i) { } |
|
1347 // OutEdgeIt(const SubBidirGraphWrapper<Graph, |
|
1348 // ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) : |
|
1349 // Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), false), gw(&_gw) { |
|
1350 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1351 // !(*(gw->forward_filter))[*this]) |
|
1352 // *(static_cast<GraphEdge*>(this))= |
|
1353 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1354 // if (*static_cast<GraphEdge*>(this)==INVALID) { |
|
1355 // *static_cast<Edge*>(this)= |
|
1356 // Edge(typename Graph::InEdgeIt(*(_gw.graph), n), true); |
|
1357 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1358 // !(*(gw->backward_filter))[*this]) |
|
1359 // *(static_cast<GraphEdge*>(this))= |
|
1360 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1361 // } |
|
1362 // } |
|
1363 // OutEdgeIt(const SubBidirGraphWrapper<Graph, |
|
1364 // ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : |
|
1365 // Edge(e), gw(&_gw) { } |
|
1366 // OutEdgeIt& operator++() { |
|
1367 // if (!this->backward) { |
|
1368 // Node n=gw->source(*this); |
|
1369 // *(static_cast<GraphEdge*>(this))= |
|
1370 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1371 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1372 // !(*(gw->forward_filter))[*this]) |
|
1373 // *(static_cast<GraphEdge*>(this))= |
|
1374 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1375 // if (*static_cast<GraphEdge*>(this)==INVALID) { |
|
1376 // *static_cast<Edge*>(this)= |
|
1377 // Edge(typename Graph::InEdgeIt(*(gw->graph), n), true); |
|
1378 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1379 // !(*(gw->backward_filter))[*this]) |
|
1380 // *(static_cast<GraphEdge*>(this))= |
|
1381 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1382 // } |
|
1383 // } else { |
|
1384 // *(static_cast<GraphEdge*>(this))= |
|
1385 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1386 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1387 // !(*(gw->backward_filter))[*this]) |
|
1388 // *(static_cast<GraphEdge*>(this))= |
|
1389 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1390 // } |
|
1391 // return *this; |
|
1392 // } |
|
1393 // }; |
|
1394 |
|
1395 // class InEdgeIt : public Edge { |
|
1396 // friend class SubBidirGraphWrapper<Graph, |
|
1397 // ForwardFilterMap, BackwardFilterMap>; |
|
1398 // protected: |
|
1399 // const SubBidirGraphWrapper<Graph, |
|
1400 // ForwardFilterMap, BackwardFilterMap>* gw; |
|
1401 // public: |
|
1402 // InEdgeIt() { } |
|
1403 // InEdgeIt(Invalid i) : Edge(i) { } |
|
1404 // InEdgeIt(const SubBidirGraphWrapper<Graph, |
|
1405 // ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) : |
|
1406 // Edge(typename Graph::InEdgeIt(*(_gw.graph), n), false), gw(&_gw) { |
|
1407 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1408 // !(*(gw->forward_filter))[*this]) |
|
1409 // *(static_cast<GraphEdge*>(this))= |
|
1410 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1411 // if (*static_cast<GraphEdge*>(this)==INVALID) { |
|
1412 // *static_cast<Edge*>(this)= |
|
1413 // Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), true); |
|
1414 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1415 // !(*(gw->backward_filter))[*this]) |
|
1416 // *(static_cast<GraphEdge*>(this))= |
|
1417 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1418 // } |
|
1419 // } |
|
1420 // InEdgeIt(const SubBidirGraphWrapper<Graph, |
|
1421 // ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : |
|
1422 // Edge(e), gw(&_gw) { } |
|
1423 // InEdgeIt& operator++() { |
|
1424 // if (!this->backward) { |
|
1425 // Node n=gw->source(*this); |
|
1426 // *(static_cast<GraphEdge*>(this))= |
|
1427 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1428 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1429 // !(*(gw->forward_filter))[*this]) |
|
1430 // *(static_cast<GraphEdge*>(this))= |
|
1431 // ++(typename Graph::InEdgeIt(*(gw->graph), *this)); |
|
1432 // if (*static_cast<GraphEdge*>(this)==INVALID) { |
|
1433 // *static_cast<Edge*>(this)= |
|
1434 // Edge(typename Graph::OutEdgeIt(*(gw->graph), n), true); |
|
1435 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1436 // !(*(gw->backward_filter))[*this]) |
|
1437 // *(static_cast<GraphEdge*>(this))= |
|
1438 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1439 // } |
|
1440 // } else { |
|
1441 // *(static_cast<GraphEdge*>(this))= |
|
1442 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1443 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1444 // !(*(gw->backward_filter))[*this]) |
|
1445 // *(static_cast<GraphEdge*>(this))= |
|
1446 // ++(typename Graph::OutEdgeIt(*(gw->graph), *this)); |
|
1447 // } |
|
1448 // return *this; |
|
1449 // } |
|
1450 // }; |
|
1451 |
|
1452 // class EdgeIt : public Edge { |
|
1453 // friend class SubBidirGraphWrapper<Graph, |
|
1454 // ForwardFilterMap, BackwardFilterMap>; |
|
1455 // protected: |
|
1456 // const SubBidirGraphWrapper<Graph, |
|
1457 // ForwardFilterMap, BackwardFilterMap>* gw; |
|
1458 // public: |
|
1459 // EdgeIt() { } |
|
1460 // EdgeIt(Invalid i) : Edge(i) { } |
|
1461 // EdgeIt(const SubBidirGraphWrapper<Graph, |
|
1462 // ForwardFilterMap, BackwardFilterMap>& _gw) : |
|
1463 // Edge(typename Graph::EdgeIt(*(_gw.graph)), false), gw(&_gw) { |
|
1464 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1465 // !(*(gw->forward_filter))[*this]) |
|
1466 // *(static_cast<GraphEdge*>(this))= |
|
1467 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1468 // if (*static_cast<GraphEdge*>(this)==INVALID) { |
|
1469 // *static_cast<Edge*>(this)= |
|
1470 // Edge(typename Graph::EdgeIt(*(_gw.graph)), true); |
|
1471 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1472 // !(*(gw->backward_filter))[*this]) |
|
1473 // *(static_cast<GraphEdge*>(this))= |
|
1474 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1475 // } |
|
1476 // } |
|
1477 // EdgeIt(const SubBidirGraphWrapper<Graph, |
|
1478 // ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : |
|
1479 // Edge(e), gw(&_gw) { } |
|
1480 // EdgeIt& operator++() { |
|
1481 // if (!this->backward) { |
|
1482 // *(static_cast<GraphEdge*>(this))= |
|
1483 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1484 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1485 // !(*(gw->forward_filter))[*this]) |
|
1486 // *(static_cast<GraphEdge*>(this))= |
|
1487 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1488 // if (*static_cast<GraphEdge*>(this)==INVALID) { |
|
1489 // *static_cast<Edge*>(this)= |
|
1490 // Edge(typename Graph::EdgeIt(*(gw->graph)), true); |
|
1491 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1492 // !(*(gw->backward_filter))[*this]) |
|
1493 // *(static_cast<GraphEdge*>(this))= |
|
1494 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1495 // } |
|
1496 // } else { |
|
1497 // *(static_cast<GraphEdge*>(this))= |
|
1498 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1499 // while (*static_cast<GraphEdge*>(this)!=INVALID && |
|
1500 // !(*(gw->backward_filter))[*this]) |
|
1501 // *(static_cast<GraphEdge*>(this))= |
|
1502 // ++(typename Graph::EdgeIt(*(gw->graph), *this)); |
|
1503 // } |
|
1504 // return *this; |
|
1505 // } |
|
1506 // }; |
|
1507 |
|
1508 // // using GraphWrapper<Graph>::first; |
|
1509 // // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { |
|
1510 // // i=OutEdgeIt(*this, p); return i; |
|
1511 // // } |
|
1512 // // InEdgeIt& first(InEdgeIt& i, const Node& p) const { |
|
1513 // // i=InEdgeIt(*this, p); return i; |
|
1514 // // } |
|
1515 // // EdgeIt& first(EdgeIt& i) const { |
|
1516 // // i=EdgeIt(*this); return i; |
|
1517 // // } |
|
1518 |
|
1519 |
|
1520 // Node source(Edge e) const { |
|
1521 // return ((!e.backward) ? this->graph->source(e) : this->graph->target(e)); } |
|
1522 // Node target(Edge e) const { |
|
1523 // return ((!e.backward) ? this->graph->target(e) : this->graph->source(e)); } |
|
1524 |
|
1525 // /// Gives back the opposite edge. |
|
1526 // Edge opposite(const Edge& e) const { |
|
1527 // Edge f=e; |
|
1528 // f.backward=!f.backward; |
|
1529 // return f; |
|
1530 // } |
|
1531 |
|
1532 // /// \warning This is a linear time operation and works only if |
|
1533 // /// \c Graph::EdgeIt is defined. |
|
1534 // int edgeNum() const { |
|
1535 // int i=0; |
|
1536 // for (EdgeIt e(*this); e!=INVALID; ++e) ++i; |
|
1537 // return i; |
|
1538 // } |
|
1539 |
|
1540 // bool forward(const Edge& e) const { return !e.backward; } |
|
1541 // bool backward(const Edge& e) const { return e.backward; } |
|
1542 |
|
1543 |
|
1544 // template <typename T> |
|
1545 // /// \c SubBidirGraphWrapper<..., ..., ...>::EdgeMap contains two |
|
1546 // /// Graph::EdgeMap one for the forward edges and |
|
1547 // /// one for the backward edges. |
|
1548 // class EdgeMap { |
|
1549 // template <typename TT> friend class EdgeMap; |
|
1550 // typename Graph::template EdgeMap<T> forward_map, backward_map; |
|
1551 // public: |
|
1552 // typedef T Value; |
|
1553 // typedef Edge Key; |
|
1554 |
|
1555 // EdgeMap(const SubBidirGraphWrapper<Graph, |
|
1556 // ForwardFilterMap, BackwardFilterMap>& g) : |
|
1557 // forward_map(*(g.graph)), backward_map(*(g.graph)) { } |
|
1558 |
|
1559 // EdgeMap(const SubBidirGraphWrapper<Graph, |
|
1560 // ForwardFilterMap, BackwardFilterMap>& g, T a) : |
|
1561 // forward_map(*(g.graph), a), backward_map(*(g.graph), a) { } |
|
1562 |
|
1563 // template <typename TT> |
|
1564 // EdgeMap(const EdgeMap<TT>& copy) |
|
1565 // : forward_map(copy.forward_map), backward_map(copy.backward_map) {} |
|
1566 |
|
1567 // template <typename TT> |
|
1568 // EdgeMap& operator=(const EdgeMap<TT>& copy) { |
|
1569 // forward_map = copy.forward_map; |
|
1570 // backward_map = copy.backward_map; |
|
1571 // return *this; |
|
1572 // } |
|
1573 |
|
1574 // void set(Edge e, T a) { |
|
1575 // if (!e.backward) |
|
1576 // forward_map.set(e, a); |
|
1577 // else |
|
1578 // backward_map.set(e, a); |
|
1579 // } |
|
1580 |
|
1581 // typename Graph::template EdgeMap<T>::ConstReference |
|
1582 // operator[](Edge e) const { |
|
1583 // if (!e.backward) |
|
1584 // return forward_map[e]; |
|
1585 // else |
|
1586 // return backward_map[e]; |
|
1587 // } |
|
1588 |
|
1589 // typename Graph::template EdgeMap<T>::Reference |
|
1590 // operator[](Edge e) { |
|
1591 // if (!e.backward) |
|
1592 // return forward_map[e]; |
|
1593 // else |
|
1594 // return backward_map[e]; |
|
1595 // } |
|
1596 |
|
1597 // void update() { |
|
1598 // forward_map.update(); |
|
1599 // backward_map.update(); |
|
1600 // } |
|
1601 // }; |
|
1602 |
|
1603 |
|
1604 // // KEEP_NODE_MAP(Parent, SubBidirGraphWrapper); |
|
1605 |
|
1606 // }; |
|
1607 |
998 |
1608 |
999 |
1609 ///\brief A wrapper for composing bidirected graph from a directed one. |
1000 ///\brief A wrapper for composing bidirected graph from a directed one. |
1610 /// |
1001 /// |
1611 ///\warning Graph wrappers are in even more experimental state than the other |
1002 ///\warning Graph wrappers are in even more experimental state than the other |