test/hao_orlin_test.cc
author Peter Kovacs <kpeter@inf.elte.hu>
Tue, 24 Mar 2009 00:18:25 +0100
changeset 604 8c3112a66878
parent 410 eac19fb31a09
child 596 293551ad254f
permissions -rw-r--r--
Use XTI implementation instead of ATI in NetworkSimplex (#234)

XTI (eXtended Threaded Index) is an imporved version of the widely
known ATI (Augmented Threaded Index) method for storing and updating
the spanning tree structure in Network Simplex algorithms.

In the ATI data structure three indices are stored for each node:
predecessor, thread and depth. In the XTI data structure depth is
replaced by the number of successors and the last successor
(according to the thread index).
     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-2009
     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 }