Simple test for HaoOrlin algorithm class (#58)
authorBalazs Dezso <deba@inf.elte.hu>
Mon, 01 Dec 2008 23:15:15 +0100
changeset 426eac19fb31a09
parent 425 b8ce15103485
child 427 01c443515ad2
Simple test for HaoOrlin algorithm class (#58)
test/CMakeLists.txt
test/Makefile.am
test/hao_orlin_test.cc
     1.1 --- a/test/CMakeLists.txt	Mon Dec 01 23:12:16 2008 +0100
     1.2 +++ b/test/CMakeLists.txt	Mon Dec 01 23:15:15 2008 +0100
     1.3 @@ -13,6 +13,7 @@
     1.4    graph_copy_test
     1.5    graph_test
     1.6    graph_utils_test
     1.7 +  hao_orlin_test
     1.8    heap_test
     1.9    kruskal_test
    1.10    maps_test
     2.1 --- a/test/Makefile.am	Mon Dec 01 23:12:16 2008 +0100
     2.2 +++ b/test/Makefile.am	Mon Dec 01 23:15:15 2008 +0100
     2.3 @@ -21,6 +21,7 @@
     2.4  	test/graph_utils_test \
     2.5  	test/heap_test \
     2.6  	test/kruskal_test \
     2.7 +	test/hao_orlin_test \
     2.8          test/maps_test \
     2.9  	test/max_matching_test \
    2.10          test/random_test \
    2.11 @@ -48,6 +49,7 @@
    2.12  test_graph_utils_test_SOURCES = test/graph_utils_test.cc
    2.13  test_heap_test_SOURCES = test/heap_test.cc
    2.14  test_kruskal_test_SOURCES = test/kruskal_test.cc
    2.15 +test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc
    2.16  test_maps_test_SOURCES = test/maps_test.cc
    2.17  test_max_matching_test_SOURCES = test/max_matching_test.cc
    2.18  test_path_test_SOURCES = test/path_test.cc
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/hao_orlin_test.cc	Mon Dec 01 23:15:15 2008 +0100
     3.3 @@ -0,0 +1,63 @@
     3.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
     3.5 + *
     3.6 + * This file is a part of LEMON, a generic C++ optimization library.
     3.7 + *
     3.8 + * Copyright (C) 2003-2008
     3.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    3.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    3.11 + *
    3.12 + * Permission to use, modify and distribute this software is granted
    3.13 + * provided that this copyright notice appears in all copies. For
    3.14 + * precise terms see the accompanying LICENSE file.
    3.15 + *
    3.16 + * This software is provided "AS IS" with no warranty of any kind,
    3.17 + * express or implied, and with no claim as to its suitability for any
    3.18 + * purpose.
    3.19 + *
    3.20 + */
    3.21 +
    3.22 +#include <sstream>
    3.23 +
    3.24 +#include <lemon/smart_graph.h>
    3.25 +#include <lemon/hao_orlin.h>
    3.26 +
    3.27 +#include <lemon/lgf_reader.h>
    3.28 +#include "test_tools.h"
    3.29 +
    3.30 +using namespace lemon;
    3.31 +using namespace std;
    3.32 +
    3.33 +const std::string lgf =
    3.34 +  "@nodes\n"
    3.35 +  "label\n"
    3.36 +  "0\n"
    3.37 +  "1\n"
    3.38 +  "2\n"
    3.39 +  "3\n"
    3.40 +  "4\n"
    3.41 +  "5\n"
    3.42 +  "@edges\n"
    3.43 +  "     label  capacity\n"
    3.44 +  "0 1  0      2\n"
    3.45 +  "1 2  1      2\n"
    3.46 +  "2 0  2      2\n"
    3.47 +  "3 4  3      2\n"
    3.48 +  "4 5  4      2\n"
    3.49 +  "5 3  5      2\n"
    3.50 +  "2 3  6      3\n";
    3.51 +
    3.52 +int main() {
    3.53 +  SmartGraph graph;
    3.54 +  SmartGraph::EdgeMap<int> capacity(graph);
    3.55 +
    3.56 +  istringstream lgfs(lgf);
    3.57 +  graphReader(graph, lgfs).
    3.58 +    edgeMap("capacity", capacity).run();
    3.59 +
    3.60 +  HaoOrlin<SmartGraph, SmartGraph::EdgeMap<int> > ho(graph, capacity);
    3.61 +  ho.run();
    3.62 +
    3.63 +  check(ho.minCutValue() == 3, "Wrong cut value");
    3.64 +
    3.65 +  return 0;
    3.66 +}