Changeset 266:4cec4981dfd1 in lemon-0.x for src/work/marci/graph_wrapper.h
- Timestamp:
- 03/30/04 19:16:53 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@372
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/graph_wrapper.h
r265 r266 124 124 template<typename T> class NodeMap : public Graph::NodeMap<T> { 125 125 public: 126 NodeMap(const TrivGraphWrapper<Graph>& _G) : 126 NodeMap(const TrivGraphWrapper<Graph>& _G) : 127 127 Graph::NodeMap<T>(*(_G.graph)) { } 128 128 NodeMap(const TrivGraphWrapper<Graph>& _G, T a) : … … 132 132 template<typename T> class EdgeMap : public Graph::EdgeMap<T> { 133 133 public: 134 EdgeMap(const TrivGraphWrapper<Graph>& _G) : 134 EdgeMap(const TrivGraphWrapper<Graph>& _G) : 135 135 Graph::EdgeMap<T>(*(_G.graph)) { } 136 136 EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) : 137 137 Graph::EdgeMap<T>(*(_G.graph), a) { } 138 }; 139 140 template<typename Map, typename T> class NodeMapWrapper { 141 protected: 142 Map* map; 143 public: 144 NodeMapWrapper(Map& _map) : map(&_map) { } 145 //template<typename T> 146 void set(Node n, T a) { map->set(n, a); } 147 //template<typename T> 148 T get(Node n) const { return map->get(n); } 149 }; 150 151 template<typename Map, typename T> class EdgeMapWrapper { 152 protected: 153 Map* map; 154 public: 155 EdgeMapWrapper(Map& _map) : map(&_map) { } 156 //template<typename T> 157 void set(Edge n, T a) { map->set(n, a); } 158 //template<typename T> 159 T get(Edge n) const { return map->get(n); } 138 160 }; 139 161 }; … … 248 270 template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 249 271 public: 250 NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) : 272 NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) : 251 273 GraphWrapper::NodeMap<T>(_G.gw) { } 252 274 NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) : … … 256 278 template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> { 257 279 public: 258 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) : 280 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) : 259 281 GraphWrapper::EdgeMap<T>(_G.gw) { } 260 282 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) : … … 760 782 template<typename I> I& first(I& i) const { gw.first(i); return i; } 761 783 template<typename I, typename P> I& first(I& i, const P& p) const { 762 g raph->first(i, p); return i; }784 gw.first(i, p); return i; } 763 785 764 786 OutEdgeIt& next(OutEdgeIt& e) const { … … 912 934 913 935 914 template<typename Graph , typename Number, typename FlowMap, typename CapacityMap>915 class ResGraphWrapper {936 template<typename GraphWrapper, typename Number, typename FlowMap, typename CapacityMap> 937 class ResGraphWrapper : public GraphWrapperSkeleton<GraphWrapper>{ 916 938 public: 917 939 //typedef Graph BaseGraph; 918 typedef TrivGraphWrapper<const Graph> GraphWrapper;919 typedef typename GraphWrapper ::Node Node;920 typedef typename GraphWrapper ::NodeIt NodeIt;940 //typedef TrivGraphWrapper<const Graph> GraphWrapper; 941 typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node; 942 typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt; 921 943 private: 922 typedef typename GraphWrapper ::OutEdgeIt OldOutEdgeIt;923 typedef typename GraphWrapper ::InEdgeIt OldInEdgeIt;944 typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OldOutEdgeIt; 945 typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OldInEdgeIt; 924 946 protected: 925 947 //const Graph* graph; 926 GraphWrapper gw;948 //GraphWrapper gw; 927 949 FlowMap* flow; 928 950 const CapacityMap* capacity; 929 951 public: 930 952 931 ResGraphWrapper(const Graph& _G, FlowMap& _flow, 932 const CapacityMap& _capacity) : 933 gw(_G), flow(&_flow), capacity(&_capacity) { } 953 ResGraphWrapper(const GraphWrapper& _gw, FlowMap& _flow, 954 const CapacityMap& _capacity) : 955 GraphWrapperSkeleton<GraphWrapper>(_gw), 956 flow(&_flow), capacity(&_capacity) { } 934 957 935 958 //void setGraph(const Graph& _graph) { graph = &_graph; } … … 942 965 943 966 class Edge { 944 friend class ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>;967 friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>; 945 968 protected: 946 969 bool out_or_in; //true, iff out … … 968 991 969 992 class OutEdgeIt : public Edge { 970 friend class ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>;993 friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>; 971 994 public: 972 995 OutEdgeIt() { } … … 975 998 OutEdgeIt(const Invalid& i) : Edge(i) { } 976 999 protected: 977 OutEdgeIt(const ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {1000 OutEdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() { 978 1001 resG.gw.first(out, v); 979 1002 while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); } … … 1007 1030 1008 1031 class EdgeIt : public Edge { 1009 friend class ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>;1032 friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>; 1010 1033 NodeIt v; 1011 1034 public: … … 1013 1036 //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { } 1014 1037 EdgeIt(const Invalid& i) : Edge(i) { } 1015 EdgeIt(const ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>& resG) : Edge() {1038 EdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG) : Edge() { 1016 1039 resG.gw.first(v); 1017 1040 if (resG.gw.valid(v)) resG.gw.first(out, v); else out=/*OldOutEdgeIt*/(INVALID); … … 1067 1090 }; 1068 1091 1069 NodeIt& first(NodeIt& v) const { return gw.first(v); }1092 NodeIt& first(NodeIt& v) const { gw.first(v); return v; } 1070 1093 OutEdgeIt& first(OutEdgeIt& e, Node v) const { 1071 1094 e=OutEdgeIt(*this, v); … … 1186 1209 } 1187 1210 1188 template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {1189 public:1190 NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)1191 : GraphWrapper::NodeMap<T>(_G.gw) { }1192 NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,1193 T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }1194 };1211 // template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 1212 // public: 1213 // NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) 1214 // : GraphWrapper::NodeMap<T>(_G.gw) { } 1215 // NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, 1216 // T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { } 1217 // }; 1195 1218 1196 1219 // template <typename T> … … 1208 1231 typename GraphWrapper::EdgeMap<T> forward_map, backward_map; 1209 1232 public: 1210 EdgeMap(const ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }1211 EdgeMap(const ResGraphWrapper<Graph , Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }1233 EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { } 1234 EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { } 1212 1235 void set(Edge e, T a) { 1213 1236 if (e.out_or_in) … … 1225 1248 }; 1226 1249 1227 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>1228 class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {1229 protected:1230 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;1231 //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;1232 public:1233 ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow,1234 const CapacityMap& _capacity) :1235 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity),1236 first_out_edges(*this) /*, dist(*this)*/ {1237 for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {1238 OutEdgeIt e;1239 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);1240 first_out_edges.set(n, e);1241 }1242 }1243 1244 //void setGraph(Graph& _graph) { graph = &_graph; }1245 //Graph& getGraph() const { return (*graph); }1246 1247 //TrivGraphWrapper() : graph(0) { }1248 //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }1249 1250 //typedef Graph BaseGraph;1251 1252 //typedef typename Graph::Node Node;1253 //typedef typename Graph::NodeIt NodeIt;1254 1255 //typedef typename Graph::Edge Edge;1256 //typedef typename Graph::OutEdgeIt OutEdgeIt;1257 //typedef typename Graph::InEdgeIt InEdgeIt;1258 //typedef typename Graph::SymEdgeIt SymEdgeIt;1259 //typedef typename Graph::EdgeIt EdgeIt;1260 1261 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;1262 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;1263 1264 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;1265 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;1266 //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;1267 //typedef typename Graph::SymEdgeIt SymEdgeIt;1268 //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;1269 1270 NodeIt& first(NodeIt& n) const {1271 return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);1272 }1273 1274 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {1275 e=first_out_edges.get(n);1276 return e;1277 }1278 1279 //ROSSZ template<typename I> I& first(I& i) const { return first(i); }1280 //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const {1281 // return first(i, p); }1282 1283 //template<typename I> I getNext(const I& i) const {1284 // return gw.getNext(i); }1285 //template<typename I> I& next(I &i) const { return gw.next(i); }1286 1287 template< typename It > It first() const {1288 It e; first(e); return e; }1289 1290 template< typename It > It first(const Node& v) const {1291 It e; first(e, v); return e; }1292 1293 //Node head(const Edge& e) const { return gw.head(e); }1294 //Node tail(const Edge& e) const { return gw.tail(e); }1295 1296 //template<typename I> bool valid(const I& i) const1297 // { return gw.valid(i); }1298 1299 //int nodeNum() const { return gw.nodeNum(); }1300 //int edgeNum() const { return gw.edgeNum(); }1301 1302 //template<typename I> Node aNode(const I& e) const {1303 // return gw.aNode(e); }1304 //template<typename I> Node bNode(const I& e) const {1305 // return gw.bNode(e); }1306 1307 //Node addNode() const { return gw.addNode(); }1308 //Edge addEdge(const Node& tail, const Node& head) const {1309 // return gw.addEdge(tail, head); }1310 1311 //void erase(const OutEdgeIt& e) {1312 // first_out_edge(this->tail(e))=e;1313 //}1314 void erase(const Edge& e) {1315 OutEdgeIt f(e);1316 next(f);1317 first_out_edges.set(this->tail(e), f);1318 }1319 //template<typename I> void erase(const I& i) const { gw.erase(i); }1320 1321 //void clear() const { gw.clear(); }1322 1323 template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {1324 public:1325 NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :1326 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }1327 NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :1328 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }1329 };1330 1331 template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {1332 public:1333 EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :1334 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }1335 EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :1336 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }1337 };1338 };1339 1340 template<typename GraphWrapper>1341 class FilterGraphWrapper {1342 };1343 1344 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>1345 class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {1346 1347 //Graph* graph;1348 1349 public:1350 //typedef Graph BaseGraph;1351 1352 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;1353 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;1354 1355 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;1356 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;1357 //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;1358 //typedef typename Graph::SymEdgeIt SymEdgeIt;1359 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;1360 1361 //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;1362 1363 public:1364 FilterGraphWrapper(const Graph& _G, FlowMap& _flow,1365 const CapacityMap& _capacity) :1366 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) {1367 }1368 1369 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {1370 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);1371 while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))1372 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);1373 return e;1374 }1375 1376 NodeIt& next(NodeIt& e) const {1377 return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);1378 }1379 1380 OutEdgeIt& next(OutEdgeIt& e) const {1381 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);1382 while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))1383 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);1384 return e;1385 }1386 1387 NodeIt& first(NodeIt& n) const {1388 return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);1389 }1390 1391 void erase(const Edge& e) {1392 OutEdgeIt f(e);1393 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);1394 while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))1395 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);1396 first_out_edges.set(this->tail(e), f);1397 }1398 1399 //TrivGraphWrapper() : graph(0) { }1400 //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }1401 1402 //void setGraph(Graph& _graph) { graph = &_graph; }1403 //Graph& getGraph() const { return (*graph); }1404 1405 //template<typename I> I& first(I& i) const { return gw.first(i); }1406 //template<typename I, typename P> I& first(I& i, const P& p) const {1407 // return gw.first(i, p); }1408 1409 //template<typename I> I getNext(const I& i) const {1410 // return gw.getNext(i); }1411 //template<typename I> I& next(I &i) const { return gw.next(i); }1412 1413 template< typename It > It first() const {1414 It e; first(e); return e; }1415 1416 template< typename It > It first(const Node& v) const {1417 It e; first(e, v); return e; }1418 1419 //Node head(const Edge& e) const { return gw.head(e); }1420 //Node tail(const Edge& e) const { return gw.tail(e); }1421 1422 //template<typename I> bool valid(const I& i) const1423 // { return gw.valid(i); }1424 1425 //template<typename I> void setInvalid(const I &i);1426 //{ return gw.setInvalid(i); }1427 1428 //int nodeNum() const { return gw.nodeNum(); }1429 //int edgeNum() const { return gw.edgeNum(); }1430 1431 //template<typename I> Node aNode(const I& e) const {1432 // return gw.aNode(e); }1433 //template<typename I> Node bNode(const I& e) const {1434 // return gw.bNode(e); }1435 1436 //Node addNode() const { return gw.addNode(); }1437 //Edge addEdge(const Node& tail, const Node& head) const {1438 // return gw.addEdge(tail, head); }1439 1440 //template<typename I> void erase(const I& i) const { gw.erase(i); }1441 1442 //void clear() const { gw.clear(); }1443 1444 template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {1445 public:1446 NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :1447 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }1448 NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :1449 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }1450 };1451 1452 template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {1453 public:1454 EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :1455 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }1456 EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :1457 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }1458 };1459 1460 public:1461 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;1462 1463 };1250 // template<typename Graph, typename Number, typename FlowMap, typename CapacityMap> 1251 // class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> { 1252 // protected: 1253 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges; 1254 // //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist; 1255 // public: 1256 // ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow, 1257 // const CapacityMap& _capacity) : 1258 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), 1259 // first_out_edges(*this) /*, dist(*this)*/ { 1260 // for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) { 1261 // OutEdgeIt e; 1262 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n); 1263 // first_out_edges.set(n, e); 1264 // } 1265 // } 1266 1267 // //void setGraph(Graph& _graph) { graph = &_graph; } 1268 // //Graph& getGraph() const { return (*graph); } 1269 1270 // //TrivGraphWrapper() : graph(0) { } 1271 // //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { } 1272 1273 // //typedef Graph BaseGraph; 1274 1275 // //typedef typename Graph::Node Node; 1276 // //typedef typename Graph::NodeIt NodeIt; 1277 1278 // //typedef typename Graph::Edge Edge; 1279 // //typedef typename Graph::OutEdgeIt OutEdgeIt; 1280 // //typedef typename Graph::InEdgeIt InEdgeIt; 1281 // //typedef typename Graph::SymEdgeIt SymEdgeIt; 1282 // //typedef typename Graph::EdgeIt EdgeIt; 1283 1284 // typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node; 1285 // typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt; 1286 1287 // typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge; 1288 // typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt; 1289 // //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt; 1290 // //typedef typename Graph::SymEdgeIt SymEdgeIt; 1291 // //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt; 1292 1293 // NodeIt& first(NodeIt& n) const { 1294 // return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n); 1295 // } 1296 1297 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { 1298 // e=first_out_edges.get(n); 1299 // return e; 1300 // } 1301 1302 // //ROSSZ template<typename I> I& first(I& i) const { return first(i); } 1303 // //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const { 1304 // // return first(i, p); } 1305 1306 // //template<typename I> I getNext(const I& i) const { 1307 // // return gw.getNext(i); } 1308 // //template<typename I> I& next(I &i) const { return gw.next(i); } 1309 1310 // template< typename It > It first() const { 1311 // It e; first(e); return e; } 1312 1313 // template< typename It > It first(const Node& v) const { 1314 // It e; first(e, v); return e; } 1315 1316 // //Node head(const Edge& e) const { return gw.head(e); } 1317 // //Node tail(const Edge& e) const { return gw.tail(e); } 1318 1319 // //template<typename I> bool valid(const I& i) const 1320 // // { return gw.valid(i); } 1321 1322 // //int nodeNum() const { return gw.nodeNum(); } 1323 // //int edgeNum() const { return gw.edgeNum(); } 1324 1325 // //template<typename I> Node aNode(const I& e) const { 1326 // // return gw.aNode(e); } 1327 // //template<typename I> Node bNode(const I& e) const { 1328 // // return gw.bNode(e); } 1329 1330 // //Node addNode() const { return gw.addNode(); } 1331 // //Edge addEdge(const Node& tail, const Node& head) const { 1332 // // return gw.addEdge(tail, head); } 1333 1334 // //void erase(const OutEdgeIt& e) { 1335 // // first_out_edge(this->tail(e))=e; 1336 // //} 1337 // void erase(const Edge& e) { 1338 // OutEdgeIt f(e); 1339 // next(f); 1340 // first_out_edges.set(this->tail(e), f); 1341 // } 1342 // //template<typename I> void erase(const I& i) const { gw.erase(i); } 1343 1344 // //void clear() const { gw.clear(); } 1345 1346 // template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 1347 // public: 1348 // NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 1349 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { } 1350 // NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 1351 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { } 1352 // }; 1353 1354 // template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 1355 // public: 1356 // EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 1357 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { } 1358 // EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 1359 // ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { } 1360 // }; 1361 // }; 1362 1363 // template<typename GraphWrapper> 1364 // class FilterGraphWrapper { 1365 // }; 1366 1367 // template<typename Graph, typename Number, typename FlowMap, typename CapacityMap> 1368 // class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> { 1369 1370 // //Graph* graph; 1371 1372 // public: 1373 // //typedef Graph BaseGraph; 1374 1375 // typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node; 1376 // typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt; 1377 1378 // typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge; 1379 // typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt; 1380 // //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt; 1381 // //typedef typename Graph::SymEdgeIt SymEdgeIt; 1382 // typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt; 1383 1384 // //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges; 1385 1386 // public: 1387 // FilterGraphWrapper(const Graph& _G, FlowMap& _flow, 1388 // const CapacityMap& _capacity) : 1389 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) { 1390 // } 1391 1392 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { 1393 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n); 1394 // while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e)))) 1395 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e); 1396 // return e; 1397 // } 1398 1399 // NodeIt& next(NodeIt& e) const { 1400 // return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e); 1401 // } 1402 1403 // OutEdgeIt& next(OutEdgeIt& e) const { 1404 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e); 1405 // while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e)))) 1406 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e); 1407 // return e; 1408 // } 1409 1410 // NodeIt& first(NodeIt& n) const { 1411 // return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n); 1412 // } 1413 1414 // void erase(const Edge& e) { 1415 // OutEdgeIt f(e); 1416 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f); 1417 // while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f)))) 1418 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f); 1419 // first_out_edges.set(this->tail(e), f); 1420 // } 1421 1422 // //TrivGraphWrapper() : graph(0) { } 1423 // //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { } 1424 1425 // //void setGraph(Graph& _graph) { graph = &_graph; } 1426 // //Graph& getGraph() const { return (*graph); } 1427 1428 // //template<typename I> I& first(I& i) const { return gw.first(i); } 1429 // //template<typename I, typename P> I& first(I& i, const P& p) const { 1430 // // return gw.first(i, p); } 1431 1432 // //template<typename I> I getNext(const I& i) const { 1433 // // return gw.getNext(i); } 1434 // //template<typename I> I& next(I &i) const { return gw.next(i); } 1435 1436 // template< typename It > It first() const { 1437 // It e; first(e); return e; } 1438 1439 // template< typename It > It first(const Node& v) const { 1440 // It e; first(e, v); return e; } 1441 1442 // //Node head(const Edge& e) const { return gw.head(e); } 1443 // //Node tail(const Edge& e) const { return gw.tail(e); } 1444 1445 // //template<typename I> bool valid(const I& i) const 1446 // // { return gw.valid(i); } 1447 1448 // //template<typename I> void setInvalid(const I &i); 1449 // //{ return gw.setInvalid(i); } 1450 1451 // //int nodeNum() const { return gw.nodeNum(); } 1452 // //int edgeNum() const { return gw.edgeNum(); } 1453 1454 // //template<typename I> Node aNode(const I& e) const { 1455 // // return gw.aNode(e); } 1456 // //template<typename I> Node bNode(const I& e) const { 1457 // // return gw.bNode(e); } 1458 1459 // //Node addNode() const { return gw.addNode(); } 1460 // //Edge addEdge(const Node& tail, const Node& head) const { 1461 // // return gw.addEdge(tail, head); } 1462 1463 // //template<typename I> void erase(const I& i) const { gw.erase(i); } 1464 1465 // //void clear() const { gw.clear(); } 1466 1467 // template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 1468 // public: 1469 // NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 1470 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { } 1471 // NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 1472 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { } 1473 // }; 1474 1475 // template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 1476 // public: 1477 // EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 1478 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { } 1479 // EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 1480 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { } 1481 // }; 1482 1483 // public: 1484 // ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist; 1485 1486 // }; 1464 1487 1465 1488
Note: See TracChangeset
for help on using the changeset viewer.