test/hao_orlin_test.cc
changeset 426 eac19fb31a09
child 463 88ed40ad0d4f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/hao_orlin_test.cc	Mon Dec 01 23:15:15 2008 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
     1.5 + *
     1.6 + * This file is a part of LEMON, a generic C++ optimization library.
     1.7 + *
     1.8 + * Copyright (C) 2003-2008
     1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 + *
    1.12 + * Permission to use, modify and distribute this software is granted
    1.13 + * provided that this copyright notice appears in all copies. For
    1.14 + * precise terms see the accompanying LICENSE file.
    1.15 + *
    1.16 + * This software is provided "AS IS" with no warranty of any kind,
    1.17 + * express or implied, and with no claim as to its suitability for any
    1.18 + * purpose.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#include <sstream>
    1.23 +
    1.24 +#include <lemon/smart_graph.h>
    1.25 +#include <lemon/hao_orlin.h>
    1.26 +
    1.27 +#include <lemon/lgf_reader.h>
    1.28 +#include "test_tools.h"
    1.29 +
    1.30 +using namespace lemon;
    1.31 +using namespace std;
    1.32 +
    1.33 +const std::string lgf =
    1.34 +  "@nodes\n"
    1.35 +  "label\n"
    1.36 +  "0\n"
    1.37 +  "1\n"
    1.38 +  "2\n"
    1.39 +  "3\n"
    1.40 +  "4\n"
    1.41 +  "5\n"
    1.42 +  "@edges\n"
    1.43 +  "     label  capacity\n"
    1.44 +  "0 1  0      2\n"
    1.45 +  "1 2  1      2\n"
    1.46 +  "2 0  2      2\n"
    1.47 +  "3 4  3      2\n"
    1.48 +  "4 5  4      2\n"
    1.49 +  "5 3  5      2\n"
    1.50 +  "2 3  6      3\n";
    1.51 +
    1.52 +int main() {
    1.53 +  SmartGraph graph;
    1.54 +  SmartGraph::EdgeMap<int> capacity(graph);
    1.55 +
    1.56 +  istringstream lgfs(lgf);
    1.57 +  graphReader(graph, lgfs).
    1.58 +    edgeMap("capacity", capacity).run();
    1.59 +
    1.60 +  HaoOrlin<SmartGraph, SmartGraph::EdgeMap<int> > ho(graph, capacity);
    1.61 +  ho.run();
    1.62 +
    1.63 +  check(ho.minCutValue() == 3, "Wrong cut value");
    1.64 +
    1.65 +  return 0;
    1.66 +}