test/hao_orlin_test.cc
changeset 452 aea2dc0518ce
child 440 88ed40ad0d4f
equal deleted inserted replaced
-1:000000000000 0:a2d3c0aab6d5
       
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
       
     2  *
       
     3  * This file is a part of LEMON, a generic C++ optimization library.
       
     4  *
       
     5  * Copyright (C) 2003-2008
       
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
       
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
       
     8  *
       
     9  * Permission to use, modify and distribute this software is granted
       
    10  * provided that this copyright notice appears in all copies. For
       
    11  * precise terms see the accompanying LICENSE file.
       
    12  *
       
    13  * This software is provided "AS IS" with no warranty of any kind,
       
    14  * express or implied, and with no claim as to its suitability for any
       
    15  * purpose.
       
    16  *
       
    17  */
       
    18 
       
    19 #include <sstream>
       
    20 
       
    21 #include <lemon/smart_graph.h>
       
    22 #include <lemon/hao_orlin.h>
       
    23 
       
    24 #include <lemon/lgf_reader.h>
       
    25 #include "test_tools.h"
       
    26 
       
    27 using namespace lemon;
       
    28 using namespace std;
       
    29 
       
    30 const std::string lgf =
       
    31   "@nodes\n"
       
    32   "label\n"
       
    33   "0\n"
       
    34   "1\n"
       
    35   "2\n"
       
    36   "3\n"
       
    37   "4\n"
       
    38   "5\n"
       
    39   "@edges\n"
       
    40   "     label  capacity\n"
       
    41   "0 1  0      2\n"
       
    42   "1 2  1      2\n"
       
    43   "2 0  2      2\n"
       
    44   "3 4  3      2\n"
       
    45   "4 5  4      2\n"
       
    46   "5 3  5      2\n"
       
    47   "2 3  6      3\n";
       
    48 
       
    49 int main() {
       
    50   SmartGraph graph;
       
    51   SmartGraph::EdgeMap<int> capacity(graph);
       
    52 
       
    53   istringstream lgfs(lgf);
       
    54   graphReader(graph, lgfs).
       
    55     edgeMap("capacity", capacity).run();
       
    56 
       
    57   HaoOrlin<SmartGraph, SmartGraph::EdgeMap<int> > ho(graph, capacity);
       
    58   ho.run();
       
    59 
       
    60   check(ho.minCutValue() == 3, "Wrong cut value");
       
    61 
       
    62   return 0;
       
    63 }