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