src/hugo/graph_wrapper.h
changeset 659 c5984e925384
parent 656 9971eb8bfbe8
child 660 edb42cb9d352
equal deleted inserted replaced
20:8b03e8564f5a 21:c6ef0d719642
  1373 
  1373 
  1374 
  1374 
  1375 
  1375 
  1376   template<typename Graph, typename Number,
  1376   template<typename Graph, typename Number,
  1377 	   typename CapacityMap, typename FlowMap>
  1377 	   typename CapacityMap, typename FlowMap>
  1378   class ForwardFilter {
  1378   class ResForwardFilter {
  1379     const Graph* graph;
  1379     //    const Graph* graph;
  1380     const CapacityMap* capacity;
  1380     const CapacityMap* capacity;
  1381     const FlowMap* flow;
  1381     const FlowMap* flow;
  1382   public:
  1382   public:
  1383     void setGraph(const Graph& _graph) { graph=&_graph; }
  1383     ResForwardFilter(/*const Graph& _graph, */
       
  1384 		     const CapacityMap& _capacity, const FlowMap& _flow) :
       
  1385       /*graph(&_graph),*/ capacity(&_capacity), flow(&_flow) { }
       
  1386     ResForwardFilter() : /*graph(0),*/ capacity(0), flow(0) { }
       
  1387     //void setGraph(const Graph& _graph) { graph=&_graph; }
  1384     void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
  1388     void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
  1385     void setFlow(const FlowMap& _flow) { flow=&_flow; }
  1389     void setFlow(const FlowMap& _flow) { flow=&_flow; }
  1386     ForwardFilter(const Graph& _graph, 
       
  1387 		  const CapacityMap& _capacity, const FlowMap& _flow) :
       
  1388       graph(&_graph), capacity(&_capacity), flow(&_flow) { }
       
  1389     bool operator[](const typename Graph::Edge& e) const {
  1390     bool operator[](const typename Graph::Edge& e) const {
  1390       return ((*flow)[e] < (*capacity)[e]);
  1391       return ((*flow)[e] < (*capacity)[e]);
  1391     }
  1392     }
  1392   };
  1393   };
  1393 
  1394 
  1394   template<typename Graph, typename Number,
  1395   template<typename Graph, typename Number,
  1395 	   typename CapacityMap, typename FlowMap>
  1396 	   typename CapacityMap, typename FlowMap>
  1396   class BackwardFilter {
  1397   class ResBackwardFilter {
  1397     const Graph* graph;
  1398     //const Graph* graph;
  1398     const CapacityMap* capacity;
  1399     const CapacityMap* capacity;
  1399     const FlowMap* flow;
  1400     const FlowMap* flow;
  1400   public:
  1401   public:
  1401     void setGraph(const Graph& _graph) { graph=&_graph; }
  1402     ResBackwardFilter(/*const Graph& _graph,*/ 
       
  1403 		      const CapacityMap& _capacity, const FlowMap& _flow) :
       
  1404       /*graph(&_graph),*/ capacity(&_capacity), flow(&_flow) { }
       
  1405     ResBackwardFilter() : /*graph(0),*/ capacity(0), flow(0) { }
       
  1406     //void setGraph(const Graph& _graph) { graph=&_graph; }
  1402     void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
  1407     void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
  1403     void setFlow(const FlowMap& _flow) { flow=&_flow; }
  1408     void setFlow(const FlowMap& _flow) { flow=&_flow; }
  1404     BackwardFilter(const Graph& _graph, 
       
  1405 		   const CapacityMap& _capacity, const FlowMap& _flow) :
       
  1406       graph(&_graph), capacity(&_capacity), flow(&_flow) { }
       
  1407     bool operator[](const typename Graph::Edge& e) const {
  1409     bool operator[](const typename Graph::Edge& e) const {
  1408       return (0 < (*flow)[e]);
  1410       return (0 < (*flow)[e]);
  1409     }
  1411     }
  1410   };
  1412   };
  1411 
  1413 
  1416   template<typename Graph, typename Number, 
  1418   template<typename Graph, typename Number, 
  1417 	   typename CapacityMap, typename FlowMap>
  1419 	   typename CapacityMap, typename FlowMap>
  1418   class ResGraphWrapper : 
  1420   class ResGraphWrapper : 
  1419     public SubBidirGraphWrapper< 
  1421     public SubBidirGraphWrapper< 
  1420     Graph, 
  1422     Graph, 
  1421     ForwardFilter<Graph, Number, CapacityMap, FlowMap>,  
  1423     ResForwardFilter<Graph, Number, CapacityMap, FlowMap>,  
  1422     BackwardFilter<Graph, Number, CapacityMap, FlowMap> > {
  1424     ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> > {
  1423   public:
  1425   public:
  1424     typedef SubBidirGraphWrapper< 
  1426     typedef SubBidirGraphWrapper< 
  1425       Graph, 
  1427       Graph, 
  1426       ForwardFilter<Graph, Number, CapacityMap, FlowMap>,  
  1428       ResForwardFilter<Graph, Number, CapacityMap, FlowMap>,  
  1427       BackwardFilter<Graph, Number, CapacityMap, FlowMap> > Parent;
  1429       ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> > Parent;
  1428   protected:
  1430   protected:
  1429     const CapacityMap* capacity;
  1431     const CapacityMap* capacity;
  1430     FlowMap* flow;
  1432     FlowMap* flow;
  1431     ForwardFilter<Graph, Number, CapacityMap, FlowMap> forward_filter;
  1433     ResForwardFilter<Graph, Number, CapacityMap, FlowMap> forward_filter;
  1432     BackwardFilter<Graph, Number, CapacityMap, FlowMap> backward_filter;
  1434     ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> backward_filter;
  1433 //     ResGraphWrapper() : Parent(), 
  1435     ResGraphWrapper() : Parent(), 
  1434 // 			capacity(0), flow(0) { }
  1436  			capacity(0), flow(0) { }
  1435 //     void setCapacityMap(const CapacityMap& _capacity) {
  1437     void setCapacityMap(const CapacityMap& _capacity) {
  1436 //       capacity=&_capacity;
  1438       capacity=&_capacity;
  1437 //     }
  1439       forward_filter.setCapacity(_capacity);
  1438 //     void setFlowMap(FlowMap& _flow) {
  1440       backward_filter.setCapacity(_capacity);
  1439 //       flow=&_flow;
  1441     }
       
  1442     void setFlowMap(FlowMap& _flow) {
       
  1443       flow=&_flow;
       
  1444       forward_filter.setFlow(_flow);
       
  1445       backward_filter.setFlow(_flow);
       
  1446     }
       
  1447 //     /// \bug does graph reference needed in filtermaps??
       
  1448 //     void setGraph(const Graph& _graph) { 
       
  1449 //       Parent::setGraph(_graph);
       
  1450 //       forward_filter.setGraph(_graph);
       
  1451 //       backward_filter.setGraph(_graph);
  1440 //     }
  1452 //     }
  1441   public:
  1453   public:
  1442     ResGraphWrapper(Graph& _graph, const CapacityMap& _capacity, 
  1454     ResGraphWrapper(Graph& _graph, const CapacityMap& _capacity, 
  1443 		       FlowMap& _flow) : 
  1455 		       FlowMap& _flow) : 
  1444       Parent(), capacity(&_capacity), flow(&_flow), 
  1456       Parent(), capacity(&_capacity), flow(&_flow), 
  1445       forward_filter(_graph, _capacity, _flow), 
  1457       forward_filter(/*_graph,*/ _capacity, _flow), 
  1446       backward_filter(_graph, _capacity, _flow) {
  1458       backward_filter(/*_graph,*/ _capacity, _flow) {
  1447       Parent::setGraph(_graph);
  1459       Parent::setGraph(_graph);
  1448       Parent::setForwardFilterMap(forward_filter);
  1460       Parent::setForwardFilterMap(forward_filter);
  1449       Parent::setBackwardFilterMap(backward_filter);
  1461       Parent::setBackwardFilterMap(backward_filter);
  1450     }
  1462     }
  1451 
  1463