COIN-OR::LEMON - Graph Library

Changeset 941:186aa53d2802 in lemon-0.x for src/test


Ignore:
Timestamp:
10/08/04 15:07:51 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1283
Message:

Suurballe and MinCostFlow? classes are now able to increase the flow 1 by 1 with
this->augment()

Location:
src/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/test/min_cost_flow_test.cc

    r921 r941  
    2222//#include <maps.h>
    2323
    24 using namespace std;
    2524using namespace lemon;
    26 
    2725
    2826
     
    4240int main()
    4341{
     42  typedef ListGraph Graph;
     43  typedef Graph::Node Node;
     44  typedef Graph::Edge Edge;
    4445
    45   typedef ListGraph::Node Node;
    46   typedef ListGraph::Edge Edge;
    47 
    48   ListGraph graph;
     46  Graph graph;
    4947
    5048  //Ahuja könyv példája
     
    6866 
    6967
    70   ListGraph::EdgeMap<int> length(graph);
     68  Graph::EdgeMap<int> length(graph);
    7169
    7270  length.set(s_v1, 6);
     
    7977  length.set(v5_t, 8);
    8078
    81   ListGraph::EdgeMap<int> capacity(graph);
     79  Graph::EdgeMap<int> capacity(graph);
    8280
    8381  capacity.set(s_v1, 2);
     
    9391  std::cout << "Mincostflows algorithm test..." << std::endl;
    9492
    95   MinCostFlow< ListGraph, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> >
    96     surb_test(graph, length, capacity);
     93  MinCostFlow< Graph, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
     94    surb_test(graph, length, capacity, s, t);
    9795
    9896  int k=1;
    9997
    100   check(  surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
     98  surb_test.augment();
     99  check(  surb_test.flowValue() == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
     100
     101  check(  surb_test.run(k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
    101102
    102103  check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
     
    104105  k=2;
    105106 
    106   check(  surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 41,"Two paths, total length should be 41");
     107  check(  surb_test.run(k) == 2 && surb_test.totalLength() == 41,"Two paths, total length should be 41");
    107108
    108109  check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
    109110 
    110  
     111  surb_test.augment();
     112  surb_test.augment();
     113  surb_test.augment();
    111114  k=4;
    112115
    113   check(  surb_test.run(s,t,k) == 3 && surb_test.totalLength() == 64,"Three paths, total length should be 64");
     116  check(  surb_test.run(k) == 3 && surb_test.totalLength() == 64,"Three paths, total length should be 64");
    114117
    115118  check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
    116119
    117120
    118   cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
    119        << endl;
     121  std::cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
     122            << std::endl;
    120123
    121124  return passed ? 0 : 1;
  • src/test/suurballe_test.cc

    r921 r941  
    2121#include "test_tools.h"
    2222
    23 using namespace std;
    2423using namespace lemon;
    25 
    2624
    2725
     
    3129int main()
    3230{
     31  typedef ListGraph Graph;
     32  typedef Graph::Node Node;
     33  typedef Graph::Edge Edge;
    3334
    34   typedef ListGraph::Node Node;
    35   typedef ListGraph::Edge Edge;
    36 
    37   ListGraph graph;
     35  Graph graph;
    3836
    3937  //Ahuja könyv példája
     
    5755 
    5856
    59   ListGraph::EdgeMap<int> length(graph);
     57  Graph::EdgeMap<int> length(graph);
    6058
    6159  length.set(s_v1, 6);
     
    7270 
    7371  int k=3;
    74   Suurballe< ListGraph, ListGraph::EdgeMap<int> >
    75     surb_test(graph, length);
     72  Suurballe< Graph, Graph::EdgeMap<int> >
     73    surb_test(graph, length, s, t);
    7674
    77   check(  surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 46,
     75  check(  surb_test.run(k) == 2 && surb_test.totalLength() == 46,
    7876          "Two paths, total length should be 46");
    7977
     
    8179          "Complementary slackness conditions are not met.");
    8280
    83   //  typedef DirPath<ListGraph> DPath;
     81  //  typedef DirPath<Graph> DPath;
    8482  //  DPath P(graph);
    8583
     
    8785  surb_test.getPath(P,0);
    8886  check(P.length() == 4, "First path should contain 4 edges."); 
    89   cout<<P.length()<<endl;
     87  std::cout<<P.length()<<std::endl;
    9088  surb_test.getPath(P,1);
    9189  check(P.length() == 3, "Second path: 3 edges.");
    92   cout<<P.length()<<endl;
     90  std::cout<<P.length()<<std::endl;
    9391  */ 
    9492
    9593  k=1;
    96   check(  surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,
     94  check(  surb_test.run(k) == 1 && surb_test.totalLength() == 19,
    9795          "One path, total length should be 19");
    9896
     
    103101  //  check(P.length() == 4, "First path should contain 4 edges."); 
    104102
    105   cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
    106        << endl;
     103  std::cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
     104            << std::endl;
    107105
    108106  return passed ? 0 : 1;
Note: See TracChangeset for help on using the changeset viewer.