test/suurballe_test.cc
changeset 445 b2564598b46d
parent 358 7f26c4b32651
child 463 88ed40ad0d4f
     1.1 --- a/test/suurballe_test.cc	Mon Dec 08 11:06:39 2008 +0100
     1.2 +++ b/test/suurballe_test.cc	Mon Dec 08 15:47:20 2008 +0000
     1.3 @@ -17,7 +17,6 @@
     1.4   */
     1.5  
     1.6  #include <iostream>
     1.7 -#include <fstream>
     1.8  
     1.9  #include <lemon/list_graph.h>
    1.10  #include <lemon/lgf_reader.h>
    1.11 @@ -28,6 +27,49 @@
    1.12  
    1.13  using namespace lemon;
    1.14  
    1.15 +char test_lgf[] =
    1.16 +  "@nodes\n"
    1.17 +  "label supply1 supply2 supply3\n"
    1.18 +  "1     0        20      27\n"
    1.19 +  "2     0       -4        0\n"
    1.20 +  "3     0        0        0\n"
    1.21 +  "4     0        0        0\n"
    1.22 +  "5     0        9        0\n"
    1.23 +  "6     0       -6        0\n"
    1.24 +  "7     0        0        0\n"
    1.25 +  "8     0        0        0\n"
    1.26 +  "9     0        3        0\n"
    1.27 +  "10    0       -2        0\n"
    1.28 +  "11    0        0        0\n"
    1.29 +  "12    0       -20     -27\n"
    1.30 +  "@arcs\n"
    1.31 +  "      cost capacity lower1 lower2\n"
    1.32 +  " 1  2  70  11       0      8\n"
    1.33 +  " 1  3 150   3       0      1\n"
    1.34 +  " 1  4  80  15       0      2\n"
    1.35 +  " 2  8  80  12       0      0\n"
    1.36 +  " 3  5 140   5       0      3\n"
    1.37 +  " 4  6  60  10       0      1\n"
    1.38 +  " 4  7  80   2       0      0\n"
    1.39 +  " 4  8 110   3       0      0\n"
    1.40 +  " 5  7  60  14       0      0\n"
    1.41 +  " 5 11 120  12       0      0\n"
    1.42 +  " 6  3   0   3       0      0\n"
    1.43 +  " 6  9 140   4       0      0\n"
    1.44 +  " 6 10  90   8       0      0\n"
    1.45 +  " 7  1  30   5       0      0\n"
    1.46 +  " 8 12  60  16       0      4\n"
    1.47 +  " 9 12  50   6       0      0\n"
    1.48 +  "10 12  70  13       0      5\n"
    1.49 +  "10  2 100   7       0      0\n"
    1.50 +  "10  7  60  10       0      0\n"
    1.51 +  "11 10  20  14       0      6\n"
    1.52 +  "12 11  30  10       0      0\n"
    1.53 +  "@attributes\n"
    1.54 +  "source  1\n"
    1.55 +  "target 12\n"
    1.56 +  "@end\n";
    1.57 +
    1.58  // Check the feasibility of the flow
    1.59  template <typename Digraph, typename FlowMap>
    1.60  bool checkFlow( const Digraph& gr, const FlowMap& flow, 
    1.61 @@ -96,20 +138,12 @@
    1.62    ListDigraph::ArcMap<int> length(digraph);
    1.63    Node source, target;
    1.64  
    1.65 -  std::string fname;
    1.66 -  if(getenv("srcdir"))
    1.67 -    fname = std::string(getenv("srcdir"));
    1.68 -  else fname = ".";
    1.69 -  fname += "/test/min_cost_flow_test.lgf";
    1.70 -
    1.71 -  std::ifstream input(fname.c_str());
    1.72 -  check(input, "Input file '" << fname << "' not found");
    1.73 +  std::istringstream input(test_lgf);
    1.74    DigraphReader<ListDigraph>(digraph, input).
    1.75      arcMap("cost", length).
    1.76      node("source", source).
    1.77      node("target", target).
    1.78      run();
    1.79 -  input.close();
    1.80    
    1.81    // Find 2 paths
    1.82    {