[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Mon Dec 8 16:48:54 CET 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/b2564598b46d
changeset: 445:b2564598b46d
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Mon Dec 08 15:47:20 2008 +0000
description:
Merge
diffstat:
6 files changed, 91 insertions(+), 107 deletions(-)
test/CMakeLists.txt | 6 +++-
test/Makefile.am | 8 ++----
test/min_cost_flow_test.lgf | 44 -----------------------------------
test/preflow_graph.lgf | 34 ---------------------------
test/preflow_test.cc | 52 +++++++++++++++++++++++++++++++----------
test/suurballe_test.cc | 54 +++++++++++++++++++++++++++++++++++--------
diffs (truncated from 309 to 300 lines):
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -4,12 +4,14 @@
SET(TESTS
bfs_test
+ circulation_test
counter_test
dfs_test
digraph_test
dijkstra_test
dim_test
error_test
+ graph_adaptor_test
graph_copy_test
graph_test
graph_utils_test
@@ -18,8 +20,10 @@
kruskal_test
maps_test
max_matching_test
+ path_test
+ preflow_test
random_test
- path_test
+ suurballe_test
time_measure_test
unionfind_test)
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 \
@@ -20,14 +18,14 @@
test/graph_copy_test \
test/graph_test \
test/graph_utils_test \
+ test/hao_orlin_test \
test/heap_test \
test/kruskal_test \
- test/hao_orlin_test \
test/maps_test \
test/max_matching_test \
- test/random_test \
test/path_test \
test/preflow_test \
+ test/random_test \
test/suurballe_test \
test/test_tools_fail \
test/test_tools_pass \
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 @@
- at 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
-
- at 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
-
- at attributes
-source 1
-target 12
-
- at 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 @@
- at nodes
-label
-0
-1
-2
-3
-4
-5
-6
-7
-8
-9
- at 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
- at 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 <fstream>
-#include <string>
+#include <iostream>
#include "test_tools.h"
#include <lemon/smart_graph.h>
@@ -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<Digraph, CapMap> 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<Digraph>(g,file).
+ std::istringstream input(test_lgf);
+ DigraphReader<Digraph>(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 <iostream>
-#include <fstream>
#include <lemon/list_graph.h>
#include <lemon/lgf_reader.h>
@@ -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 <typename Digraph, typename FlowMap>
bool checkFlow( const Digraph& gr, const FlowMap& flow,
@@ -96,20 +138,12 @@
ListDigraph::ArcMap<int> 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);
More information about the Lemon-commits
mailing list