Changeset 878:86b42ec55f3e in lemon-0.x for src/hugo
- Timestamp:
- 09/17/04 14:23:09 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1185
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hugo/graph_wrapper.h
r877 r878 98 98 GraphWrapper(Graph& _graph) : graph(&_graph) { } 99 99 GraphWrapper(const GraphWrapper<Graph>& gw) : graph(gw.graph) { } 100 // Graph& getGraph() const { return *graph; }101 100 102 101 typedef typename Graph::Node Node; … … 106 105 public: 107 106 NodeIt() { } 108 // NodeIt(const NodeIt& n) : Node(n), gw(n.gw) { }109 107 NodeIt(Invalid i) : Node(i) { } 110 108 NodeIt(const GraphWrapper<Graph>& _gw) : … … 124 122 public: 125 123 OutEdgeIt() { } 126 //OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }127 124 OutEdgeIt(Invalid i) : Edge(i) { } 128 125 OutEdgeIt(const GraphWrapper<Graph>& _gw, const Node& n) : … … 141 138 public: 142 139 InEdgeIt() { } 143 //InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }144 140 InEdgeIt(Invalid i) : Edge(i) { } 145 141 InEdgeIt(const GraphWrapper<Graph>& _gw, const Node& n) : … … 153 149 } 154 150 }; 155 //typedef typename Graph::SymEdgeIt SymEdgeIt;156 151 class EdgeIt : public Edge { 157 152 const GraphWrapper<Graph>* gw; … … 159 154 public: 160 155 EdgeIt() { } 161 //EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { }162 156 EdgeIt(Invalid i) : Edge(i) { } 163 157 EdgeIt(const GraphWrapper<Graph>& _gw) : … … 185 179 } 186 180 187 // NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }188 // OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }189 // InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }190 // EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }191 192 181 Node tail(const Edge& e) const { 193 182 return Node(graph->tail(static_cast<typename Graph::Edge>(e))); } … … 195 184 return Node(graph->head(static_cast<typename Graph::Edge>(e))); } 196 185 197 // bool valid(const Node& n) const {198 // return graph->valid(static_cast<typename Graph::Node>(n)); }199 // bool valid(const Edge& e) const {200 // return graph->valid(static_cast<typename Graph::Edge>(e)); }201 202 186 int nodeNum() const { return graph->nodeNum(); } 203 187 int edgeNum() const { return graph->edgeNum(); } 204 205 // Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }206 // Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }207 // Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }208 // Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }209 188 210 189 Node addNode() const { return Node(graph->addNode()); } … … 261 240 public: 262 241 OutEdgeIt() { } 263 //OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }264 242 OutEdgeIt(Invalid i) : Edge(i) { } 265 243 OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : … … 278 256 public: 279 257 InEdgeIt() { } 280 //InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }281 258 InEdgeIt(Invalid i) : Edge(i) { } 282 259 InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : … … 298 275 i=InEdgeIt(*this, p); return i; 299 276 } 300 301 // using GraphWrapper<Graph>::next;302 // OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }303 // InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }304 305 // Node aNode(const OutEdgeIt& e) const {306 // return Node(this->graph->aNode(e.e)); }307 // Node aNode(const InEdgeIt& e) const {308 // return Node(this->graph->aNode(e.e)); }309 // Node bNode(const OutEdgeIt& e) const {310 // return Node(this->graph->bNode(e.e)); }311 // Node bNode(const InEdgeIt& e) const {312 // return Node(this->graph->bNode(e.e)); }313 277 314 278 Node tail(const Edge& e) const { … … 364 328 public: 365 329 NodeIt() { } 366 // NodeIt(const NodeIt& n) : Node(n), gw(n.gw) { }367 330 NodeIt(Invalid i) : Node(i) { } 368 331 NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : … … 392 355 public: 393 356 OutEdgeIt() { } 394 // OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }395 357 OutEdgeIt(Invalid i) : Edge(i) { } 396 358 OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : … … 446 408 public: 447 409 EdgeIt() { } 448 // EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { }449 410 EdgeIt(Invalid i) : Edge(i) { } 450 411 EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : … … 482 443 } 483 444 484 // NodeIt& next(NodeIt& i) const {485 // this->graph->next(i.n);486 // while (this->graph->valid(i) && !(*node_filter_map)[i.n]) {487 // this->graph->next(i.n); }488 // return i;489 // }490 // OutEdgeIt& next(OutEdgeIt& i) const {491 // this->graph->next(i.e);492 // while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) {493 // this->graph->next(i.e); }494 // return i;495 // }496 // InEdgeIt& next(InEdgeIt& i) const {497 // this->graph->next(i.e);498 // while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) {499 // this->graph->next(i.e); }500 // return i;501 // }502 // EdgeIt& next(EdgeIt& i) const {503 // this->graph->next(i.e);504 // while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) {505 // this->graph->next(i.e); }506 // return i;507 // }508 509 // Node aNode(const OutEdgeIt& e) const {510 // return Node(this->graph->aNode(e.e)); }511 // Node aNode(const InEdgeIt& e) const {512 // return Node(this->graph->aNode(e.e)); }513 // Node bNode(const OutEdgeIt& e) const {514 // return Node(this->graph->bNode(e.e)); }515 // Node bNode(const InEdgeIt& e) const {516 // return Node(this->graph->bNode(e.e)); }517 518 445 /// This function hides \c n in the graph, i.e. the iteration 519 446 /// jumps over it. This is done by simply setting the value of \c n … … 563 490 564 491 565 // /// \brief A wrapper for forgetting the orientation of a graph.566 // ///567 // /// A wrapper for getting an undirected graph by forgetting568 // /// the orientation of a directed one.569 // ///570 // /// \author Marton Makai571 // /// does not work in the new concept.572 492 template<typename Graph> 573 493 class UndirGraphWrapper : public GraphWrapper<Graph> { … … 602 522 }; 603 523 604 //FIXME InEdgeIt605 524 typedef OutEdgeIt InEdgeIt; 606 525 607 526 using GraphWrapper<Graph>::first; 608 // NodeIt& first(NodeIt& i) const {609 // i=NodeIt(*this); return i;610 // }611 527 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 612 528 i=OutEdgeIt(*this, p); return i; 613 529 } 614 //FIXME615 // InEdgeIt& first(InEdgeIt& i, const Node& p) const {616 // i=InEdgeIt(*this, p); return i;617 // }618 // EdgeIt& first(EdgeIt& i) const {619 // i=EdgeIt(*this); return i;620 // }621 530 622 531 using GraphWrapper<Graph>::next; 623 // NodeIt& next(NodeIt& n) const { 624 // GraphWrapper<Graph>::next(n); 625 // return n; 626 // } 532 627 533 OutEdgeIt& next(OutEdgeIt& e) const { 628 534 if (e.out_or_in) { … … 636 542 return e; 637 543 } 638 //FIXME InEdgeIt639 // EdgeIt& next(EdgeIt& e) const {640 // GraphWrapper<Graph>::next(n);641 // // graph->next(e.e);642 // return e;643 // }644 544 645 545 Node aNode(const OutEdgeIt& e) const { … … 757 657 Graph::Edge(e), backward(_backward) { } 758 658 Edge(Invalid i) : Graph::Edge(i), backward(true) { } 759 //the unique invalid iterator760 // friend bool operator==(const Edge& u, const Edge& v) {761 // return (u.backward==v.backward &&762 // static_cast<typename Graph::Edge>(u)==763 // static_cast<typename Graph::Edge>(v));764 // }765 // friend bool operator!=(const Edge& u, const Edge& v) {766 // return (u.backward!=v.backward ||767 // static_cast<typename Graph::Edge>(u)!=768 // static_cast<typename Graph::Edge>(v));769 // }770 659 bool operator==(const Edge& v) const { 771 660 return (this->backward==v.backward && … … 789 678 OutEdgeIt() { } 790 679 OutEdgeIt(Invalid i) : Edge(i) { } 791 //the unique invalid iterator792 680 OutEdgeIt(const SubBidirGraphWrapper<Graph, 793 681 ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) : … … 847 735 InEdgeIt() { } 848 736 InEdgeIt(Invalid i) : Edge(i) { } 849 //the unique invalid iterator850 737 InEdgeIt(const SubBidirGraphWrapper<Graph, 851 738 ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) : … … 905 792 EdgeIt() { } 906 793 EdgeIt(Invalid i) : Edge(i) { } 907 //the unique invalid iterator908 794 EdgeIt(const SubBidirGraphWrapper<Graph, 909 795 ForwardFilterMap, BackwardFilterMap>& _gw) : … … 954 840 955 841 using GraphWrapper<Graph>::first; 956 // NodeIt& first(NodeIt& i) const {957 // i=NodeIt(*this); return i;958 // }959 842 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 960 843 i=OutEdgeIt(*this, p); return i; … … 967 850 } 968 851 969 // using GraphWrapper<Graph>::next;970 // // NodeIt& next(NodeIt& n) const { GraphWrapper<Graph>::next(n); return n; }971 // OutEdgeIt& next(OutEdgeIt& e) const {972 // if (!e.backward) {973 // Node v=this->graph->aNode(e.out);974 // this->graph->next(e.out);975 // while(this->graph->valid(e.out) && !(*forward_filter)[e]) {976 // this->graph->next(e.out); }977 // if (!this->graph->valid(e.out)) {978 // e.backward=true;979 // this->graph->first(e.in, v);980 // while(this->graph->valid(e.in) && !(*backward_filter)[e]) {981 // this->graph->next(e.in); }982 // }983 // } else {984 // this->graph->next(e.in);985 // while(this->graph->valid(e.in) && !(*backward_filter)[e]) {986 // this->graph->next(e.in); }987 // }988 // return e;989 // }990 // // FIXME Not tested991 // InEdgeIt& next(InEdgeIt& e) const {992 // if (!e.backward) {993 // Node v=this->graph->aNode(e.in);994 // this->graph->next(e.in);995 // while(this->graph->valid(e.in) && !(*forward_filter)[e]) {996 // this->graph->next(e.in); }997 // if (!this->graph->valid(e.in)) {998 // e.backward=true;999 // this->graph->first(e.out, v);1000 // while(this->graph->valid(e.out) && !(*backward_filter)[e]) {1001 // this->graph->next(e.out); }1002 // }1003 // } else {1004 // this->graph->next(e.out);1005 // while(this->graph->valid(e.out) && !(*backward_filter)[e]) {1006 // this->graph->next(e.out); }1007 // }1008 // return e;1009 // }1010 // EdgeIt& next(EdgeIt& e) const {1011 // if (!e.backward) {1012 // this->graph->next(e.e);1013 // while(this->graph->valid(e.e) && !(*forward_filter)[e]) {1014 // this->graph->next(e.e); }1015 // if (!this->graph->valid(e.e)) {1016 // e.backward=true;1017 // this->graph->first(e.e);1018 // while(this->graph->valid(e.e) && !(*backward_filter)[e]) {1019 // this->graph->next(e.e); }1020 // }1021 // } else {1022 // this->graph->next(e.e);1023 // while(this->graph->valid(e.e) && !(*backward_filter)[e]) {1024 // this->graph->next(e.e); }1025 // }1026 // return e;1027 // }1028 852 1029 853 Node tail(Edge e) const { … … 1031 855 Node head(Edge e) const { 1032 856 return ((!e.backward) ? this->graph->head(e) : this->graph->tail(e)); } 1033 1034 // Node aNode(OutEdgeIt e) const {1035 // return ((!e.backward) ? this->graph->aNode(e.out) :1036 // this->graph->aNode(e.in)); }1037 // Node bNode(OutEdgeIt e) const {1038 // return ((!e.backward) ? this->graph->bNode(e.out) :1039 // this->graph->bNode(e.in)); }1040 1041 // Node aNode(InEdgeIt e) const {1042 // return ((!e.backward) ? this->graph->aNode(e.in) :1043 // this->graph->aNode(e.out)); }1044 // Node bNode(InEdgeIt e) const {1045 // return ((!e.backward) ? this->graph->bNode(e.in) :1046 // this->graph->bNode(e.out)); }1047 857 1048 858 /// Gives back the opposite edge. … … 1096 906 backward_map.update(); 1097 907 } 1098 // T get(Edge e) const {1099 // if (e.out_or_in)1100 // return forward_map.get(e.out);1101 // else1102 // return backward_map.get(e.in);1103 // }1104 908 }; 1105 909 … … 1183 987 /*graph(&_graph),*/ capacity(&_capacity), flow(&_flow) { } 1184 988 ResForwardFilter() : /*graph(0),*/ capacity(0), flow(0) { } 1185 //void setGraph(const Graph& _graph) { graph=&_graph; }1186 989 void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; } 1187 990 void setFlow(const FlowMap& _flow) { flow=&_flow; } … … 1194 997 typename CapacityMap, typename FlowMap> 1195 998 class ResBackwardFilter { 1196 //const Graph* graph;1197 999 const CapacityMap* capacity; 1198 1000 const FlowMap* flow; … … 1202 1004 /*graph(&_graph),*/ capacity(&_capacity), flow(&_flow) { } 1203 1005 ResBackwardFilter() : /*graph(0),*/ capacity(0), flow(0) { } 1204 //void setGraph(const Graph& _graph) { graph=&_graph; }1205 1006 void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; } 1206 1007 void setFlow(const FlowMap& _flow) { flow=&_flow; } … … 1243 1044 backward_filter.setFlow(_flow); 1244 1045 } 1245 // /// \bug does graph reference needed in filtermaps??1246 // void setGraph(const Graph& _graph) {1247 // Parent::setGraph(_graph);1248 // forward_filter.setGraph(_graph);1249 // backward_filter.setGraph(_graph);1250 // }1251 1046 public: 1252 1047 ResGraphWrapper(Graph& _graph, const CapacityMap& _capacity, … … 1262 1057 typedef typename Parent::Edge Edge; 1263 1058 1264 // bool forward(const Parent::Edge& e) const { return Parent::forward(e); }1265 //bool backward(const Edge& e) const { return e.backward; }1266 1267 1059 void augment(const Edge& e, Number a) const { 1268 1060 if (Parent::forward(e)) 1269 // flow->set(e.out, flow->get(e.out)+a);1270 1061 flow->set(e, (*flow)[e]+a); 1271 1062 else 1272 //flow->set(e.in, flow->get(e.in)-a);1273 1063 flow->set(e, (*flow)[e]-a); 1274 }1275 1276 /// \deprecated1277 ///1278 Number resCap(const Edge& e) const {1279 if (Parent::forward(e))1280 // return (capacity->get(e.out)-flow->get(e.out));1281 return ((*capacity)[e]-(*flow)[e]);1282 else1283 // return (flow->get(e.in));1284 return ((*flow)[e]);1285 1064 } 1286 1065 … … 1298 1077 Number operator[](const Edge& e) const { 1299 1078 if (res_graph->forward(e)) 1300 // return (capacity->get(e.out)-flow->get(e.out));1301 1079 return (*(res_graph->capacity))[e]-(*(res_graph->flow))[e]; 1302 1080 else 1303 // return (flow->get(e.in));1304 1081 return (*(res_graph->flow))[e]; 1305 1082 } 1306 /// \bug not needed with dynamic maps, or does it?1307 void update() { }1308 1083 }; 1309 1084 … … 1342 1117 public: 1343 1118 OutEdgeIt() { } 1344 //OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }1345 1119 OutEdgeIt(Invalid i) : Edge(i) { } 1346 1120 OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, … … 1356 1130 } 1357 1131 }; 1358 // class InEdgeIt {1359 // friend class GraphWrapper<Graph>;1360 // friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;1361 // // typedef typename Graph::InEdgeIt GraphInEdgeIt;1362 // typename Graph::InEdgeIt e;1363 // public:1364 // InEdgeIt() { }1365 // InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }1366 // InEdgeIt(const Invalid& i) : e(i) { }1367 // InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,1368 // const Node& _n) :1369 // e(*(_G.graph), typename Graph::Node(_n)) { }1370 // operator Edge() const { return Edge(typename Graph::Edge(e)); }1371 // };1372 //typedef typename Graph::SymEdgeIt SymEdgeIt;1373 // class EdgeIt {1374 // friend class GraphWrapper<Graph>;1375 // friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;1376 // // typedef typename Graph::EdgeIt GraphEdgeIt;1377 // typename Graph::EdgeIt e;1378 // public:1379 // EdgeIt() { }1380 // EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }1381 // EdgeIt(const Invalid& i) : e(i) { }1382 // EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :1383 // e(*(_G.graph)) { }1384 // operator Edge() const { return Edge(typename Graph::Edge(e)); }1385 // };1386 1132 1387 1133 using GraphWrapper<Graph>::first; 1388 // NodeIt& first(NodeIt& i) const {1389 // i=NodeIt(*this); return i;1390 // }1391 1134 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 1392 1135 i=OutEdgeIt(*this, p); return i; 1393 1136 } 1394 // InEdgeIt& first(InEdgeIt& i, const Node& p) const {1395 // i=InEdgeIt(*this, p); return i;1396 // }1397 // EdgeIt& first(EdgeIt& i) const {1398 // i=EdgeIt(*this); return i;1399 // }1400 1401 // using GraphWrapper<Graph>::next;1402 // // NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }1403 // OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }1404 // InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }1405 // EdgeIt& next(EdgeIt& i) const { this->graph->next(i.e); return i; }1406 1407 // Node aNode(const OutEdgeIt& e) const {1408 // return Node(this->graph->aNode(e.e)); }1409 // Node aNode(const InEdgeIt& e) const {1410 // return Node(this->graph->aNode(e.e)); }1411 // Node bNode(const OutEdgeIt& e) const {1412 // return Node(this->graph->bNode(e.e)); }1413 // Node bNode(const InEdgeIt& e) const {1414 // return Node(this->graph->bNode(e.e)); }1415 1416 1137 void erase(const Edge& e) const { 1417 1138 Node n=tail(e);
Note: See TracChangeset
for help on using the changeset viewer.