Location: LEMON/LEMON-official/lemon/bits/path_dump.h - annotation
Load file history
Porting Gomory-Hu algorithm (#66)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r463:88ed40ad0d4f r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r576:f5bc148f7e1f r576:f5bc148f7e1f r100:4f754b4cf82b r566:c786cd201266 r566:c786cd201266 r566:c786cd201266 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r209:765619b7cbb2 r209:765619b7cbb2 r100:4f754b4cf82b r209:765619b7cbb2 r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b | /* -*- mode: C++; indent-tabs-mode: nil; -*-
*
* This file is a part of LEMON, a generic C++ optimization library.
*
* Copyright (C) 2003-2009
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
#ifndef LEMON_BITS_PATH_DUMP_H
#define LEMON_BITS_PATH_DUMP_H
#include <lemon/core.h>
#include <lemon/concept_check.h>
namespace lemon {
template <typename _Digraph, typename _PredMap>
class PredMapPath {
public:
typedef True RevPathTag;
typedef _Digraph Digraph;
typedef typename Digraph::Arc Arc;
typedef _PredMap PredMap;
PredMapPath(const Digraph& _digraph, const PredMap& _predMap,
typename Digraph::Node _target)
: digraph(_digraph), predMap(_predMap), target(_target) {}
int length() const {
int len = 0;
typename Digraph::Node node = target;
typename Digraph::Arc arc;
while ((arc = predMap[node]) != INVALID) {
node = digraph.source(arc);
++len;
}
return len;
}
bool empty() const {
return predMap[target] != INVALID;
}
class RevArcIt {
public:
RevArcIt() {}
RevArcIt(Invalid) : path(0), current(INVALID) {}
RevArcIt(const PredMapPath& _path)
: path(&_path), current(_path.target) {
if (path->predMap[current] == INVALID) current = INVALID;
}
operator const typename Digraph::Arc() const {
return path->predMap[current];
}
RevArcIt& operator++() {
current = path->digraph.source(path->predMap[current]);
if (path->predMap[current] == INVALID) current = INVALID;
return *this;
}
bool operator==(const RevArcIt& e) const {
return current == e.current;
}
bool operator!=(const RevArcIt& e) const {
return current != e.current;
}
bool operator<(const RevArcIt& e) const {
return current < e.current;
}
private:
const PredMapPath* path;
typename Digraph::Node current;
};
private:
const Digraph& digraph;
const PredMap& predMap;
typename Digraph::Node target;
};
template <typename _Digraph, typename _PredMatrixMap>
class PredMatrixMapPath {
public:
typedef True RevPathTag;
typedef _Digraph Digraph;
typedef typename Digraph::Arc Arc;
typedef _PredMatrixMap PredMatrixMap;
PredMatrixMapPath(const Digraph& _digraph,
const PredMatrixMap& _predMatrixMap,
typename Digraph::Node _source,
typename Digraph::Node _target)
: digraph(_digraph), predMatrixMap(_predMatrixMap),
source(_source), target(_target) {}
int length() const {
int len = 0;
typename Digraph::Node node = target;
typename Digraph::Arc arc;
while ((arc = predMatrixMap(source, node)) != INVALID) {
node = digraph.source(arc);
++len;
}
return len;
}
bool empty() const {
return source != target;
}
class RevArcIt {
public:
RevArcIt() {}
RevArcIt(Invalid) : path(0), current(INVALID) {}
RevArcIt(const PredMatrixMapPath& _path)
: path(&_path), current(_path.target) {
if (path->predMatrixMap(path->source, current) == INVALID)
current = INVALID;
}
operator const typename Digraph::Arc() const {
return path->predMatrixMap(path->source, current);
}
RevArcIt& operator++() {
current =
path->digraph.source(path->predMatrixMap(path->source, current));
if (path->predMatrixMap(path->source, current) == INVALID)
current = INVALID;
return *this;
}
bool operator==(const RevArcIt& e) const {
return current == e.current;
}
bool operator!=(const RevArcIt& e) const {
return current != e.current;
}
bool operator<(const RevArcIt& e) const {
return current < e.current;
}
private:
const PredMatrixMapPath* path;
typename Digraph::Node current;
};
private:
const Digraph& digraph;
const PredMatrixMap& predMatrixMap;
typename Digraph::Node source;
typename Digraph::Node target;
};
}
#endif
|