diff --git a/test/Makefile.am b/test/Makefile.am --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,7 +1,5 @@ EXTRA_DIST += \ - test/CMakeLists.txt \ - test/min_cost_flow_test.lgf \ - test/preflow_graph.lgf + test/CMakeLists.txt noinst_HEADERS += \ test/graph_test.h \ diff --git a/test/min_cost_flow_test.lgf b/test/min_cost_flow_test.lgf deleted file mode 100644 --- a/test/min_cost_flow_test.lgf +++ /dev/null @@ -1,44 +0,0 @@ -@nodes -label supply1 supply2 supply3 -1 0 20 27 -2 0 -4 0 -3 0 0 0 -4 0 0 0 -5 0 9 0 -6 0 -6 0 -7 0 0 0 -8 0 0 0 -9 0 3 0 -10 0 -2 0 -11 0 0 0 -12 0 -20 -27 - -@arcs - cost capacity lower1 lower2 -1 2 70 11 0 8 -1 3 150 3 0 1 -1 4 80 15 0 2 -2 8 80 12 0 0 -3 5 140 5 0 3 -4 6 60 10 0 1 -4 7 80 2 0 0 -4 8 110 3 0 0 -5 7 60 14 0 0 -5 11 120 12 0 0 -6 3 0 3 0 0 -6 9 140 4 0 0 -6 10 90 8 0 0 -7 1 30 5 0 0 -8 12 60 16 0 4 -9 12 50 6 0 0 -10 12 70 13 0 5 -10 2 100 7 0 0 -10 7 60 10 0 0 -11 10 20 14 0 6 -12 11 30 10 0 0 - -@attributes -source 1 -target 12 - -@end diff --git a/test/preflow_graph.lgf b/test/preflow_graph.lgf deleted file mode 100644 --- a/test/preflow_graph.lgf +++ /dev/null @@ -1,34 +0,0 @@ -@nodes -label -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -@arcs - label capacity -0 1 0 20 -0 2 1 0 -1 1 2 3 -1 2 3 8 -1 3 4 8 -2 5 5 5 -3 2 6 5 -3 5 7 5 -3 6 8 5 -4 3 9 3 -5 7 10 3 -5 6 11 10 -5 8 12 10 -6 8 13 8 -8 9 14 20 -8 1 15 5 -9 5 16 5 -@attributes -source 1 -target 8 diff --git a/test/preflow_test.cc b/test/preflow_test.cc --- a/test/preflow_test.cc +++ b/test/preflow_test.cc @@ -16,8 +16,7 @@ * */ -#include -#include +#include #include "test_tools.h" #include @@ -29,6 +28,42 @@ using namespace lemon; +char test_lgf[] = + "@nodes\n" + "label\n" + "0\n" + "1\n" + "2\n" + "3\n" + "4\n" + "5\n" + "6\n" + "7\n" + "8\n" + "9\n" + "@arcs\n" + " label capacity\n" + "0 1 0 20\n" + "0 2 1 0\n" + "1 1 2 3\n" + "1 2 3 8\n" + "1 3 4 8\n" + "2 5 5 5\n" + "3 2 6 5\n" + "3 5 7 5\n" + "3 6 8 5\n" + "4 3 9 3\n" + "5 7 10 3\n" + "5 6 11 10\n" + "5 8 12 10\n" + "6 8 13 8\n" + "8 9 14 20\n" + "8 1 15 5\n" + "9 5 16 5\n" + "@attributes\n" + "source 1\n" + "target 8\n"; + void checkPreflowCompile() { typedef int VType; @@ -123,20 +158,11 @@ typedef Preflow PType; - std::string f_name; - if( getenv("srcdir") ) - f_name = std::string(getenv("srcdir")); - else f_name = "."; - f_name += "/test/preflow_graph.lgf"; - - std::ifstream file(f_name.c_str()); - - check(file, "Input file '" << f_name << "' not found."); - Digraph g; Node s, t; CapMap cap(g); - DigraphReader(g,file). + std::istringstream input(test_lgf); + DigraphReader(g,input). arcMap("capacity", cap). node("source",s). node("target",t). diff --git a/test/suurballe_test.cc b/test/suurballe_test.cc --- a/test/suurballe_test.cc +++ b/test/suurballe_test.cc @@ -17,7 +17,6 @@ */ #include -#include #include #include @@ -28,6 +27,49 @@ using namespace lemon; +char test_lgf[] = + "@nodes\n" + "label supply1 supply2 supply3\n" + "1 0 20 27\n" + "2 0 -4 0\n" + "3 0 0 0\n" + "4 0 0 0\n" + "5 0 9 0\n" + "6 0 -6 0\n" + "7 0 0 0\n" + "8 0 0 0\n" + "9 0 3 0\n" + "10 0 -2 0\n" + "11 0 0 0\n" + "12 0 -20 -27\n" + "@arcs\n" + " cost capacity lower1 lower2\n" + " 1 2 70 11 0 8\n" + " 1 3 150 3 0 1\n" + " 1 4 80 15 0 2\n" + " 2 8 80 12 0 0\n" + " 3 5 140 5 0 3\n" + " 4 6 60 10 0 1\n" + " 4 7 80 2 0 0\n" + " 4 8 110 3 0 0\n" + " 5 7 60 14 0 0\n" + " 5 11 120 12 0 0\n" + " 6 3 0 3 0 0\n" + " 6 9 140 4 0 0\n" + " 6 10 90 8 0 0\n" + " 7 1 30 5 0 0\n" + " 8 12 60 16 0 4\n" + " 9 12 50 6 0 0\n" + "10 12 70 13 0 5\n" + "10 2 100 7 0 0\n" + "10 7 60 10 0 0\n" + "11 10 20 14 0 6\n" + "12 11 30 10 0 0\n" + "@attributes\n" + "source 1\n" + "target 12\n" + "@end\n"; + // Check the feasibility of the flow template bool checkFlow( const Digraph& gr, const FlowMap& flow, @@ -96,20 +138,12 @@ ListDigraph::ArcMap length(digraph); Node source, target; - std::string fname; - if(getenv("srcdir")) - fname = std::string(getenv("srcdir")); - else fname = "."; - fname += "/test/min_cost_flow_test.lgf"; - - std::ifstream input(fname.c_str()); - check(input, "Input file '" << fname << "' not found"); + std::istringstream input(test_lgf); DigraphReader(digraph, input). arcMap("cost", length). node("source", source). node("target", target). run(); - input.close(); // Find 2 paths {