lemon/graph_adaptor.h
changeset 2301 eb378706bd3d
parent 2260 4274224f8a7d
child 2340 03c71d754990
equal deleted inserted replaced
40:5939a118b3cc 41:3a14efa455e9
  1428     return UndirGraphAdaptor<const Graph>(graph);
  1428     return UndirGraphAdaptor<const Graph>(graph);
  1429   }
  1429   }
  1430 
  1430 
  1431   template<typename Graph, typename Number,  
  1431   template<typename Graph, typename Number,  
  1432            typename CapacityMap, typename FlowMap, 
  1432            typename CapacityMap, typename FlowMap, 
  1433            typename Tolerance = Tolerance<Number> >
  1433            typename Tol = Tolerance<Number> >
  1434   class ResForwardFilter {
  1434   class ResForwardFilter {
  1435     const CapacityMap* capacity;
  1435     const CapacityMap* capacity;
  1436     const FlowMap* flow;
  1436     const FlowMap* flow;
  1437     Tolerance tolerance;
  1437     Tol tolerance;
  1438   public:
  1438   public:
  1439     typedef typename Graph::Edge Key;
  1439     typedef typename Graph::Edge Key;
  1440     typedef bool Value;
  1440     typedef bool Value;
  1441 
  1441 
  1442     ResForwardFilter(const CapacityMap& _capacity, const FlowMap& _flow,
  1442     ResForwardFilter(const CapacityMap& _capacity, const FlowMap& _flow,
  1443                      const Tolerance& _tolerance = Tolerance()) 
  1443                      const Tol& _tolerance = Tol()) 
  1444       : capacity(&_capacity), flow(&_flow), tolerance(_tolerance) { }
  1444       : capacity(&_capacity), flow(&_flow), tolerance(_tolerance) { }
  1445 
  1445 
  1446     ResForwardFilter(const Tolerance& _tolerance) 
  1446     ResForwardFilter(const Tol& _tolerance) 
  1447       : capacity(0), flow(0), tolerance(_tolerance)  { }
  1447       : capacity(0), flow(0), tolerance(_tolerance)  { }
  1448 
  1448 
  1449     void setCapacity(const CapacityMap& _capacity) { capacity = &_capacity; }
  1449     void setCapacity(const CapacityMap& _capacity) { capacity = &_capacity; }
  1450     void setFlow(const FlowMap& _flow) { flow = &_flow; }
  1450     void setFlow(const FlowMap& _flow) { flow = &_flow; }
  1451 
  1451 
  1454     }
  1454     }
  1455   };
  1455   };
  1456 
  1456 
  1457   template<typename Graph, typename Number,
  1457   template<typename Graph, typename Number,
  1458 	   typename CapacityMap, typename FlowMap,
  1458 	   typename CapacityMap, typename FlowMap,
  1459            typename Tolerance = Tolerance<Number> >
  1459            typename Tol = Tolerance<Number> >
  1460   class ResBackwardFilter {
  1460   class ResBackwardFilter {
  1461     const CapacityMap* capacity;
  1461     const CapacityMap* capacity;
  1462     const FlowMap* flow;
  1462     const FlowMap* flow;
  1463     Tolerance tolerance;
  1463     Tol tolerance;
  1464   public:
  1464   public:
  1465     typedef typename Graph::Edge Key;
  1465     typedef typename Graph::Edge Key;
  1466     typedef bool Value;
  1466     typedef bool Value;
  1467 
  1467 
  1468     ResBackwardFilter(const CapacityMap& _capacity, const FlowMap& _flow,
  1468     ResBackwardFilter(const CapacityMap& _capacity, const FlowMap& _flow,
  1469                       const Tolerance& _tolerance = Tolerance())
  1469                       const Tol& _tolerance = Tol())
  1470       : capacity(&_capacity), flow(&_flow), tolerance(_tolerance) { }
  1470       : capacity(&_capacity), flow(&_flow), tolerance(_tolerance) { }
  1471     ResBackwardFilter(const Tolerance& _tolerance = Tolerance())
  1471     ResBackwardFilter(const Tol& _tolerance = Tol())
  1472       : capacity(0), flow(0), tolerance(_tolerance) { }
  1472       : capacity(0), flow(0), tolerance(_tolerance) { }
  1473     void setCapacity(const CapacityMap& _capacity) { capacity = &_capacity; }
  1473     void setCapacity(const CapacityMap& _capacity) { capacity = &_capacity; }
  1474     void setFlow(const FlowMap& _flow) { flow = &_flow; }
  1474     void setFlow(const FlowMap& _flow) { flow = &_flow; }
  1475     bool operator[](const typename Graph::Edge& e) const {
  1475     bool operator[](const typename Graph::Edge& e) const {
  1476       return tolerance.less(0, Number((*flow)[e]));
  1476       return tolerance.less(0, Number((*flow)[e]));
  1514   ///\endcode
  1514   ///\endcode
  1515   ///\author Marton Makai
  1515   ///\author Marton Makai
  1516   ///
  1516   ///
  1517   template<typename Graph, typename Number, 
  1517   template<typename Graph, typename Number, 
  1518 	   typename CapacityMap, typename FlowMap,
  1518 	   typename CapacityMap, typename FlowMap,
  1519            typename Tolerance = Tolerance<Number> >
  1519            typename Tol = Tolerance<Number> >
  1520   class ResGraphAdaptor : 
  1520   class ResGraphAdaptor : 
  1521     public EdgeSubGraphAdaptor< 
  1521     public EdgeSubGraphAdaptor< 
  1522     UndirGraphAdaptor<const Graph>, 
  1522     UndirGraphAdaptor<const Graph>, 
  1523     typename UndirGraphAdaptor<const Graph>::template CombinedEdgeMap<
  1523     typename UndirGraphAdaptor<const Graph>::template CombinedEdgeMap<
  1524     ResForwardFilter<const Graph, Number, CapacityMap, FlowMap>,  
  1524     ResForwardFilter<const Graph, Number, CapacityMap, FlowMap>,  
  1566     /// \brief Constructor of the residual graph.
  1566     /// \brief Constructor of the residual graph.
  1567     ///
  1567     ///
  1568     /// Constructor of the residual graph. The parameters are the graph type,
  1568     /// Constructor of the residual graph. The parameters are the graph type,
  1569     /// the flow map, the capacity map and a tolerance object.
  1569     /// the flow map, the capacity map and a tolerance object.
  1570     ResGraphAdaptor(const Graph& _graph, const CapacityMap& _capacity, 
  1570     ResGraphAdaptor(const Graph& _graph, const CapacityMap& _capacity, 
  1571                     FlowMap& _flow, const Tolerance& _tolerance = Tolerance()) 
  1571                     FlowMap& _flow, const Tol& _tolerance = Tol()) 
  1572       : Parent(), capacity(&_capacity), flow(&_flow), ugraph(_graph),
  1572       : Parent(), capacity(&_capacity), flow(&_flow), ugraph(_graph),
  1573         forward_filter(_capacity, _flow, _tolerance), 
  1573         forward_filter(_capacity, _flow, _tolerance), 
  1574         backward_filter(_capacity, _flow, _tolerance),
  1574         backward_filter(_capacity, _flow, _tolerance),
  1575         edge_filter(forward_filter, backward_filter)
  1575         edge_filter(forward_filter, backward_filter)
  1576     {
  1576     {