Changeset 775:e46a1f0623a0 in lemon0.x for src/hugo/graph_wrapper.h
 Timestamp:
 08/31/04 13:26:59 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1068
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/hugo/graph_wrapper.h
r774 r775 348 348 }; 349 349 350 351 350 352 /// A graph wrapper for hiding nodes and edges from a graph. 351 353 … … 381 383 382 384 typedef typename GraphWrapper<Graph>::Node Node; 383 class NodeIt { 384 friend class GraphWrapper<Graph>; 385 // class NodeIt { 386 // friend class GraphWrapper<Graph>; 387 // friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; 388 // typename Graph::NodeIt n; 389 // public: 390 // NodeIt() { } 391 // NodeIt(const typename Graph::NodeIt& _n) : n(_n) { } 392 // NodeIt(const Invalid& i) : n(i) { } 393 // NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 394 // n(*(_G.graph)) { 395 // while (_G.graph>valid(n) && !(*(_G.node_filter_map))[n]) 396 // _G.graph>next(n); 397 // } 398 // operator Node() const { return Node(typename Graph::Node(n)); } 399 // }; 400 class NodeIt : public Node { 401 const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; 385 402 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; 386 typename Graph::NodeIt n; 387 public: 403 public: 388 404 NodeIt() { } 389 NodeIt(const typename Graph::NodeIt& _n) : n(_n) { } 390 NodeIt(const Invalid& i) : n(i) { } 391 NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 392 n(*(_G.graph)) { 393 while (_G.graph>valid(n) && !(*(_G.node_filter_map))[n]) 394 _G.graph>next(n); 395 } 396 operator Node() const { return Node(typename Graph::Node(n)); } 405 // NodeIt(const NodeIt& n) : Node(n), gw(n.gw) { } 406 NodeIt(Invalid i) : Node(i) { } 407 NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : 408 Node(typename Graph::NodeIt(*(_gw.graph))), gw(&_gw) { } 409 NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 410 const Node& n) : 411 Node(n), gw(&_gw) { } 412 NodeIt& operator++() { 413 *(static_cast<Node*>(this))= 414 ++(typename Graph::NodeIt(*(gw>graph), *this)); 415 while (*static_cast<Node*>(this)!=INVALID && 416 !(*(gw>node_filter_map))[*this]) 417 *(static_cast<Node*>(this))= 418 ++(typename Graph::NodeIt(*(gw>graph), *this)); 419 return *this; 420 } 397 421 }; 398 422 typedef typename GraphWrapper<Graph>::Edge Edge; 399 class OutEdgeIt {400 friend class GraphWrapper<Graph>;423 class OutEdgeIt : public Edge { 424 const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; 401 425 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; 402 typename Graph::OutEdgeIt e;403 426 public: 404 427 OutEdgeIt() { } 405 OutEdgeIt(const typename Graph::OutEdgeIt& _e) : e(_e) { } 406 OutEdgeIt(const Invalid& i) : e(i) { } 407 OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G, 408 const Node& _n) : 409 e(*(_G.graph), typename Graph::Node(_n)) { 410 while (_G.graph>valid(e) && !(*(_G.edge_filter_map))[e]) 411 _G.graph>next(e); 412 } 413 operator Edge() const { return Edge(typename Graph::Edge(e)); } 414 }; 415 class InEdgeIt { 416 friend class GraphWrapper<Graph>; 428 // OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { } 429 OutEdgeIt(Invalid i) : Edge(i) { } 430 OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 431 Edge(typename Graph::OutEdgeIt(*(_gw.graph)), n), gw(&_gw) { } 432 OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 433 const Edge& e) : 434 Edge(e), gw(&_gw) { } 435 OutEdgeIt& operator++() { 436 *(static_cast<Edge*>(this))= 437 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 438 while (*static_cast<Edge*>(this)!=INVALID && 439 !(*(gw>edge_filter_map))[*this]) 440 *(static_cast<Edge*>(this))= 441 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 442 return *this; 443 } 444 }; 445 class InEdgeIt : public Edge { 446 const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; 417 447 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; 418 typename Graph::InEdgeIt e;419 448 public: 420 449 InEdgeIt() { } 421 InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { } 422 InEdgeIt(const Invalid& i) : e(i) { } 423 InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G, 424 const Node& _n) : 425 e(*(_G.graph), typename Graph::Node(_n)) { 426 while (_G.graph>valid(e) && !(*(_G.edge_filter_map))[e]) 427 _G.graph>next(e); 428 } 429 operator Edge() const { return Edge(typename Graph::Edge(e)); } 430 }; 431 //typedef typename Graph::SymEdgeIt SymEdgeIt; 432 class EdgeIt { 433 friend class GraphWrapper<Graph>; 450 // InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { } 451 InEdgeIt(Invalid i) : Edge(i) { } 452 InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 453 Edge(typename Graph::InEdgeIt(*(_gw.graph)), n), gw(&_gw) { } 454 InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 455 const Edge& e) : 456 Edge(e), gw(&_gw) { } 457 InEdgeIt& operator++() { 458 *(static_cast<Edge*>(this))= 459 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 460 while (*static_cast<Edge*>(this)!=INVALID && 461 !(*(gw>edge_filter_map))[*this]) 462 *(static_cast<Edge*>(this))= 463 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 464 return *this; 465 } 466 }; 467 class EdgeIt : public Edge { 468 const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw; 434 469 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>; 435 typename Graph::EdgeIt e;436 470 public: 437 471 EdgeIt() { } 438 EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { } 439 EdgeIt(const Invalid& i) : e(i) { } 440 EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 441 e(*(_G.graph)) { 442 while (_G.graph>valid(e) && !(*(_G.edge_filter_map))[e]) 443 _G.graph>next(e); 444 } 445 operator Edge() const { return Edge(typename Graph::Edge(e)); } 472 // EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { } 473 EdgeIt(Invalid i) : Edge(i) { } 474 EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : 475 Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { } 476 EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 477 const Edge& e) : 478 Edge(e), gw(&_gw) { } 479 EdgeIt& operator++() { 480 *(static_cast<Edge*>(this))= 481 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 482 while (*static_cast<Edge*>(this)!=INVALID && 483 !(*(gw>edge_filter_map))[*this]) 484 *(static_cast<Edge*>(this))= 485 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 486 return *this; 487 } 446 488 }; 447 489 … … 459 501 } 460 502 461 NodeIt& next(NodeIt& i) const {462 this>graph>next(i.n);463 while (this>graph>valid(i) && !(*node_filter_map)[i.n]) {464 this>graph>next(i.n); }465 return i;466 }467 OutEdgeIt& next(OutEdgeIt& i) const {468 this>graph>next(i.e);469 while (this>graph>valid(i) && !(*edge_filter_map)[i.e]) {470 this>graph>next(i.e); }471 return i;472 }473 InEdgeIt& next(InEdgeIt& i) const {474 this>graph>next(i.e);475 while (this>graph>valid(i) && !(*edge_filter_map)[i.e]) {476 this>graph>next(i.e); }477 return i;478 }479 EdgeIt& next(EdgeIt& i) const {480 this>graph>next(i.e);481 while (this>graph>valid(i) && !(*edge_filter_map)[i.e]) {482 this>graph>next(i.e); }483 return i;484 }485 486 Node aNode(const OutEdgeIt& e) const {487 return Node(this>graph>aNode(e.e)); }488 Node aNode(const InEdgeIt& e) const {489 return Node(this>graph>aNode(e.e)); }490 Node bNode(const OutEdgeIt& e) const {491 return Node(this>graph>bNode(e.e)); }492 Node bNode(const InEdgeIt& e) const {493 return Node(this>graph>bNode(e.e)); }503 // NodeIt& next(NodeIt& i) const { 504 // this>graph>next(i.n); 505 // while (this>graph>valid(i) && !(*node_filter_map)[i.n]) { 506 // this>graph>next(i.n); } 507 // return i; 508 // } 509 // OutEdgeIt& next(OutEdgeIt& i) const { 510 // this>graph>next(i.e); 511 // while (this>graph>valid(i) && !(*edge_filter_map)[i.e]) { 512 // this>graph>next(i.e); } 513 // return i; 514 // } 515 // InEdgeIt& next(InEdgeIt& i) const { 516 // this>graph>next(i.e); 517 // while (this>graph>valid(i) && !(*edge_filter_map)[i.e]) { 518 // this>graph>next(i.e); } 519 // return i; 520 // } 521 // EdgeIt& next(EdgeIt& i) const { 522 // this>graph>next(i.e); 523 // while (this>graph>valid(i) && !(*edge_filter_map)[i.e]) { 524 // this>graph>next(i.e); } 525 // return i; 526 // } 527 528 // Node aNode(const OutEdgeIt& e) const { 529 // return Node(this>graph>aNode(e.e)); } 530 // Node aNode(const InEdgeIt& e) const { 531 // return Node(this>graph>aNode(e.e)); } 532 // Node bNode(const OutEdgeIt& e) const { 533 // return Node(this>graph>bNode(e.e)); } 534 // Node bNode(const InEdgeIt& e) const { 535 // return Node(this>graph>bNode(e.e)); } 494 536 495 537 /// This function hides \c n in the graph, i.e. the iteration … … 754 796 *(static_cast<GraphEdge*>(this))= 755 797 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 756 if (*static_cast<GraphEdge*>(this)==INVALID) 798 if (*static_cast<GraphEdge*>(this)==INVALID) { 757 799 *static_cast<Edge*>(this)= 758 800 Edge(typename Graph::InEdgeIt(*(_gw.graph), n), true); 759 while (*static_cast<GraphEdge*>(this)!=INVALID && 760 !(*(gw>backward_filter))[*this]) 761 *(static_cast<GraphEdge*>(this))= 762 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 801 while (*static_cast<GraphEdge*>(this)!=INVALID && 802 !(*(gw>backward_filter))[*this]) 803 *(static_cast<GraphEdge*>(this))= 804 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 805 } 763 806 } 764 807 OutEdgeIt(const SubBidirGraphWrapper<Graph, … … 774 817 *(static_cast<GraphEdge*>(this))= 775 818 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 776 if (*static_cast<GraphEdge*>(this)==INVALID) 819 if (*static_cast<GraphEdge*>(this)==INVALID) { 777 820 *static_cast<Edge*>(this)= 778 821 Edge(typename Graph::InEdgeIt(*(gw>graph), n), true); 779 while (*static_cast<GraphEdge*>(this)!=INVALID && 780 !(*(gw>backward_filter))[*this]) 781 *(static_cast<GraphEdge*>(this))= 782 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 822 while (*static_cast<GraphEdge*>(this)!=INVALID && 823 !(*(gw>backward_filter))[*this]) 824 *(static_cast<GraphEdge*>(this))= 825 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 826 } 783 827 } else { 784 828 *(static_cast<GraphEdge*>(this))= … … 810 854 *(static_cast<GraphEdge*>(this))= 811 855 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 812 if (*static_cast<GraphEdge*>(this)==INVALID) 856 if (*static_cast<GraphEdge*>(this)==INVALID) { 813 857 *static_cast<Edge*>(this)= 814 858 Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), true); 815 while (*static_cast<GraphEdge*>(this)!=INVALID && 816 !(*(gw>backward_filter))[*this]) 817 *(static_cast<GraphEdge*>(this))= 818 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 859 while (*static_cast<GraphEdge*>(this)!=INVALID && 860 !(*(gw>backward_filter))[*this]) 861 *(static_cast<GraphEdge*>(this))= 862 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 863 } 819 864 } 820 865 InEdgeIt(const SubBidirGraphWrapper<Graph, … … 823 868 InEdgeIt& operator++() { 824 869 if (!this>backward) { 825 Node n=gw> head(*this);870 Node n=gw>tail(*this); 826 871 *(static_cast<GraphEdge*>(this))= 827 872 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); … … 830 875 *(static_cast<GraphEdge*>(this))= 831 876 ++(typename Graph::InEdgeIt(*(gw>graph), *this)); 832 if (*static_cast<GraphEdge*>(this)==INVALID) 877 if (*static_cast<GraphEdge*>(this)==INVALID) { 833 878 *static_cast<Edge*>(this)= 834 879 Edge(typename Graph::OutEdgeIt(*(gw>graph), n), true); 835 while (*static_cast<GraphEdge*>(this)!=INVALID && 836 !(*(gw>backward_filter))[*this]) 837 *(static_cast<GraphEdge*>(this))= 838 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 880 while (*static_cast<GraphEdge*>(this)!=INVALID && 881 !(*(gw>backward_filter))[*this]) 882 *(static_cast<GraphEdge*>(this))= 883 ++(typename Graph::OutEdgeIt(*(gw>graph), *this)); 884 } 839 885 } else { 840 886 *(static_cast<GraphEdge*>(this))= … … 860 906 //the unique invalid iterator 861 907 EdgeIt(const SubBidirGraphWrapper<Graph, 862 863 Edge(typename Graph:: EdgeIt(*(_gw.graph)), false), gw(&_gw) {908 ForwardFilterMap, BackwardFilterMap>& _gw) : 909 Edge(typename Graph::OutEdgeIt(*(_gw.graph)), false), gw(&_gw) { 864 910 while (*static_cast<GraphEdge*>(this)!=INVALID && 865 911 !(*(gw>forward_filter))[*this]) 866 912 *(static_cast<GraphEdge*>(this))= 867 913 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 868 if (*static_cast<GraphEdge*>(this)==INVALID) 914 if (*static_cast<GraphEdge*>(this)==INVALID) { 869 915 *static_cast<Edge*>(this)= 870 916 Edge(typename Graph::EdgeIt(*(_gw.graph)), true); 871 while (*static_cast<GraphEdge*>(this)!=INVALID && 872 !(*(gw>backward_filter))[*this]) 873 *(static_cast<GraphEdge*>(this))= 874 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 917 while (*static_cast<GraphEdge*>(this)!=INVALID && 918 !(*(gw>backward_filter))[*this]) 919 *(static_cast<GraphEdge*>(this))= 920 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 921 } 875 922 } 876 923 EdgeIt(const SubBidirGraphWrapper<Graph, … … 885 932 *(static_cast<GraphEdge*>(this))= 886 933 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 887 if (*static_cast<GraphEdge*>(this)==INVALID) 934 if (*static_cast<GraphEdge*>(this)==INVALID) { 888 935 *static_cast<Edge*>(this)= 889 936 Edge(typename Graph::EdgeIt(*(gw>graph)), true); 890 while (*static_cast<GraphEdge*>(this)!=INVALID && 891 !(*(gw>backward_filter))[*this]) 892 *(static_cast<GraphEdge*>(this))= 893 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 937 while (*static_cast<GraphEdge*>(this)!=INVALID && 938 !(*(gw>backward_filter))[*this]) 939 *(static_cast<GraphEdge*>(this))= 940 ++(typename Graph::EdgeIt(*(gw>graph), *this)); 941 } 894 942 } else { 895 943 *(static_cast<GraphEdge*>(this))=
Note: See TracChangeset
for help on using the changeset viewer.