src/test/min_cost_flow_test.cc
changeset 1435 8e85e6bbefdf
parent 1434 d8475431bbbb
child 1436 e0beb94d08bf
     1.1 --- a/src/test/min_cost_flow_test.cc	Sat May 21 21:04:57 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,126 +0,0 @@
     1.4 -/* -*- C++ -*-
     1.5 - * src/test/min_cost_flow_test.cc - Part of LEMON, a generic C++ optimization library
     1.6 - *
     1.7 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
     1.9 - *
    1.10 - * Permission to use, modify and distribute this software is granted
    1.11 - * provided that this copyright notice appears in all copies. For
    1.12 - * precise terms see the accompanying LICENSE file.
    1.13 - *
    1.14 - * This software is provided "AS IS" with no warranty of any kind,
    1.15 - * express or implied, and with no claim as to its suitability for any
    1.16 - * purpose.
    1.17 - *
    1.18 - */
    1.19 -
    1.20 -#include <iostream>
    1.21 -#include "test_tools.h"
    1.22 -#include <lemon/list_graph.h>
    1.23 -#include <lemon/min_cost_flow.h>
    1.24 -//#include <path.h>
    1.25 -//#include <maps.h>
    1.26 -
    1.27 -using namespace lemon;
    1.28 -
    1.29 -
    1.30 -bool passed = true;
    1.31 -/*
    1.32 -void check(bool rc, char *msg="") {
    1.33 -  passed = passed && rc;
    1.34 -  if(!rc) {
    1.35 -    std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
    1.36 - 
    1.37 -
    1.38 -  }
    1.39 -}
    1.40 -*/
    1.41 -
    1.42 -
    1.43 -int main()
    1.44 -{
    1.45 -  typedef ListGraph Graph;
    1.46 -  typedef Graph::Node Node;
    1.47 -  typedef Graph::Edge Edge;
    1.48 -
    1.49 -  Graph graph;
    1.50 -
    1.51 -  //Ahuja könyv példája
    1.52 -
    1.53 -  Node s=graph.addNode();
    1.54 -  Node v1=graph.addNode();  
    1.55 -  Node v2=graph.addNode();
    1.56 -  Node v3=graph.addNode();
    1.57 -  Node v4=graph.addNode();
    1.58 -  Node v5=graph.addNode();
    1.59 -  Node t=graph.addNode();
    1.60 -
    1.61 -  Edge s_v1=graph.addEdge(s, v1);
    1.62 -  Edge v1_v2=graph.addEdge(v1, v2);
    1.63 -  Edge s_v3=graph.addEdge(s, v3);
    1.64 -  Edge v2_v4=graph.addEdge(v2, v4);
    1.65 -  Edge v2_v5=graph.addEdge(v2, v5);
    1.66 -  Edge v3_v5=graph.addEdge(v3, v5);
    1.67 -  Edge v4_t=graph.addEdge(v4, t);
    1.68 -  Edge v5_t=graph.addEdge(v5, t);
    1.69 -  
    1.70 -
    1.71 -  Graph::EdgeMap<int> length(graph);
    1.72 -
    1.73 -  length.set(s_v1, 6);
    1.74 -  length.set(v1_v2, 4);
    1.75 -  length.set(s_v3, 10);
    1.76 -  length.set(v2_v4, 5);
    1.77 -  length.set(v2_v5, 1);
    1.78 -  length.set(v3_v5, 4);
    1.79 -  length.set(v4_t, 8);
    1.80 -  length.set(v5_t, 8);
    1.81 -
    1.82 -  Graph::EdgeMap<int> capacity(graph);
    1.83 -
    1.84 -  capacity.set(s_v1, 2);
    1.85 -  capacity.set(v1_v2, 2);
    1.86 -  capacity.set(s_v3, 1);
    1.87 -  capacity.set(v2_v4, 1);
    1.88 -  capacity.set(v2_v5, 1);
    1.89 -  capacity.set(v3_v5, 1);
    1.90 -  capacity.set(v4_t, 1);
    1.91 -  capacity.set(v5_t, 2);
    1.92 -
    1.93 -  //  ConstMap<Edge, int> const1map(1);
    1.94 -  std::cout << "Mincostflows algorithm test..." << std::endl;
    1.95 -
    1.96 -  MinCostFlow< Graph, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
    1.97 -    surb_test(graph, length, capacity, s, t);
    1.98 -
    1.99 -  int k=1;
   1.100 -
   1.101 -  surb_test.augment();
   1.102 -  check(  surb_test.flowValue() == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
   1.103 -
   1.104 -  check(  surb_test.run(k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
   1.105 -
   1.106 -  check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
   1.107 -  
   1.108 -  k=2;
   1.109 -  
   1.110 -  check(  surb_test.run(k) == 2 && surb_test.totalLength() == 41,"Two paths, total length should be 41");
   1.111 -
   1.112 -  check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
   1.113 -  
   1.114 -  surb_test.augment();
   1.115 -  surb_test.augment();
   1.116 -  surb_test.augment();
   1.117 -  k=4;
   1.118 -
   1.119 -  check(  surb_test.run(k) == 3 && surb_test.totalLength() == 64,"Three paths, total length should be 64");
   1.120 -
   1.121 -  check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
   1.122 -
   1.123 -
   1.124 -  std::cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
   1.125 -	    << std::endl;
   1.126 -
   1.127 -  return passed ? 0 : 1;
   1.128 -
   1.129 -}