0
13
0
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
namespace lemon { |
20 | 20 |
/*! |
21 | 21 |
|
22 | 22 |
|
23 | 23 |
|
24 | 24 |
\page lgf-format LEMON Graph Format (LGF) |
25 | 25 |
|
26 | 26 |
The \e LGF is a <em>column oriented</em> |
27 | 27 |
file format for storing graphs and associated data like |
28 | 28 |
node and edge maps. |
29 | 29 |
|
30 | 30 |
Each line with \c '#' first non-whitespace |
31 | 31 |
character is considered as a comment line. |
32 | 32 |
|
33 | 33 |
Otherwise the file consists of sections starting with |
34 | 34 |
a header line. The header lines starts with an \c '@' character followed by the |
35 | 35 |
type of section. The standard section types are \c \@nodes, \c |
36 | 36 |
\@arcs and \c \@edges |
37 | 37 |
and \@attributes. Each header line may also have an optional |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H |
20 | 20 |
#define LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H |
21 | 21 |
|
22 | 22 |
#include <lemon/core.h> |
23 | 23 |
#include <lemon/error.h> |
24 | 24 |
|
25 | 25 |
namespace lemon { |
26 | 26 |
|
27 | 27 |
template <typename _Digraph> |
28 | 28 |
class DigraphAdaptorExtender : public _Digraph { |
29 | 29 |
typedef _Digraph Parent; |
30 | 30 |
|
31 | 31 |
public: |
32 | 32 |
|
33 | 33 |
typedef _Digraph Digraph; |
34 | 34 |
typedef DigraphAdaptorExtender Adaptor; |
35 | 35 |
|
36 | 36 |
// Base extensions |
37 | 37 |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_PATH_DUMP_H |
20 | 20 |
#define LEMON_BITS_PATH_DUMP_H |
21 | 21 |
|
22 | 22 |
#include <lemon/core.h> |
23 | 23 |
#include <lemon/concept_check.h> |
24 | 24 |
|
25 | 25 |
namespace lemon { |
26 | 26 |
|
27 | 27 |
template <typename _Digraph, typename _PredMap> |
28 | 28 |
class PredMapPath { |
29 | 29 |
public: |
30 | 30 |
typedef True RevPathTag; |
31 | 31 |
|
32 | 32 |
typedef _Digraph Digraph; |
33 | 33 |
typedef typename Digraph::Arc Arc; |
34 | 34 |
typedef _PredMap PredMap; |
35 | 35 |
|
36 | 36 |
PredMapPath(const Digraph& _digraph, const PredMap& _predMap, |
37 | 37 |
typename Digraph::Node _target) |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
///\file |
20 | 20 |
///\brief Some basic non-inline functions and static global data. |
21 | 21 |
|
22 | 22 |
#include<lemon/bits/windows.h> |
23 | 23 |
|
24 | 24 |
#ifdef WIN32 |
25 | 25 |
#ifndef WIN32_LEAN_AND_MEAN |
26 | 26 |
#define WIN32_LEAN_AND_MEAN |
27 | 27 |
#endif |
28 | 28 |
#ifndef NOMINMAX |
29 | 29 |
#define NOMINMAX |
30 | 30 |
#endif |
31 | 31 |
#ifdef UNICODE |
32 | 32 |
#undef UNICODE |
33 | 33 |
#endif |
34 | 34 |
#include <windows.h> |
35 | 35 |
#ifdef LOCALE_INVARIANT |
36 | 36 |
#define MY_LOCALE LOCALE_INVARIANT |
37 | 37 |
#else |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_COST_SCALING_H |
20 | 20 |
#define LEMON_COST_SCALING_H |
21 | 21 |
|
22 | 22 |
/// \ingroup min_cost_flow_algs |
23 | 23 |
/// \file |
24 | 24 |
/// \brief Cost scaling algorithm for finding a minimum cost flow. |
25 | 25 |
|
26 | 26 |
#include <vector> |
27 | 27 |
#include <deque> |
28 | 28 |
#include <limits> |
29 | 29 |
|
30 | 30 |
#include <lemon/core.h> |
31 | 31 |
#include <lemon/maps.h> |
32 | 32 |
#include <lemon/math.h> |
33 | 33 |
#include <lemon/static_graph.h> |
34 | 34 |
#include <lemon/circulation.h> |
35 | 35 |
#include <lemon/bellman_ford.h> |
36 | 36 |
|
37 | 37 |
namespace lemon { |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_MAPS_H |
20 | 20 |
#define LEMON_MAPS_H |
21 | 21 |
|
22 | 22 |
#include <iterator> |
23 | 23 |
#include <functional> |
24 | 24 |
#include <vector> |
25 | 25 |
#include <map> |
26 | 26 |
|
27 | 27 |
#include <lemon/core.h> |
28 | 28 |
|
29 | 29 |
///\file |
30 | 30 |
///\ingroup maps |
31 | 31 |
///\brief Miscellaneous property maps |
32 | 32 |
|
33 | 33 |
namespace lemon { |
34 | 34 |
|
35 | 35 |
/// \addtogroup maps |
36 | 36 |
/// @{ |
37 | 37 |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_PREFLOW_H |
20 | 20 |
#define LEMON_PREFLOW_H |
21 | 21 |
|
22 | 22 |
#include <lemon/tolerance.h> |
23 | 23 |
#include <lemon/elevator.h> |
24 | 24 |
|
25 | 25 |
/// \file |
26 | 26 |
/// \ingroup max_flow |
27 | 27 |
/// \brief Implementation of the preflow algorithm. |
28 | 28 |
|
29 | 29 |
namespace lemon { |
30 | 30 |
|
31 | 31 |
/// \brief Default traits class of Preflow class. |
32 | 32 |
/// |
33 | 33 |
/// Default traits class of Preflow class. |
34 | 34 |
/// \tparam GR Digraph type. |
35 | 35 |
/// \tparam CAP Capacity map type. |
36 | 36 |
template <typename GR, typename CAP> |
37 | 37 |
struct PreflowDefaultTraits { |
... | ... |
@@ -525,96 +525,96 @@ |
525 | 525 |
} |
526 | 526 |
for (OutArcIt e(_graph, n); e != INVALID; ++e) { |
527 | 527 |
Node v = _graph.target(e); |
528 | 528 |
if (!reached[v] && _tolerance.positive((*_flow)[e])) { |
529 | 529 |
reached[v] = true; |
530 | 530 |
_level->initAddItem(v); |
531 | 531 |
nqueue.push_back(v); |
532 | 532 |
} |
533 | 533 |
} |
534 | 534 |
} |
535 | 535 |
queue.swap(nqueue); |
536 | 536 |
} |
537 | 537 |
_level->initFinish(); |
538 | 538 |
|
539 | 539 |
for (OutArcIt e(_graph, _source); e != INVALID; ++e) { |
540 | 540 |
Value rem = (*_capacity)[e] - (*_flow)[e]; |
541 | 541 |
if (_tolerance.positive(rem)) { |
542 | 542 |
Node u = _graph.target(e); |
543 | 543 |
if ((*_level)[u] == _level->maxLevel()) continue; |
544 | 544 |
_flow->set(e, (*_capacity)[e]); |
545 | 545 |
(*_excess)[u] += rem; |
546 | 546 |
} |
547 | 547 |
} |
548 | 548 |
for (InArcIt e(_graph, _source); e != INVALID; ++e) { |
549 | 549 |
Value rem = (*_flow)[e]; |
550 | 550 |
if (_tolerance.positive(rem)) { |
551 | 551 |
Node v = _graph.source(e); |
552 | 552 |
if ((*_level)[v] == _level->maxLevel()) continue; |
553 | 553 |
_flow->set(e, 0); |
554 | 554 |
(*_excess)[v] += rem; |
555 | 555 |
} |
556 | 556 |
} |
557 |
for (NodeIt n(_graph); n != INVALID; ++n) |
|
557 |
for (NodeIt n(_graph); n != INVALID; ++n) |
|
558 | 558 |
if(n!=_source && n!=_target && _tolerance.positive((*_excess)[n])) |
559 | 559 |
_level->activate(n); |
560 |
|
|
560 |
|
|
561 | 561 |
return true; |
562 | 562 |
} |
563 | 563 |
|
564 | 564 |
/// \brief Starts the first phase of the preflow algorithm. |
565 | 565 |
/// |
566 | 566 |
/// The preflow algorithm consists of two phases, this method runs |
567 | 567 |
/// the first phase. After the first phase the maximum flow value |
568 | 568 |
/// and a minimum value cut can already be computed, although a |
569 | 569 |
/// maximum flow is not yet obtained. So after calling this method |
570 | 570 |
/// \ref flowValue() returns the value of a maximum flow and \ref |
571 | 571 |
/// minCut() returns a minimum cut. |
572 | 572 |
/// \pre One of the \ref init() functions must be called before |
573 | 573 |
/// using this function. |
574 | 574 |
void startFirstPhase() { |
575 | 575 |
_phase = true; |
576 | 576 |
|
577 | 577 |
while (true) { |
578 | 578 |
int num = _node_num; |
579 | 579 |
|
580 | 580 |
Node n = INVALID; |
581 | 581 |
int level = -1; |
582 | 582 |
|
583 | 583 |
while (num > 0) { |
584 | 584 |
n = _level->highestActive(); |
585 | 585 |
if (n == INVALID) goto first_phase_done; |
586 | 586 |
level = _level->highestActiveLevel(); |
587 | 587 |
--num; |
588 |
|
|
588 |
|
|
589 | 589 |
Value excess = (*_excess)[n]; |
590 | 590 |
int new_level = _level->maxLevel(); |
591 | 591 |
|
592 | 592 |
for (OutArcIt e(_graph, n); e != INVALID; ++e) { |
593 | 593 |
Value rem = (*_capacity)[e] - (*_flow)[e]; |
594 | 594 |
if (!_tolerance.positive(rem)) continue; |
595 | 595 |
Node v = _graph.target(e); |
596 | 596 |
if ((*_level)[v] < level) { |
597 | 597 |
if (!_level->active(v) && v != _target) { |
598 | 598 |
_level->activate(v); |
599 | 599 |
} |
600 | 600 |
if (!_tolerance.less(rem, excess)) { |
601 | 601 |
_flow->set(e, (*_flow)[e] + excess); |
602 | 602 |
(*_excess)[v] += excess; |
603 | 603 |
excess = 0; |
604 | 604 |
goto no_more_push_1; |
605 | 605 |
} else { |
606 | 606 |
excess -= rem; |
607 | 607 |
(*_excess)[v] += rem; |
608 | 608 |
_flow->set(e, (*_capacity)[e]); |
609 | 609 |
} |
610 | 610 |
} else if (new_level > (*_level)[v]) { |
611 | 611 |
new_level = (*_level)[v]; |
612 | 612 |
} |
613 | 613 |
} |
614 | 614 |
|
615 | 615 |
for (InArcIt e(_graph, n); e != INVALID; ++e) { |
616 | 616 |
Value rem = (*_flow)[e]; |
617 | 617 |
if (!_tolerance.positive(rem)) continue; |
618 | 618 |
Node v = _graph.source(e); |
619 | 619 |
if ((*_level)[v] < level) { |
620 | 620 |
if (!_level->active(v) && v != _target) { |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <lemon/concepts/digraph.h> |
20 | 20 |
#include <lemon/smart_graph.h> |
21 | 21 |
#include <lemon/list_graph.h> |
22 | 22 |
#include <lemon/lgf_reader.h> |
23 | 23 |
#include <lemon/dfs.h> |
24 | 24 |
#include <lemon/path.h> |
25 | 25 |
|
26 | 26 |
#include "graph_test.h" |
27 | 27 |
#include "test_tools.h" |
28 | 28 |
|
29 | 29 |
using namespace lemon; |
30 | 30 |
|
31 | 31 |
char test_lgf[] = |
32 | 32 |
"@nodes\n" |
33 | 33 |
"label\n" |
34 | 34 |
"0\n" |
35 | 35 |
"1\n" |
36 | 36 |
"2\n" |
37 | 37 |
"3\n" |
... | ... |
@@ -190,45 +190,45 @@ |
190 | 190 |
node("target", t). |
191 | 191 |
node("source1", s1). |
192 | 192 |
node("target1", t1). |
193 | 193 |
run(); |
194 | 194 |
|
195 | 195 |
Dfs<Digraph> dfs_test(G); |
196 | 196 |
dfs_test.run(s); |
197 | 197 |
|
198 | 198 |
Path<Digraph> p = dfs_test.path(t); |
199 | 199 |
check(p.length() == dfs_test.dist(t),"path() found a wrong path."); |
200 | 200 |
check(checkPath(G, p),"path() found a wrong path."); |
201 | 201 |
check(pathSource(G, p) == s,"path() found a wrong path."); |
202 | 202 |
check(pathTarget(G, p) == t,"path() found a wrong path."); |
203 | 203 |
|
204 | 204 |
for(NodeIt v(G); v!=INVALID; ++v) { |
205 | 205 |
if (dfs_test.reached(v)) { |
206 | 206 |
check(v==s || dfs_test.predArc(v)!=INVALID, "Wrong tree."); |
207 | 207 |
if (dfs_test.predArc(v)!=INVALID ) { |
208 | 208 |
Arc e=dfs_test.predArc(v); |
209 | 209 |
Node u=G.source(e); |
210 | 210 |
check(u==dfs_test.predNode(v),"Wrong tree."); |
211 | 211 |
check(dfs_test.dist(v) - dfs_test.dist(u) == 1, |
212 | 212 |
"Wrong distance. (" << dfs_test.dist(u) << "->" |
213 | 213 |
<< dfs_test.dist(v) << ")"); |
214 | 214 |
} |
215 | 215 |
} |
216 | 216 |
} |
217 | 217 |
|
218 | 218 |
{ |
219 | 219 |
Dfs<Digraph> dfs(G); |
220 | 220 |
check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6."); |
221 | 221 |
} |
222 |
|
|
222 |
|
|
223 | 223 |
{ |
224 | 224 |
NullMap<Node,Arc> myPredMap; |
225 | 225 |
dfs(G).predMap(myPredMap).run(s); |
226 | 226 |
} |
227 | 227 |
} |
228 | 228 |
|
229 | 229 |
int main() |
230 | 230 |
{ |
231 | 231 |
checkDfs<ListDigraph>(); |
232 | 232 |
checkDfs<SmartDigraph>(); |
233 | 233 |
return 0; |
234 | 234 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <lemon/smart_graph.h> |
20 | 20 |
#include <lemon/list_graph.h> |
21 | 21 |
#include <lemon/lgf_reader.h> |
22 | 22 |
#include <lemon/error.h> |
23 | 23 |
|
24 | 24 |
#include "test_tools.h" |
25 | 25 |
|
26 | 26 |
using namespace std; |
27 | 27 |
using namespace lemon; |
28 | 28 |
|
29 | 29 |
void digraph_copy_test() { |
30 | 30 |
const int nn = 10; |
31 | 31 |
|
32 | 32 |
// Build a digraph |
33 | 33 |
SmartDigraph from; |
34 | 34 |
SmartDigraph::NodeMap<int> fnm(from); |
35 | 35 |
SmartDigraph::ArcMap<int> fam(from); |
36 | 36 |
SmartDigraph::Node fn = INVALID; |
37 | 37 |
SmartDigraph::Arc fa = INVALID; |
... | ... |
@@ -41,93 +41,93 @@ |
41 | 41 |
SmartDigraph::Node node = from.addNode(); |
42 | 42 |
fnv.push_back(node); |
43 | 43 |
fnm[node] = i * i; |
44 | 44 |
if (i == 0) fn = node; |
45 | 45 |
} |
46 | 46 |
|
47 | 47 |
for (int i = 0; i < nn; ++i) { |
48 | 48 |
for (int j = 0; j < nn; ++j) { |
49 | 49 |
SmartDigraph::Arc arc = from.addArc(fnv[i], fnv[j]); |
50 | 50 |
fam[arc] = i + j * j; |
51 | 51 |
if (i == 0 && j == 0) fa = arc; |
52 | 52 |
} |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
// Test digraph copy |
56 | 56 |
ListDigraph to; |
57 | 57 |
ListDigraph::NodeMap<int> tnm(to); |
58 | 58 |
ListDigraph::ArcMap<int> tam(to); |
59 | 59 |
ListDigraph::Node tn; |
60 | 60 |
ListDigraph::Arc ta; |
61 | 61 |
|
62 | 62 |
SmartDigraph::NodeMap<ListDigraph::Node> nr(from); |
63 | 63 |
SmartDigraph::ArcMap<ListDigraph::Arc> er(from); |
64 | 64 |
|
65 | 65 |
ListDigraph::NodeMap<SmartDigraph::Node> ncr(to); |
66 | 66 |
ListDigraph::ArcMap<SmartDigraph::Arc> ecr(to); |
67 | 67 |
|
68 | 68 |
digraphCopy(from, to). |
69 | 69 |
nodeMap(fnm, tnm).arcMap(fam, tam). |
70 | 70 |
nodeRef(nr).arcRef(er). |
71 | 71 |
nodeCrossRef(ncr).arcCrossRef(ecr). |
72 | 72 |
node(fn, tn).arc(fa, ta).run(); |
73 |
|
|
73 |
|
|
74 | 74 |
check(countNodes(from) == countNodes(to), "Wrong copy."); |
75 | 75 |
check(countArcs(from) == countArcs(to), "Wrong copy."); |
76 | 76 |
|
77 | 77 |
for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) { |
78 | 78 |
check(ncr[nr[it]] == it, "Wrong copy."); |
79 | 79 |
check(fnm[it] == tnm[nr[it]], "Wrong copy."); |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
for (SmartDigraph::ArcIt it(from); it != INVALID; ++it) { |
83 | 83 |
check(ecr[er[it]] == it, "Wrong copy."); |
84 | 84 |
check(fam[it] == tam[er[it]], "Wrong copy."); |
85 | 85 |
check(nr[from.source(it)] == to.source(er[it]), "Wrong copy."); |
86 | 86 |
check(nr[from.target(it)] == to.target(er[it]), "Wrong copy."); |
87 | 87 |
} |
88 | 88 |
|
89 | 89 |
for (ListDigraph::NodeIt it(to); it != INVALID; ++it) { |
90 | 90 |
check(nr[ncr[it]] == it, "Wrong copy."); |
91 | 91 |
} |
92 | 92 |
|
93 | 93 |
for (ListDigraph::ArcIt it(to); it != INVALID; ++it) { |
94 | 94 |
check(er[ecr[it]] == it, "Wrong copy."); |
95 | 95 |
} |
96 | 96 |
check(tn == nr[fn], "Wrong copy."); |
97 | 97 |
check(ta == er[fa], "Wrong copy."); |
98 | 98 |
|
99 | 99 |
// Test repeated copy |
100 | 100 |
digraphCopy(from, to).run(); |
101 |
|
|
101 |
|
|
102 | 102 |
check(countNodes(from) == countNodes(to), "Wrong copy."); |
103 | 103 |
check(countArcs(from) == countArcs(to), "Wrong copy."); |
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
void graph_copy_test() { |
107 | 107 |
const int nn = 10; |
108 | 108 |
|
109 | 109 |
// Build a graph |
110 | 110 |
SmartGraph from; |
111 | 111 |
SmartGraph::NodeMap<int> fnm(from); |
112 | 112 |
SmartGraph::ArcMap<int> fam(from); |
113 | 113 |
SmartGraph::EdgeMap<int> fem(from); |
114 | 114 |
SmartGraph::Node fn = INVALID; |
115 | 115 |
SmartGraph::Arc fa = INVALID; |
116 | 116 |
SmartGraph::Edge fe = INVALID; |
117 | 117 |
|
118 | 118 |
std::vector<SmartGraph::Node> fnv; |
119 | 119 |
for (int i = 0; i < nn; ++i) { |
120 | 120 |
SmartGraph::Node node = from.addNode(); |
121 | 121 |
fnv.push_back(node); |
122 | 122 |
fnm[node] = i * i; |
123 | 123 |
if (i == 0) fn = node; |
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
for (int i = 0; i < nn; ++i) { |
127 | 127 |
for (int j = 0; j < nn; ++j) { |
128 | 128 |
SmartGraph::Edge edge = from.addEdge(fnv[i], fnv[j]); |
129 | 129 |
fem[edge] = i * i + j * j; |
130 | 130 |
fam[from.direct(edge, true)] = i + j * j; |
131 | 131 |
fam[from.direct(edge, false)] = i * i + j; |
132 | 132 |
if (i == 0 && j == 0) fa = from.direct(edge, true); |
133 | 133 |
if (i == 0 && j == 0) fe = edge; |
... | ... |
@@ -171,45 +171,45 @@ |
171 | 171 |
check(fam[it] == tam[ar[it]], "Wrong copy."); |
172 | 172 |
check(nr[from.source(it)] == to.source(ar[it]), "Wrong copy."); |
173 | 173 |
check(nr[from.target(it)] == to.target(ar[it]), "Wrong copy."); |
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
for (SmartGraph::EdgeIt it(from); it != INVALID; ++it) { |
177 | 177 |
check(ecr[er[it]] == it, "Wrong copy."); |
178 | 178 |
check(fem[it] == tem[er[it]], "Wrong copy."); |
179 | 179 |
check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]), |
180 | 180 |
"Wrong copy."); |
181 | 181 |
check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]), |
182 | 182 |
"Wrong copy."); |
183 | 183 |
check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])), |
184 | 184 |
"Wrong copy."); |
185 | 185 |
} |
186 | 186 |
|
187 | 187 |
for (ListGraph::NodeIt it(to); it != INVALID; ++it) { |
188 | 188 |
check(nr[ncr[it]] == it, "Wrong copy."); |
189 | 189 |
} |
190 | 190 |
|
191 | 191 |
for (ListGraph::ArcIt it(to); it != INVALID; ++it) { |
192 | 192 |
check(ar[acr[it]] == it, "Wrong copy."); |
193 | 193 |
} |
194 | 194 |
for (ListGraph::EdgeIt it(to); it != INVALID; ++it) { |
195 | 195 |
check(er[ecr[it]] == it, "Wrong copy."); |
196 | 196 |
} |
197 | 197 |
check(tn == nr[fn], "Wrong copy."); |
198 | 198 |
check(ta == ar[fa], "Wrong copy."); |
199 | 199 |
check(te == er[fe], "Wrong copy."); |
200 | 200 |
|
201 | 201 |
// Test repeated copy |
202 | 202 |
graphCopy(from, to).run(); |
203 |
|
|
203 |
|
|
204 | 204 |
check(countNodes(from) == countNodes(to), "Wrong copy."); |
205 | 205 |
check(countEdges(from) == countEdges(to), "Wrong copy."); |
206 | 206 |
check(countArcs(from) == countArcs(to), "Wrong copy."); |
207 | 207 |
} |
208 | 208 |
|
209 | 209 |
|
210 | 210 |
int main() { |
211 | 211 |
digraph_copy_test(); |
212 | 212 |
graph_copy_test(); |
213 | 213 |
|
214 | 214 |
return 0; |
215 | 215 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <iostream> |
20 | 20 |
#include <fstream> |
21 | 21 |
#include <string> |
22 | 22 |
#include <vector> |
23 | 23 |
|
24 | 24 |
#include <lemon/concept_check.h> |
25 | 25 |
#include <lemon/concepts/heap.h> |
26 | 26 |
|
27 | 27 |
#include <lemon/smart_graph.h> |
28 | 28 |
#include <lemon/lgf_reader.h> |
29 | 29 |
#include <lemon/dijkstra.h> |
30 | 30 |
#include <lemon/maps.h> |
31 | 31 |
|
32 | 32 |
#include <lemon/bin_heap.h> |
33 | 33 |
#include <lemon/quad_heap.h> |
34 | 34 |
#include <lemon/dheap.h> |
35 | 35 |
#include <lemon/fib_heap.h> |
36 | 36 |
#include <lemon/pairing_heap.h> |
37 | 37 |
#include <lemon/radix_heap.h> |
... | ... |
@@ -34,136 +34,136 @@ |
34 | 34 |
"@attributes\n" |
35 | 35 |
"source 0\n" |
36 | 36 |
"target 1\n"; |
37 | 37 |
|
38 | 38 |
char test_lgf_nomap[] = |
39 | 39 |
"@nodes\n" |
40 | 40 |
"label\n" |
41 | 41 |
"0\n" |
42 | 42 |
"1\n" |
43 | 43 |
"@arcs\n" |
44 | 44 |
" -\n" |
45 | 45 |
"0 1\n"; |
46 | 46 |
|
47 | 47 |
char test_lgf_bad1[] = |
48 | 48 |
"@nodes\n" |
49 | 49 |
"label\n" |
50 | 50 |
"0\n" |
51 | 51 |
"1\n" |
52 | 52 |
"@arcs\n" |
53 | 53 |
" - another\n" |
54 | 54 |
"0 1\n"; |
55 | 55 |
|
56 | 56 |
char test_lgf_bad2[] = |
57 | 57 |
"@nodes\n" |
58 | 58 |
"label\n" |
59 | 59 |
"0\n" |
60 | 60 |
"1\n" |
61 | 61 |
"@arcs\n" |
62 | 62 |
" label -\n" |
63 | 63 |
"0 1\n"; |
64 | 64 |
|
65 | 65 |
|
66 |
int main() |
|
66 |
int main() |
|
67 | 67 |
{ |
68 | 68 |
{ |
69 |
ListDigraph d; |
|
69 |
ListDigraph d; |
|
70 | 70 |
ListDigraph::Node s,t; |
71 | 71 |
ListDigraph::ArcMap<int> label(d); |
72 | 72 |
std::istringstream input(test_lgf); |
73 | 73 |
digraphReader(d, input). |
74 | 74 |
node("source", s). |
75 | 75 |
node("target", t). |
76 | 76 |
arcMap("label", label). |
77 | 77 |
run(); |
78 | 78 |
check(countNodes(d) == 2,"There should be 2 nodes"); |
79 | 79 |
check(countArcs(d) == 2,"There should be 2 arcs"); |
80 | 80 |
} |
81 | 81 |
{ |
82 | 82 |
ListGraph g; |
83 | 83 |
ListGraph::Node s,t; |
84 | 84 |
ListGraph::EdgeMap<int> label(g); |
85 | 85 |
std::istringstream input(test_lgf); |
86 | 86 |
graphReader(g, input). |
87 | 87 |
node("source", s). |
88 | 88 |
node("target", t). |
89 | 89 |
edgeMap("label", label). |
90 | 90 |
run(); |
91 | 91 |
check(countNodes(g) == 2,"There should be 2 nodes"); |
92 | 92 |
check(countEdges(g) == 2,"There should be 2 arcs"); |
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
{ |
96 |
ListDigraph d; |
|
96 |
ListDigraph d; |
|
97 | 97 |
std::istringstream input(test_lgf_nomap); |
98 | 98 |
digraphReader(d, input). |
99 | 99 |
run(); |
100 | 100 |
check(countNodes(d) == 2,"There should be 2 nodes"); |
101 | 101 |
check(countArcs(d) == 1,"There should be 1 arc"); |
102 | 102 |
} |
103 | 103 |
{ |
104 | 104 |
ListGraph g; |
105 | 105 |
std::istringstream input(test_lgf_nomap); |
106 | 106 |
graphReader(g, input). |
107 | 107 |
run(); |
108 | 108 |
check(countNodes(g) == 2,"There should be 2 nodes"); |
109 | 109 |
check(countEdges(g) == 1,"There should be 1 edge"); |
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
{ |
113 |
ListDigraph d; |
|
113 |
ListDigraph d; |
|
114 | 114 |
std::istringstream input(test_lgf_bad1); |
115 | 115 |
bool ok=false; |
116 | 116 |
try { |
117 | 117 |
digraphReader(d, input). |
118 | 118 |
run(); |
119 | 119 |
} |
120 |
catch (FormatError& error) |
|
120 |
catch (FormatError& error) |
|
121 | 121 |
{ |
122 | 122 |
ok = true; |
123 | 123 |
} |
124 | 124 |
check(ok,"FormatError exception should have occured"); |
125 | 125 |
} |
126 | 126 |
{ |
127 | 127 |
ListGraph g; |
128 | 128 |
std::istringstream input(test_lgf_bad1); |
129 | 129 |
bool ok=false; |
130 | 130 |
try { |
131 | 131 |
graphReader(g, input). |
132 | 132 |
run(); |
133 | 133 |
} |
134 | 134 |
catch (FormatError& error) |
135 | 135 |
{ |
136 | 136 |
ok = true; |
137 | 137 |
} |
138 | 138 |
check(ok,"FormatError exception should have occured"); |
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
{ |
142 |
ListDigraph d; |
|
142 |
ListDigraph d; |
|
143 | 143 |
std::istringstream input(test_lgf_bad2); |
144 | 144 |
bool ok=false; |
145 | 145 |
try { |
146 | 146 |
digraphReader(d, input). |
147 | 147 |
run(); |
148 | 148 |
} |
149 | 149 |
catch (FormatError& error) |
150 | 150 |
{ |
151 | 151 |
ok = true; |
152 | 152 |
} |
153 | 153 |
check(ok,"FormatError exception should have occured"); |
154 | 154 |
} |
155 | 155 |
{ |
156 | 156 |
ListGraph g; |
157 | 157 |
std::istringstream input(test_lgf_bad2); |
158 | 158 |
bool ok=false; |
159 | 159 |
try { |
160 | 160 |
graphReader(g, input). |
161 | 161 |
run(); |
162 | 162 |
} |
163 | 163 |
catch (FormatError& error) |
164 | 164 |
{ |
165 | 165 |
ok = true; |
166 | 166 |
} |
167 | 167 |
check(ok,"FormatError exception should have occured"); |
168 | 168 |
} |
169 | 169 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <deque> |
20 | 20 |
#include <set> |
21 | 21 |
|
22 | 22 |
#include <lemon/concept_check.h> |
23 | 23 |
#include <lemon/concepts/maps.h> |
24 | 24 |
#include <lemon/maps.h> |
25 | 25 |
#include <lemon/list_graph.h> |
26 | 26 |
#include <lemon/smart_graph.h> |
27 | 27 |
#include <lemon/adaptors.h> |
28 | 28 |
#include <lemon/dfs.h> |
29 | 29 |
#include <algorithm> |
30 | 30 |
|
31 | 31 |
#include "test_tools.h" |
32 | 32 |
|
33 | 33 |
using namespace lemon; |
34 | 34 |
using namespace lemon::concepts; |
35 | 35 |
|
36 | 36 |
struct A {}; |
37 | 37 |
inline bool operator<(A, A) { return true; } |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2011 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <iostream> |
20 | 20 |
|
21 | 21 |
#include "test_tools.h" |
22 | 22 |
#include <lemon/smart_graph.h> |
23 | 23 |
#include <lemon/preflow.h> |
24 | 24 |
#include <lemon/concepts/digraph.h> |
25 | 25 |
#include <lemon/concepts/maps.h> |
26 | 26 |
#include <lemon/lgf_reader.h> |
27 | 27 |
#include <lemon/elevator.h> |
28 | 28 |
|
29 | 29 |
using namespace lemon; |
30 | 30 |
|
31 | 31 |
char test_lgf[] = |
32 | 32 |
"@nodes\n" |
33 | 33 |
"label\n" |
34 | 34 |
"0\n" |
35 | 35 |
"1\n" |
36 | 36 |
"2\n" |
37 | 37 |
"3\n" |
... | ... |
@@ -130,65 +130,65 @@ |
130 | 130 |
for(SmartDigraph::ArcIt e(g); e!=INVALID; ++e) { |
131 | 131 |
if (cut[g.source(e)] && !cut[g.target(e)]) c+=cap[e]; |
132 | 132 |
} |
133 | 133 |
return c; |
134 | 134 |
} |
135 | 135 |
|
136 | 136 |
bool checkFlow(const SmartDigraph& g, |
137 | 137 |
const SmartDigraph::ArcMap<int>& flow, |
138 | 138 |
const SmartDigraph::ArcMap<int>& cap, |
139 | 139 |
SmartDigraph::Node s, SmartDigraph::Node t) { |
140 | 140 |
|
141 | 141 |
for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) { |
142 | 142 |
if (flow[e] < 0 || flow[e] > cap[e]) return false; |
143 | 143 |
} |
144 | 144 |
|
145 | 145 |
for (SmartDigraph::NodeIt n(g); n != INVALID; ++n) { |
146 | 146 |
if (n == s || n == t) continue; |
147 | 147 |
int sum = 0; |
148 | 148 |
for (SmartDigraph::OutArcIt e(g, n); e != INVALID; ++e) { |
149 | 149 |
sum += flow[e]; |
150 | 150 |
} |
151 | 151 |
for (SmartDigraph::InArcIt e(g, n); e != INVALID; ++e) { |
152 | 152 |
sum -= flow[e]; |
153 | 153 |
} |
154 | 154 |
if (sum != 0) return false; |
155 | 155 |
} |
156 | 156 |
return true; |
157 | 157 |
} |
158 | 158 |
|
159 | 159 |
void initFlowTest() |
160 | 160 |
{ |
161 | 161 |
DIGRAPH_TYPEDEFS(SmartDigraph); |
162 |
|
|
162 |
|
|
163 | 163 |
SmartDigraph g; |
164 | 164 |
SmartDigraph::ArcMap<int> cap(g),iflow(g); |
165 | 165 |
Node s=g.addNode(); Node t=g.addNode(); |
166 | 166 |
Node n1=g.addNode(); Node n2=g.addNode(); |
167 | 167 |
Arc a; |
168 | 168 |
a=g.addArc(s,n1); cap[a]=20; iflow[a]=20; |
169 | 169 |
a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0; |
170 | 170 |
a=g.addArc(n2,t); cap[a]=20; iflow[a]=0; |
171 | 171 |
|
172 | 172 |
Preflow<SmartDigraph> pre(g,cap,s,t); |
173 | 173 |
pre.init(iflow); |
174 | 174 |
pre.startFirstPhase(); |
175 | 175 |
check(pre.flowValue() == 10, "The incorrect max flow value."); |
176 | 176 |
check(pre.minCut(s), "Wrong min cut (Node s)."); |
177 | 177 |
check(pre.minCut(n1), "Wrong min cut (Node n1)."); |
178 | 178 |
check(!pre.minCut(n2), "Wrong min cut (Node n2)."); |
179 | 179 |
check(!pre.minCut(t), "Wrong min cut (Node t)."); |
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
|
183 | 183 |
int main() { |
184 | 184 |
|
185 | 185 |
typedef SmartDigraph Digraph; |
186 | 186 |
|
187 | 187 |
typedef Digraph::Node Node; |
188 | 188 |
typedef Digraph::NodeIt NodeIt; |
189 | 189 |
typedef Digraph::ArcIt ArcIt; |
190 | 190 |
typedef Digraph::ArcMap<int> CapMap; |
191 | 191 |
typedef Digraph::ArcMap<int> FlowMap; |
192 | 192 |
typedef Digraph::NodeMap<bool> CutMap; |
193 | 193 |
|
194 | 194 |
typedef Preflow<Digraph, CapMap> PType; |
... | ... |
@@ -242,35 +242,35 @@ |
242 | 242 |
preflow_test.minCutMap(min_cut2); |
243 | 243 |
min_cut_value=cutValue(g,min_cut2,cap); |
244 | 244 |
|
245 | 245 |
check(preflow_test.flowValue() == min_cut_value && |
246 | 246 |
min_cut_value == 2*flow_value, |
247 | 247 |
"The max flow value or the three min cut values were not doubled"); |
248 | 248 |
|
249 | 249 |
|
250 | 250 |
preflow_test.flowMap(flow); |
251 | 251 |
|
252 | 252 |
NodeIt tmp1(g,s); |
253 | 253 |
++tmp1; |
254 | 254 |
if ( tmp1 != INVALID ) s=tmp1; |
255 | 255 |
|
256 | 256 |
NodeIt tmp2(g,t); |
257 | 257 |
++tmp2; |
258 | 258 |
if ( tmp2 != INVALID ) t=tmp2; |
259 | 259 |
|
260 | 260 |
preflow_test.source(s); |
261 | 261 |
preflow_test.target(t); |
262 | 262 |
|
263 | 263 |
preflow_test.run(); |
264 | 264 |
|
265 | 265 |
CutMap min_cut3(g); |
266 | 266 |
preflow_test.minCutMap(min_cut3); |
267 | 267 |
min_cut_value=cutValue(g,min_cut3,cap); |
268 | 268 |
|
269 | 269 |
|
270 | 270 |
check(preflow_test.flowValue() == min_cut_value, |
271 | 271 |
"The max flow value or the three min cut values are incorrect."); |
272 | 272 |
|
273 | 273 |
initFlowTest(); |
274 |
|
|
274 |
|
|
275 | 275 |
return 0; |
276 | 276 |
} |
0 comments (0 inline)