# HG changeset patch # User Alpar Juttner # Date 1323582947 -3600 # Node ID 7768d68909e8da890a81ddad31e559d5e1994428 # Parent 3c30bd0f9cccb3f7f9bba178ce33df00c2c2dac1 Circulation test code added diff -r 3c30bd0f9ccc -r 7768d68909e8 CMakeLists.txt --- a/CMakeLists.txt Sun Dec 11 06:53:16 2011 +0100 +++ b/CMakeLists.txt Sun Dec 11 06:55:47 2011 +0100 @@ -87,6 +87,8 @@ ADD_SUBDIRECTORY(generators/netgen) ADD_SUBDIRECTORY(data) +ADD_SUBDIRECTORY(tests) + ####################################################################### ## CPACK configuration ## diff -r 3c30bd0f9ccc -r 7768d68909e8 tests/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/CMakeLists.txt Sun Dec 11 06:55:47 2011 +0100 @@ -0,0 +1,28 @@ +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/tests + # ${CMAKE_BINARY_DIR}/src +) + +LINK_DIRECTORIES( + # ${CMAKE_BINARY_DIR}/lemon +) + +ADD_EXECUTABLE(circulation + circulation.cc +) + +TARGET_LINK_LIBRARIES(circulation + lemon +) + + +## This tells cmake to install 'lemon-project' to $PREFIX/bin when +## 'make install' is executed. You can give more targets separated +## by whitespaces. + +INSTALL( + TARGETS + RUNTIME DESTINATION ${INSTALL_BIN_DIR} + COMPONENT bin +) + diff -r 3c30bd0f9ccc -r 7768d68909e8 tests/circulation.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/circulation.cc Sun Dec 11 06:55:47 2011 +0100 @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include + +const char test_name[] = "circulation"; + +using namespace lemon; + +int main(int argc, char **argv) +{ + if(argc!=2) exit(1); + + typedef int Value; + + SmartDigraph g; + + SmartDigraph::ArcMap lo_cap(g); + SmartDigraph::ArcMap up_cap(g); + SmartDigraph::ArcMap cost(g); + SmartDigraph::NodeMap sup(g); + + Timer ti; + try { + std::ifstream input; + input.open(argv[1]); + readDimacsMin(input, g, lo_cap, up_cap, cost, sup); + } catch (FormatError& error) { + std::cerr << error.what() << std::endl; + return 1; + } + std::cerr << "Read the file: " << ti << '\n'; + ti.restart(); + + Circulation,SmartDigraph::ArcMap, + SmartDigraph::NodeMap > circ(g,lo_cap,up_cap,sup); + std::cerr << "Setup Circulation class: " << ti << '\n'; + ti.restart(); + bool res = circ.run(); + if(res) + { + std::cerr << "A feasible circulation is found: " << ti << "\n"; + ti.restart(); + bool res2 = circ.checkFlow(); + std::cerr << "Checked in time " << ti << "\n"; + if(res2) + std::cerr << "Success!\nn"; + else + std::cerr << "Oops!!!!\n\n"; + } + else + { + std::cerr << "A dual solution is found: " << ti << "\n"; + ti.restart(); + bool res2 = circ.checkBarrier(); + std::cerr << "Checked in time " << ti << "\n"; + if(res2) + std::cerr << "Success!\nn"; + else + std::cerr << "Dual-Oops!!!!\n\n"; + + } +} +