test/preflow_test.cc
changeset 433 39b03fc708fd
parent 394 e7707b3069f1
child 440 88ed40ad0d4f
equal deleted inserted replaced
3:7a46df18f40e 4:c6560eea575c
    14  * express or implied, and with no claim as to its suitability for any
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    15  * purpose.
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 #include <fstream>
    19 #include <iostream>
    20 #include <string>
       
    21 
    20 
    22 #include "test_tools.h"
    21 #include "test_tools.h"
    23 #include <lemon/smart_graph.h>
    22 #include <lemon/smart_graph.h>
    24 #include <lemon/preflow.h>
    23 #include <lemon/preflow.h>
    25 #include <lemon/concepts/digraph.h>
    24 #include <lemon/concepts/digraph.h>
    26 #include <lemon/concepts/maps.h>
    25 #include <lemon/concepts/maps.h>
    27 #include <lemon/lgf_reader.h>
    26 #include <lemon/lgf_reader.h>
    28 #include <lemon/elevator.h>
    27 #include <lemon/elevator.h>
    29 
    28 
    30 using namespace lemon;
    29 using namespace lemon;
       
    30 
       
    31 char test_lgf[] =
       
    32   "@nodes\n"
       
    33   "label\n"
       
    34   "0\n"
       
    35   "1\n"
       
    36   "2\n"
       
    37   "3\n"
       
    38   "4\n"
       
    39   "5\n"
       
    40   "6\n"
       
    41   "7\n"
       
    42   "8\n"
       
    43   "9\n"
       
    44   "@arcs\n"
       
    45   "    label capacity\n"
       
    46   "0 1 0     20\n"
       
    47   "0 2 1     0\n"
       
    48   "1 1 2     3\n"
       
    49   "1 2 3     8\n"
       
    50   "1 3 4     8\n"
       
    51   "2 5 5     5\n"
       
    52   "3 2 6     5\n"
       
    53   "3 5 7     5\n"
       
    54   "3 6 8     5\n"
       
    55   "4 3 9     3\n"
       
    56   "5 7 10    3\n"
       
    57   "5 6 11    10\n"
       
    58   "5 8 12    10\n"
       
    59   "6 8 13    8\n"
       
    60   "8 9 14    20\n"
       
    61   "8 1 15    5\n"
       
    62   "9 5 16    5\n"
       
    63   "@attributes\n"
       
    64   "source 1\n"
       
    65   "target 8\n";
    31 
    66 
    32 void checkPreflowCompile()
    67 void checkPreflowCompile()
    33 {
    68 {
    34   typedef int VType;
    69   typedef int VType;
    35   typedef concepts::Digraph Digraph;
    70   typedef concepts::Digraph Digraph;
   121   typedef Digraph::ArcMap<int> FlowMap;
   156   typedef Digraph::ArcMap<int> FlowMap;
   122   typedef Digraph::NodeMap<bool> CutMap;
   157   typedef Digraph::NodeMap<bool> CutMap;
   123 
   158 
   124   typedef Preflow<Digraph, CapMap> PType;
   159   typedef Preflow<Digraph, CapMap> PType;
   125 
   160 
   126   std::string f_name;
       
   127   if( getenv("srcdir") )
       
   128     f_name = std::string(getenv("srcdir"));
       
   129   else f_name = ".";
       
   130   f_name += "/test/preflow_graph.lgf";
       
   131 
       
   132   std::ifstream file(f_name.c_str());
       
   133 
       
   134   check(file, "Input file '" << f_name << "' not found.");
       
   135 
       
   136   Digraph g;
   161   Digraph g;
   137   Node s, t;
   162   Node s, t;
   138   CapMap cap(g);
   163   CapMap cap(g);
   139   DigraphReader<Digraph>(g,file).
   164   std::istringstream input(test_lgf);
       
   165   DigraphReader<Digraph>(g,input).
   140     arcMap("capacity", cap).
   166     arcMap("capacity", cap).
   141     node("source",s).
   167     node("source",s).
   142     node("target",t).
   168     node("target",t).
   143     run();
   169     run();
   144 
   170