test/min_cost_flow_test.cc
changeset 689 111698359429
parent 687 6c408d864fa1
child 711 cc61d09f053b
     1.1 --- a/test/min_cost_flow_test.cc	Wed Apr 29 14:25:51 2009 +0200
     1.2 +++ b/test/min_cost_flow_test.cc	Wed Apr 29 16:54:27 2009 +0200
     1.3 @@ -84,7 +84,7 @@
     1.4  };
     1.5  
     1.6  // Check the interface of an MCF algorithm
     1.7 -template <typename GR, typename Flow, typename Cost>
     1.8 +template <typename GR, typename Value, typename Cost>
     1.9  class McfClassConcept
    1.10  {
    1.11  public:
    1.12 @@ -95,6 +95,7 @@
    1.13        checkConcept<concepts::Digraph, GR>();
    1.14  
    1.15        MCF mcf(g);
    1.16 +      const MCF& const_mcf = mcf;
    1.17  
    1.18        b = mcf.reset()
    1.19               .lowerMap(lower)
    1.20 @@ -102,47 +103,38 @@
    1.21               .costMap(cost)
    1.22               .supplyMap(sup)
    1.23               .stSupply(n, n, k)
    1.24 -             .flowMap(flow)
    1.25 -             .potentialMap(pot)
    1.26               .run();
    1.27 -      
    1.28 -      const MCF& const_mcf = mcf;
    1.29 -
    1.30 -      const typename MCF::FlowMap &fm = const_mcf.flowMap();
    1.31 -      const typename MCF::PotentialMap &pm = const_mcf.potentialMap();
    1.32  
    1.33        c = const_mcf.totalCost();
    1.34 -      double x = const_mcf.template totalCost<double>();
    1.35 +      x = const_mcf.template totalCost<double>();
    1.36        v = const_mcf.flow(a);
    1.37        c = const_mcf.potential(n);
    1.38 -      
    1.39 -      v = const_mcf.INF;
    1.40 -
    1.41 -      ignore_unused_variable_warning(fm);
    1.42 -      ignore_unused_variable_warning(pm);
    1.43 -      ignore_unused_variable_warning(x);
    1.44 +      const_mcf.flowMap(fm);
    1.45 +      const_mcf.potentialMap(pm);
    1.46      }
    1.47  
    1.48      typedef typename GR::Node Node;
    1.49      typedef typename GR::Arc Arc;
    1.50 -    typedef concepts::ReadMap<Node, Flow> NM;
    1.51 -    typedef concepts::ReadMap<Arc, Flow> FAM;
    1.52 +    typedef concepts::ReadMap<Node, Value> NM;
    1.53 +    typedef concepts::ReadMap<Arc, Value> VAM;
    1.54      typedef concepts::ReadMap<Arc, Cost> CAM;
    1.55 +    typedef concepts::WriteMap<Arc, Value> FlowMap;
    1.56 +    typedef concepts::WriteMap<Node, Cost> PotMap;
    1.57  
    1.58      const GR &g;
    1.59 -    const FAM &lower;
    1.60 -    const FAM &upper;
    1.61 +    const VAM &lower;
    1.62 +    const VAM &upper;
    1.63      const CAM &cost;
    1.64      const NM &sup;
    1.65      const Node &n;
    1.66      const Arc &a;
    1.67 -    const Flow &k;
    1.68 -    Flow v;
    1.69 -    Cost c;
    1.70 +    const Value &k;
    1.71 +    FlowMap fm;
    1.72 +    PotMap pm;
    1.73      bool b;
    1.74 -
    1.75 -    typename MCF::FlowMap &flow;
    1.76 -    typename MCF::PotentialMap &pot;
    1.77 +    double x;
    1.78 +    typename MCF::Value v;
    1.79 +    typename MCF::Cost c;
    1.80    };
    1.81  
    1.82  };
    1.83 @@ -221,11 +213,14 @@
    1.84  {
    1.85    check(mcf_result == result, "Wrong result " + test_id);
    1.86    if (optimal) {
    1.87 -    check(checkFlow(gr, lower, upper, supply, mcf.flowMap(), type),
    1.88 +    typename GR::template ArcMap<typename SM::Value> flow(gr);
    1.89 +    typename GR::template NodeMap<typename CM::Value> pi(gr);
    1.90 +    mcf.flowMap(flow);
    1.91 +    mcf.potentialMap(pi);
    1.92 +    check(checkFlow(gr, lower, upper, supply, flow, type),
    1.93            "The flow is not feasible " + test_id);
    1.94      check(mcf.totalCost() == total, "The flow is not optimal " + test_id);
    1.95 -    check(checkPotential(gr, lower, upper, cost, supply, mcf.flowMap(),
    1.96 -                         mcf.potentialMap()),
    1.97 +    check(checkPotential(gr, lower, upper, cost, supply, flow, pi),
    1.98            "Wrong potentials " + test_id);
    1.99    }
   1.100  }
   1.101 @@ -234,11 +229,13 @@
   1.102  {
   1.103    // Check the interfaces
   1.104    {
   1.105 -    typedef int Flow;
   1.106 -    typedef int Cost;
   1.107      typedef concepts::Digraph GR;
   1.108 -    checkConcept< McfClassConcept<GR, Flow, Cost>,
   1.109 -                  NetworkSimplex<GR, Flow, Cost> >();
   1.110 +    checkConcept< McfClassConcept<GR, int, int>,
   1.111 +                  NetworkSimplex<GR> >();
   1.112 +    checkConcept< McfClassConcept<GR, double, double>,
   1.113 +                  NetworkSimplex<GR, double> >();
   1.114 +    checkConcept< McfClassConcept<GR, int, double>,
   1.115 +                  NetworkSimplex<GR, int, double> >();
   1.116    }
   1.117  
   1.118    // Run various MCF tests