kpeter@593: /* -*- mode: C++; indent-tabs-mode: nil; -*- kpeter@593: * kpeter@593: * This file is a part of LEMON, a generic C++ optimization library. kpeter@593: * kpeter@593: * Copyright (C) 2003-2009 kpeter@593: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport kpeter@593: * (Egervary Research Group on Combinatorial Optimization, EGRES). kpeter@593: * kpeter@593: * Permission to use, modify and distribute this software is granted kpeter@593: * provided that this copyright notice appears in all copies. For kpeter@593: * precise terms see the accompanying LICENSE file. kpeter@593: * kpeter@593: * This software is provided "AS IS" with no warranty of any kind, kpeter@593: * express or implied, and with no claim as to its suitability for any kpeter@593: * purpose. kpeter@593: * kpeter@593: */ kpeter@593: kpeter@593: #include kpeter@593: #include kpeter@593: kpeter@593: #include kpeter@593: #include kpeter@593: #include kpeter@593: kpeter@593: //#include kpeter@593: //#include kpeter@593: //#include kpeter@593: #include kpeter@593: //#include kpeter@593: //#include kpeter@593: kpeter@593: #include kpeter@593: #include kpeter@593: kpeter@593: #include "test_tools.h" kpeter@593: kpeter@593: using namespace lemon; kpeter@593: kpeter@593: char test_lgf[] = kpeter@593: "@nodes\n" kpeter@593: "label sup1 sup2 sup3\n" kpeter@593: " 1 20 27 0\n" kpeter@593: " 2 -4 0 0\n" kpeter@593: " 3 0 0 0\n" kpeter@593: " 4 0 0 0\n" kpeter@593: " 5 9 0 0\n" kpeter@593: " 6 -6 0 0\n" kpeter@593: " 7 0 0 0\n" kpeter@593: " 8 0 0 0\n" kpeter@593: " 9 3 0 0\n" kpeter@593: " 10 -2 0 0\n" kpeter@593: " 11 0 0 0\n" kpeter@593: " 12 -20 -27 0\n" kpeter@593: "\n" kpeter@593: "@arcs\n" kpeter@593: " cost cap low1 low2\n" kpeter@593: " 1 2 70 11 0 8\n" kpeter@593: " 1 3 150 3 0 1\n" kpeter@593: " 1 4 80 15 0 2\n" kpeter@593: " 2 8 80 12 0 0\n" kpeter@593: " 3 5 140 5 0 3\n" kpeter@593: " 4 6 60 10 0 1\n" kpeter@593: " 4 7 80 2 0 0\n" kpeter@593: " 4 8 110 3 0 0\n" kpeter@593: " 5 7 60 14 0 0\n" kpeter@593: " 5 11 120 12 0 0\n" kpeter@593: " 6 3 0 3 0 0\n" kpeter@593: " 6 9 140 4 0 0\n" kpeter@593: " 6 10 90 8 0 0\n" kpeter@593: " 7 1 30 5 0 0\n" kpeter@593: " 8 12 60 16 0 4\n" kpeter@593: " 9 12 50 6 0 0\n" kpeter@593: "10 12 70 13 0 5\n" kpeter@593: "10 2 100 7 0 0\n" kpeter@593: "10 7 60 10 0 0\n" kpeter@593: "11 10 20 14 0 6\n" kpeter@593: "12 11 30 10 0 0\n" kpeter@593: "\n" kpeter@593: "@attributes\n" kpeter@593: "source 1\n" kpeter@593: "target 12\n"; kpeter@593: kpeter@593: kpeter@593: // Check the interface of an MCF algorithm kpeter@593: template kpeter@593: class McfClassConcept kpeter@593: { kpeter@593: public: kpeter@593: kpeter@593: template kpeter@593: struct Constraints { kpeter@593: void constraints() { kpeter@593: checkConcept(); kpeter@593: kpeter@593: MCF mcf_test1(g, lower, upper, cost, sup); kpeter@593: MCF mcf_test2(g, upper, cost, sup); kpeter@593: MCF mcf_test3(g, lower, upper, cost, n, n, k); kpeter@593: MCF mcf_test4(g, upper, cost, n, n, k); kpeter@593: kpeter@593: // TODO: This part should be enabled and the next part kpeter@593: // should be removed if map copying is supported kpeter@593: /* kpeter@593: flow = mcf_test1.flowMap(); kpeter@593: mcf_test1.flowMap(flow); kpeter@593: kpeter@593: pot = mcf_test1.potentialMap(); kpeter@593: mcf_test1.potentialMap(pot); kpeter@593: */ kpeter@593: /**/ kpeter@593: const typename MCF::FlowMap &fm = kpeter@593: mcf_test1.flowMap(); kpeter@593: mcf_test1.flowMap(flow); kpeter@593: const typename MCF::PotentialMap &pm = kpeter@593: mcf_test1.potentialMap(); kpeter@593: mcf_test1.potentialMap(pot); kpeter@593: ignore_unused_variable_warning(fm); kpeter@593: ignore_unused_variable_warning(pm); kpeter@593: /**/ kpeter@593: kpeter@593: mcf_test1.run(); kpeter@593: kpeter@593: v = mcf_test1.totalCost(); kpeter@593: v = mcf_test1.flow(a); kpeter@593: v = mcf_test1.potential(n); kpeter@593: } kpeter@593: kpeter@593: typedef typename GR::Node Node; kpeter@593: typedef typename GR::Arc Arc; kpeter@593: typedef concepts::ReadMap NM; kpeter@593: typedef concepts::ReadMap AM; kpeter@593: kpeter@593: const GR &g; kpeter@593: const AM &lower; kpeter@593: const AM &upper; kpeter@593: const AM &cost; kpeter@593: const NM ⊃ kpeter@593: const Node &n; kpeter@593: const Arc &a; kpeter@593: const Value &k; kpeter@593: Value v; kpeter@593: kpeter@593: typename MCF::FlowMap &flow; kpeter@593: typename MCF::PotentialMap &pot; kpeter@593: }; kpeter@593: kpeter@593: }; kpeter@593: kpeter@593: kpeter@593: // Check the feasibility of the given flow (primal soluiton) kpeter@593: template < typename GR, typename LM, typename UM, kpeter@593: typename SM, typename FM > kpeter@593: bool checkFlow( const GR& gr, const LM& lower, const UM& upper, kpeter@593: const SM& supply, const FM& flow ) kpeter@593: { kpeter@593: TEMPLATE_DIGRAPH_TYPEDEFS(GR); kpeter@593: kpeter@593: for (ArcIt e(gr); e != INVALID; ++e) { kpeter@593: if (flow[e] < lower[e] || flow[e] > upper[e]) return false; kpeter@593: } kpeter@593: kpeter@593: for (NodeIt n(gr); n != INVALID; ++n) { kpeter@593: typename SM::Value sum = 0; kpeter@593: for (OutArcIt e(gr, n); e != INVALID; ++e) kpeter@593: sum += flow[e]; kpeter@593: for (InArcIt e(gr, n); e != INVALID; ++e) kpeter@593: sum -= flow[e]; kpeter@593: if (sum != supply[n]) return false; kpeter@593: } kpeter@593: kpeter@593: return true; kpeter@593: } kpeter@593: kpeter@593: // Check the feasibility of the given potentials (dual soluiton) kpeter@593: // using the Complementary Slackness optimality condition kpeter@593: template < typename GR, typename LM, typename UM, kpeter@593: typename CM, typename FM, typename PM > kpeter@593: bool checkPotential( const GR& gr, const LM& lower, const UM& upper, kpeter@593: const CM& cost, const FM& flow, const PM& pi ) kpeter@593: { kpeter@593: TEMPLATE_DIGRAPH_TYPEDEFS(GR); kpeter@593: kpeter@593: bool opt = true; kpeter@593: for (ArcIt e(gr); opt && e != INVALID; ++e) { kpeter@593: typename CM::Value red_cost = kpeter@593: cost[e] + pi[gr.source(e)] - pi[gr.target(e)]; kpeter@593: opt = red_cost == 0 || kpeter@593: (red_cost > 0 && flow[e] == lower[e]) || kpeter@593: (red_cost < 0 && flow[e] == upper[e]); kpeter@593: } kpeter@593: return opt; kpeter@593: } kpeter@593: kpeter@593: // Run a minimum cost flow algorithm and check the results kpeter@593: template < typename MCF, typename GR, kpeter@593: typename LM, typename UM, kpeter@593: typename CM, typename SM > kpeter@593: void checkMcf( const MCF& mcf, bool mcf_result, kpeter@593: const GR& gr, const LM& lower, const UM& upper, kpeter@593: const CM& cost, const SM& supply, kpeter@593: bool result, typename CM::Value total, kpeter@593: const std::string &test_id = "" ) kpeter@593: { kpeter@593: check(mcf_result == result, "Wrong result " + test_id); kpeter@593: if (result) { kpeter@593: check(checkFlow(gr, lower, upper, supply, mcf.flowMap()), kpeter@593: "The flow is not feasible " + test_id); kpeter@593: check(mcf.totalCost() == total, "The flow is not optimal " + test_id); kpeter@593: check(checkPotential(gr, lower, upper, cost, mcf.flowMap(), kpeter@593: mcf.potentialMap()), kpeter@593: "Wrong potentials " + test_id); kpeter@593: } kpeter@593: } kpeter@593: kpeter@593: int main() kpeter@593: { kpeter@593: // Check the interfaces kpeter@593: { kpeter@593: typedef int Value; kpeter@593: // This typedef should be enabled if the standard maps are kpeter@593: // reference maps in the graph concepts kpeter@593: //typedef concepts::Digraph GR; kpeter@593: typedef ListDigraph GR; kpeter@593: typedef concepts::ReadMap NM; kpeter@593: typedef concepts::ReadMap AM; kpeter@593: kpeter@593: //checkConcept< McfClassConcept, kpeter@593: // CycleCanceling >(); kpeter@593: //checkConcept< McfClassConcept, kpeter@593: // CapacityScaling >(); kpeter@593: //checkConcept< McfClassConcept, kpeter@593: // CostScaling >(); kpeter@593: checkConcept< McfClassConcept, kpeter@593: NetworkSimplex >(); kpeter@593: //checkConcept< MinCostFlow, kpeter@593: // NetworkSimplex >(); kpeter@593: } kpeter@593: kpeter@593: // Run various MCF tests kpeter@593: typedef ListDigraph Digraph; kpeter@593: DIGRAPH_TYPEDEFS(ListDigraph); kpeter@593: kpeter@593: // Read the test digraph kpeter@593: Digraph gr; kpeter@593: Digraph::ArcMap c(gr), l1(gr), l2(gr), u(gr); kpeter@593: Digraph::NodeMap s1(gr), s2(gr), s3(gr); kpeter@593: Node v, w; kpeter@593: kpeter@593: std::istringstream input(test_lgf); kpeter@593: DigraphReader(gr, input) kpeter@593: .arcMap("cost", c) kpeter@593: .arcMap("cap", u) kpeter@593: .arcMap("low1", l1) kpeter@593: .arcMap("low2", l2) kpeter@593: .nodeMap("sup1", s1) kpeter@593: .nodeMap("sup2", s2) kpeter@593: .nodeMap("sup3", s3) kpeter@593: .node("source", v) kpeter@593: .node("target", w) kpeter@593: .run(); kpeter@593: kpeter@593: /* kpeter@593: // A. Test CapacityScaling with scaling kpeter@593: { kpeter@593: CapacityScaling mcf1(gr, u, c, s1); kpeter@593: CapacityScaling mcf2(gr, u, c, v, w, 27); kpeter@593: CapacityScaling mcf3(gr, u, c, s3); kpeter@593: CapacityScaling mcf4(gr, l2, u, c, s1); kpeter@593: CapacityScaling mcf5(gr, l2, u, c, v, w, 27); kpeter@593: CapacityScaling mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(), gr, l1, u, c, s1, true, 5240, "#A1"); kpeter@593: checkMcf(mcf2, mcf2.run(), gr, l1, u, c, s2, true, 7620, "#A2"); kpeter@593: checkMcf(mcf3, mcf3.run(), gr, l1, u, c, s3, true, 0, "#A3"); kpeter@593: checkMcf(mcf4, mcf4.run(), gr, l2, u, c, s1, true, 5970, "#A4"); kpeter@593: checkMcf(mcf5, mcf5.run(), gr, l2, u, c, s2, true, 8010, "#A5"); kpeter@593: checkMcf(mcf6, mcf6.run(), gr, l2, u, c, s3, false, 0, "#A6"); kpeter@593: } kpeter@593: kpeter@593: // B. Test CapacityScaling without scaling kpeter@593: { kpeter@593: CapacityScaling mcf1(gr, u, c, s1); kpeter@593: CapacityScaling mcf2(gr, u, c, v, w, 27); kpeter@593: CapacityScaling mcf3(gr, u, c, s3); kpeter@593: CapacityScaling mcf4(gr, l2, u, c, s1); kpeter@593: CapacityScaling mcf5(gr, l2, u, c, v, w, 27); kpeter@593: CapacityScaling mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(false), gr, l1, u, c, s1, true, 5240, "#B1"); kpeter@593: checkMcf(mcf2, mcf2.run(false), gr, l1, u, c, s2, true, 7620, "#B2"); kpeter@593: checkMcf(mcf3, mcf3.run(false), gr, l1, u, c, s3, true, 0, "#B3"); kpeter@593: checkMcf(mcf4, mcf4.run(false), gr, l2, u, c, s1, true, 5970, "#B4"); kpeter@593: checkMcf(mcf5, mcf5.run(false), gr, l2, u, c, s2, true, 8010, "#B5"); kpeter@593: checkMcf(mcf6, mcf6.run(false), gr, l2, u, c, s3, false, 0, "#B6"); kpeter@593: } kpeter@593: kpeter@593: // C. Test CostScaling using partial augment-relabel method kpeter@593: { kpeter@593: CostScaling mcf1(gr, u, c, s1); kpeter@593: CostScaling mcf2(gr, u, c, v, w, 27); kpeter@593: CostScaling mcf3(gr, u, c, s3); kpeter@593: CostScaling mcf4(gr, l2, u, c, s1); kpeter@593: CostScaling mcf5(gr, l2, u, c, v, w, 27); kpeter@593: CostScaling mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(), gr, l1, u, c, s1, true, 5240, "#C1"); kpeter@593: checkMcf(mcf2, mcf2.run(), gr, l1, u, c, s2, true, 7620, "#C2"); kpeter@593: checkMcf(mcf3, mcf3.run(), gr, l1, u, c, s3, true, 0, "#C3"); kpeter@593: checkMcf(mcf4, mcf4.run(), gr, l2, u, c, s1, true, 5970, "#C4"); kpeter@593: checkMcf(mcf5, mcf5.run(), gr, l2, u, c, s2, true, 8010, "#C5"); kpeter@593: checkMcf(mcf6, mcf6.run(), gr, l2, u, c, s3, false, 0, "#C6"); kpeter@593: } kpeter@593: kpeter@593: // D. Test CostScaling using push-relabel method kpeter@593: { kpeter@593: CostScaling mcf1(gr, u, c, s1); kpeter@593: CostScaling mcf2(gr, u, c, v, w, 27); kpeter@593: CostScaling mcf3(gr, u, c, s3); kpeter@593: CostScaling mcf4(gr, l2, u, c, s1); kpeter@593: CostScaling mcf5(gr, l2, u, c, v, w, 27); kpeter@593: CostScaling mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(false), gr, l1, u, c, s1, true, 5240, "#D1"); kpeter@593: checkMcf(mcf2, mcf2.run(false), gr, l1, u, c, s2, true, 7620, "#D2"); kpeter@593: checkMcf(mcf3, mcf3.run(false), gr, l1, u, c, s3, true, 0, "#D3"); kpeter@593: checkMcf(mcf4, mcf4.run(false), gr, l2, u, c, s1, true, 5970, "#D4"); kpeter@593: checkMcf(mcf5, mcf5.run(false), gr, l2, u, c, s2, true, 8010, "#D5"); kpeter@593: checkMcf(mcf6, mcf6.run(false), gr, l2, u, c, s3, false, 0, "#D6"); kpeter@593: } kpeter@593: */ kpeter@593: kpeter@593: // E. Test NetworkSimplex with FIRST_ELIGIBLE_PIVOT kpeter@593: { kpeter@593: NetworkSimplex::PivotRuleEnum pr = kpeter@593: NetworkSimplex::FIRST_ELIGIBLE_PIVOT; kpeter@593: NetworkSimplex mcf1(gr, u, c, s1); kpeter@593: NetworkSimplex mcf2(gr, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf3(gr, u, c, s3); kpeter@593: NetworkSimplex mcf4(gr, l2, u, c, s1); kpeter@593: NetworkSimplex mcf5(gr, l2, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(pr), gr, l1, u, c, s1, true, 5240, "#E1"); kpeter@593: checkMcf(mcf2, mcf2.run(pr), gr, l1, u, c, s2, true, 7620, "#E2"); kpeter@593: checkMcf(mcf3, mcf3.run(pr), gr, l1, u, c, s3, true, 0, "#E3"); kpeter@593: checkMcf(mcf4, mcf4.run(pr), gr, l2, u, c, s1, true, 5970, "#E4"); kpeter@593: checkMcf(mcf5, mcf5.run(pr), gr, l2, u, c, s2, true, 8010, "#E5"); kpeter@593: checkMcf(mcf6, mcf6.run(pr), gr, l2, u, c, s3, false, 0, "#E6"); kpeter@593: } kpeter@593: kpeter@593: // F. Test NetworkSimplex with BEST_ELIGIBLE_PIVOT kpeter@593: { kpeter@593: NetworkSimplex::PivotRuleEnum pr = kpeter@593: NetworkSimplex::BEST_ELIGIBLE_PIVOT; kpeter@593: NetworkSimplex mcf1(gr, u, c, s1); kpeter@593: NetworkSimplex mcf2(gr, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf3(gr, u, c, s3); kpeter@593: NetworkSimplex mcf4(gr, l2, u, c, s1); kpeter@593: NetworkSimplex mcf5(gr, l2, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(pr), gr, l1, u, c, s1, true, 5240, "#F1"); kpeter@593: checkMcf(mcf2, mcf2.run(pr), gr, l1, u, c, s2, true, 7620, "#F2"); kpeter@593: checkMcf(mcf3, mcf3.run(pr), gr, l1, u, c, s3, true, 0, "#F3"); kpeter@593: checkMcf(mcf4, mcf4.run(pr), gr, l2, u, c, s1, true, 5970, "#F4"); kpeter@593: checkMcf(mcf5, mcf5.run(pr), gr, l2, u, c, s2, true, 8010, "#F5"); kpeter@593: checkMcf(mcf6, mcf6.run(pr), gr, l2, u, c, s3, false, 0, "#F6"); kpeter@593: } kpeter@593: kpeter@593: // G. Test NetworkSimplex with BLOCK_SEARCH_PIVOT kpeter@593: { kpeter@593: NetworkSimplex::PivotRuleEnum pr = kpeter@593: NetworkSimplex::BLOCK_SEARCH_PIVOT; kpeter@593: NetworkSimplex mcf1(gr, u, c, s1); kpeter@593: NetworkSimplex mcf2(gr, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf3(gr, u, c, s3); kpeter@593: NetworkSimplex mcf4(gr, l2, u, c, s1); kpeter@593: NetworkSimplex mcf5(gr, l2, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(pr), gr, l1, u, c, s1, true, 5240, "#G1"); kpeter@593: checkMcf(mcf2, mcf2.run(pr), gr, l1, u, c, s2, true, 7620, "#G2"); kpeter@593: checkMcf(mcf3, mcf3.run(pr), gr, l1, u, c, s3, true, 0, "#G3"); kpeter@593: checkMcf(mcf4, mcf4.run(pr), gr, l2, u, c, s1, true, 5970, "#G4"); kpeter@593: checkMcf(mcf5, mcf5.run(pr), gr, l2, u, c, s2, true, 8010, "#G5"); kpeter@593: checkMcf(mcf6, mcf6.run(pr), gr, l2, u, c, s3, false, 0, "#G6"); kpeter@593: } kpeter@593: kpeter@593: // H. Test NetworkSimplex with CANDIDATE_LIST_PIVOT kpeter@593: { kpeter@593: NetworkSimplex::PivotRuleEnum pr = kpeter@593: NetworkSimplex::CANDIDATE_LIST_PIVOT; kpeter@593: NetworkSimplex mcf1(gr, u, c, s1); kpeter@593: NetworkSimplex mcf2(gr, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf3(gr, u, c, s3); kpeter@593: NetworkSimplex mcf4(gr, l2, u, c, s1); kpeter@593: NetworkSimplex mcf5(gr, l2, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(pr), gr, l1, u, c, s1, true, 5240, "#H1"); kpeter@593: checkMcf(mcf2, mcf2.run(pr), gr, l1, u, c, s2, true, 7620, "#H2"); kpeter@593: checkMcf(mcf3, mcf3.run(pr), gr, l1, u, c, s3, true, 0, "#H3"); kpeter@593: checkMcf(mcf4, mcf4.run(pr), gr, l2, u, c, s1, true, 5970, "#H4"); kpeter@593: checkMcf(mcf5, mcf5.run(pr), gr, l2, u, c, s2, true, 8010, "#H5"); kpeter@593: checkMcf(mcf6, mcf6.run(pr), gr, l2, u, c, s3, false, 0, "#H6"); kpeter@593: } kpeter@593: kpeter@593: // I. Test NetworkSimplex with ALTERING_LIST_PIVOT kpeter@593: { kpeter@593: NetworkSimplex::PivotRuleEnum pr = kpeter@593: NetworkSimplex::ALTERING_LIST_PIVOT; kpeter@593: NetworkSimplex mcf1(gr, u, c, s1); kpeter@593: NetworkSimplex mcf2(gr, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf3(gr, u, c, s3); kpeter@593: NetworkSimplex mcf4(gr, l2, u, c, s1); kpeter@593: NetworkSimplex mcf5(gr, l2, u, c, v, w, 27); kpeter@593: NetworkSimplex mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(pr), gr, l1, u, c, s1, true, 5240, "#I1"); kpeter@593: checkMcf(mcf2, mcf2.run(pr), gr, l1, u, c, s2, true, 7620, "#I2"); kpeter@593: checkMcf(mcf3, mcf3.run(pr), gr, l1, u, c, s3, true, 0, "#I3"); kpeter@593: checkMcf(mcf4, mcf4.run(pr), gr, l2, u, c, s1, true, 5970, "#I4"); kpeter@593: checkMcf(mcf5, mcf5.run(pr), gr, l2, u, c, s2, true, 8010, "#I5"); kpeter@593: checkMcf(mcf6, mcf6.run(pr), gr, l2, u, c, s3, false, 0, "#I6"); kpeter@593: } kpeter@593: kpeter@593: /* kpeter@593: // J. Test MinCostFlow kpeter@593: { kpeter@593: MinCostFlow mcf1(gr, u, c, s1); kpeter@593: MinCostFlow mcf2(gr, u, c, v, w, 27); kpeter@593: MinCostFlow mcf3(gr, u, c, s3); kpeter@593: MinCostFlow mcf4(gr, l2, u, c, s1); kpeter@593: MinCostFlow mcf5(gr, l2, u, c, v, w, 27); kpeter@593: MinCostFlow mcf6(gr, l2, u, c, s3); kpeter@593: kpeter@593: checkMcf(mcf1, mcf1.run(), gr, l1, u, c, s1, true, 5240, "#J1"); kpeter@593: checkMcf(mcf2, mcf2.run(), gr, l1, u, c, s2, true, 7620, "#J2"); kpeter@593: checkMcf(mcf3, mcf3.run(), gr, l1, u, c, s3, true, 0, "#J3"); kpeter@593: checkMcf(mcf4, mcf4.run(), gr, l2, u, c, s1, true, 5970, "#J4"); kpeter@593: checkMcf(mcf5, mcf5.run(), gr, l2, u, c, s2, true, 8010, "#J5"); kpeter@593: checkMcf(mcf6, mcf6.run(), gr, l2, u, c, s3, false, 0, "#J6"); kpeter@593: } kpeter@593: */ kpeter@593: /* kpeter@593: // K. Test MinCostMaxFlow kpeter@593: { kpeter@593: MinCostMaxFlow mcmf(gr, u, c, v, w); kpeter@593: mcmf.run(); kpeter@593: checkMcf(mcmf, true, gr, l1, u, c, s3, true, 7620, "#K1"); kpeter@593: } kpeter@593: */ kpeter@593: kpeter@593: return 0; kpeter@593: }