Major improvements in NetworkSimplex.
Main changes:
- Use -potenital[] instead of potential[] to conform to the usual
terminology.
- Use function parameter instead of #define commands to select pivot rule.
- Use much faster implementation for the candidate list pivot rule.
It is about 5-20 times faster now.
- Add a new pivot rule called "Limited Search" that is a modified
version of "Block Search". It is about 25 percent faster on rather
sparse graphs.
- By default "Limited Search" is used for sparse graphs and
"Block Search" is used otherwise. This combined method is the most
efficient on every input class.
- Change the name of private members to start with "_".
- Change the name of function parameters not to start with "_".
- Remove unnecessary documentation for private members.
- Many doc improvements.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
19 #ifndef LEMON_HAO_ORLIN_H
20 #define LEMON_HAO_ORLIN_H
24 #include <ext/hash_set>
27 #include <lemon/maps.h>
28 #include <lemon/graph_utils.h>
29 #include <lemon/graph_adaptor.h>
30 #include <lemon/iterable_maps.h>
34 /// \brief Implementation of the Hao-Orlin algorithm.
36 /// Implementation of the Hao-Orlin algorithm class for testing network
43 /// \brief %Hao-Orlin algorithm to find a minimum cut in directed graphs.
45 /// Hao-Orlin calculates a minimum cut in a directed graph
46 /// \f$D=(V,A)\f$. It takes a fixed node \f$ source \in V \f$ and
47 /// consists of two phases: in the first phase it determines a
48 /// minimum cut with \f$ source \f$ on the source-side (i.e. a set
49 /// \f$ X\subsetneq V \f$ with \f$ source \in X \f$ and minimal
50 /// out-degree) and in the second phase it determines a minimum cut
51 /// with \f$ source \f$ on the sink-side (i.e. a set
52 /// \f$ X\subsetneq V \f$ with \f$ source \notin X \f$ and minimal
53 /// out-degree). Obviously, the smaller of these two cuts will be a
54 /// minimum cut of \f$ D \f$. The algorithm is a modified
55 /// push-relabel preflow algorithm and our implementation calculates
56 /// the minimum cut in \f$ O(n^2\sqrt{m}) \f$ time (we use the
57 /// highest-label rule), or in \f$O(nm)\f$ for unit capacities. The
58 /// purpose of such algorithm is testing network reliability. For an
59 /// undirected graph you can run just the first phase of the
60 /// algorithm or you can use the algorithm of Nagamochi and Ibaraki
61 /// which solves the undirected problem in
62 /// \f$ O(nm + n^2 \log(n)) \f$ time: it is implemented in the
63 /// NagamochiIbaraki algorithm class.
65 /// \param _Graph is the graph type of the algorithm.
66 /// \param _CapacityMap is an edge map of capacities which should
67 /// be any numreric type. The default type is _Graph::EdgeMap<int>.
68 /// \param _Tolerance is the handler of the inexact computation. The
69 /// default type for this is Tolerance<typename CapacityMap::Value>.
71 /// \author Attila Bernath and Balazs Dezso
73 template <typename _Graph, typename _CapacityMap, typename _Tolerance>
75 template <typename _Graph,
76 typename _CapacityMap = typename _Graph::template EdgeMap<int>,
77 typename _Tolerance = Tolerance<typename _CapacityMap::Value> >
83 typedef _CapacityMap CapacityMap;
84 typedef _Tolerance Tolerance;
86 typedef typename CapacityMap::Value Value;
88 GRAPH_TYPEDEFS(typename Graph);
91 const CapacityMap* _capacity;
93 typedef typename Graph::template EdgeMap<Value> FlowMap;
100 // Bucketing structure
101 std::vector<Node> _first, _last;
102 typename Graph::template NodeMap<Node>* _next;
103 typename Graph::template NodeMap<Node>* _prev;
104 typename Graph::template NodeMap<bool>* _active;
105 typename Graph::template NodeMap<int>* _bucket;
107 std::vector<bool> _dormant;
109 std::list<std::list<int> > _sets;
110 std::list<int>::iterator _highest;
112 typedef typename Graph::template NodeMap<Value> ExcessMap;
115 typedef typename Graph::template NodeMap<bool> SourceSetMap;
116 SourceSetMap* _source_set;
120 typedef typename Graph::template NodeMap<bool> MinCutMap;
121 MinCutMap* _min_cut_map;
123 Tolerance _tolerance;
127 /// \brief Constructor
129 /// Constructor of the algorithm class.
130 HaoOrlin(const Graph& graph, const CapacityMap& capacity,
131 const Tolerance& tolerance = Tolerance()) :
132 _graph(graph), _capacity(&capacity), _flow(0), _source(),
133 _node_num(), _first(), _last(), _next(0), _prev(0),
134 _active(0), _bucket(0), _dormant(), _sets(), _highest(),
135 _excess(0), _source_set(0), _min_cut(), _min_cut_map(0),
136 _tolerance(tolerance) {}
167 void activate(const Node& i) {
168 _active->set(i, true);
170 int bucket = (*_bucket)[i];
172 if ((*_prev)[i] == INVALID || (*_active)[(*_prev)[i]]) return;
174 _next->set((*_prev)[i], (*_next)[i]);
175 if ((*_next)[i] != INVALID) {
176 _prev->set((*_next)[i], (*_prev)[i]);
178 _last[bucket] = (*_prev)[i];
181 _next->set(i, _first[bucket]);
182 _prev->set(_first[bucket], i);
183 _prev->set(i, INVALID);
187 void deactivate(const Node& i) {
188 _active->set(i, false);
189 int bucket = (*_bucket)[i];
191 if ((*_next)[i] == INVALID || !(*_active)[(*_next)[i]]) return;
194 _prev->set((*_next)[i], (*_prev)[i]);
195 if ((*_prev)[i] != INVALID) {
196 _next->set((*_prev)[i], (*_next)[i]);
198 _first[bucket] = (*_next)[i];
201 _prev->set(i, _last[bucket]);
202 _next->set(_last[bucket], i);
203 _next->set(i, INVALID);
207 void addItem(const Node& i, int bucket) {
208 (*_bucket)[i] = bucket;
209 if (_last[bucket] != INVALID) {
210 _prev->set(i, _last[bucket]);
211 _next->set(_last[bucket], i);
212 _next->set(i, INVALID);
215 _prev->set(i, INVALID);
217 _next->set(i, INVALID);
222 void findMinCutOut() {
224 for (NodeIt n(_graph); n != INVALID; ++n) {
228 for (EdgeIt e(_graph); e != INVALID; ++e) {
235 typename Graph::template NodeMap<bool> reached(_graph, false);
237 reached.set(_source, true);
239 bool first_set = true;
241 for (NodeIt t(_graph); t != INVALID; ++t) {
242 if (reached[t]) continue;
243 _sets.push_front(std::list<int>());
244 _sets.front().push_front(bucket_num);
245 _dormant[bucket_num] = !first_set;
247 _bucket->set(t, bucket_num);
248 _first[bucket_num] = _last[bucket_num] = t;
249 _next->set(t, INVALID);
250 _prev->set(t, INVALID);
254 std::vector<Node> queue;
256 reached.set(t, true);
258 while (!queue.empty()) {
259 _sets.front().push_front(bucket_num);
260 _dormant[bucket_num] = !first_set;
261 _first[bucket_num] = _last[bucket_num] = INVALID;
263 std::vector<Node> nqueue;
264 for (int i = 0; i < int(queue.size()); ++i) {
266 for (InEdgeIt e(_graph, n); e != INVALID; ++e) {
267 Node u = _graph.source(e);
268 if (!reached[u] && _tolerance.positive((*_capacity)[e])) {
269 reached.set(u, true);
270 addItem(u, bucket_num);
278 _sets.front().pop_front();
283 _bucket->set(_source, 0);
286 _source_set->set(_source, true);
288 Node target = _last[_sets.back().back()];
290 for (OutEdgeIt e(_graph, _source); e != INVALID; ++e) {
291 if (_tolerance.positive((*_capacity)[e])) {
292 Node u = _graph.target(e);
293 _flow->set(e, (*_capacity)[e]);
294 _excess->set(u, (*_excess)[u] + (*_capacity)[e]);
295 if (!(*_active)[u] && u != _source) {
300 if ((*_active)[target]) {
304 _highest = _sets.back().begin();
305 while (_highest != _sets.back().end() &&
306 !(*_active)[_first[*_highest]]) {
313 while (_highest != _sets.back().end()) {
314 Node n = _first[*_highest];
315 Value excess = (*_excess)[n];
316 int next_bucket = _node_num;
319 if (++std::list<int>::iterator(_highest) == _sets.back().end()) {
322 under_bucket = *(++std::list<int>::iterator(_highest));
325 for (OutEdgeIt e(_graph, n); e != INVALID; ++e) {
326 Node v = _graph.target(e);
327 if (_dormant[(*_bucket)[v]]) continue;
328 Value rem = (*_capacity)[e] - (*_flow)[e];
329 if (!_tolerance.positive(rem)) continue;
330 if ((*_bucket)[v] == under_bucket) {
331 if (!(*_active)[v] && v != target) {
334 if (!_tolerance.less(rem, excess)) {
335 _flow->set(e, (*_flow)[e] + excess);
336 _excess->set(v, (*_excess)[v] + excess);
341 _excess->set(v, (*_excess)[v] + rem);
342 _flow->set(e, (*_capacity)[e]);
344 } else if (next_bucket > (*_bucket)[v]) {
345 next_bucket = (*_bucket)[v];
349 for (InEdgeIt e(_graph, n); e != INVALID; ++e) {
350 Node v = _graph.source(e);
351 if (_dormant[(*_bucket)[v]]) continue;
352 Value rem = (*_flow)[e];
353 if (!_tolerance.positive(rem)) continue;
354 if ((*_bucket)[v] == under_bucket) {
355 if (!(*_active)[v] && v != target) {
358 if (!_tolerance.less(rem, excess)) {
359 _flow->set(e, (*_flow)[e] - excess);
360 _excess->set(v, (*_excess)[v] + excess);
365 _excess->set(v, (*_excess)[v] + rem);
368 } else if (next_bucket > (*_bucket)[v]) {
369 next_bucket = (*_bucket)[v];
375 _excess->set(n, excess);
378 if ((*_next)[n] == INVALID) {
379 typename std::list<std::list<int> >::iterator new_set =
380 _sets.insert(--_sets.end(), std::list<int>());
381 new_set->splice(new_set->end(), _sets.back(),
382 _sets.back().begin(), ++_highest);
383 for (std::list<int>::iterator it = new_set->begin();
384 it != new_set->end(); ++it) {
385 _dormant[*it] = true;
387 while (_highest != _sets.back().end() &&
388 !(*_active)[_first[*_highest]]) {
391 } else if (next_bucket == _node_num) {
392 _first[(*_bucket)[n]] = (*_next)[n];
393 _prev->set((*_next)[n], INVALID);
395 std::list<std::list<int> >::iterator new_set =
396 _sets.insert(--_sets.end(), std::list<int>());
398 new_set->push_front(bucket_num);
399 _bucket->set(n, bucket_num);
400 _first[bucket_num] = _last[bucket_num] = n;
401 _next->set(n, INVALID);
402 _prev->set(n, INVALID);
403 _dormant[bucket_num] = true;
406 while (_highest != _sets.back().end() &&
407 !(*_active)[_first[*_highest]]) {
411 _first[*_highest] = (*_next)[n];
412 _prev->set((*_next)[n], INVALID);
414 while (next_bucket != *_highest) {
418 if (_highest == _sets.back().begin()) {
419 _sets.back().push_front(bucket_num);
420 _dormant[bucket_num] = false;
421 _first[bucket_num] = _last[bucket_num] = INVALID;
426 _bucket->set(n, *_highest);
427 _next->set(n, _first[*_highest]);
428 if (_first[*_highest] != INVALID) {
429 _prev->set(_first[*_highest], n);
431 _last[*_highest] = n;
433 _first[*_highest] = n;
438 if (!(*_active)[_first[*_highest]]) {
440 if (_highest != _sets.back().end() &&
441 !(*_active)[_first[*_highest]]) {
442 _highest = _sets.back().end();
448 if ((*_excess)[target] < _min_cut) {
449 _min_cut = (*_excess)[target];
450 for (NodeIt i(_graph); i != INVALID; ++i) {
451 _min_cut_map->set(i, true);
453 for (std::list<int>::iterator it = _sets.back().begin();
454 it != _sets.back().end(); ++it) {
455 Node n = _first[*it];
456 while (n != INVALID) {
457 _min_cut_map->set(n, false);
465 if ((*_prev)[target] != INVALID) {
466 _last[(*_bucket)[target]] = (*_prev)[target];
467 _next->set((*_prev)[target], INVALID);
468 new_target = (*_prev)[target];
470 _sets.back().pop_back();
471 if (_sets.back().empty()) {
475 for (std::list<int>::iterator it = _sets.back().begin();
476 it != _sets.back().end(); ++it) {
477 _dormant[*it] = false;
480 new_target = _last[_sets.back().back()];
483 _bucket->set(target, 0);
485 _source_set->set(target, true);
486 for (OutEdgeIt e(_graph, target); e != INVALID; ++e) {
487 Value rem = (*_capacity)[e] - (*_flow)[e];
488 if (!_tolerance.positive(rem)) continue;
489 Node v = _graph.target(e);
490 if (!(*_active)[v] && !(*_source_set)[v]) {
493 _excess->set(v, (*_excess)[v] + rem);
494 _flow->set(e, (*_capacity)[e]);
497 for (InEdgeIt e(_graph, target); e != INVALID; ++e) {
498 Value rem = (*_flow)[e];
499 if (!_tolerance.positive(rem)) continue;
500 Node v = _graph.source(e);
501 if (!(*_active)[v] && !(*_source_set)[v]) {
504 _excess->set(v, (*_excess)[v] + rem);
509 if ((*_active)[target]) {
513 _highest = _sets.back().begin();
514 while (_highest != _sets.back().end() &&
515 !(*_active)[_first[*_highest]]) {
522 void findMinCutIn() {
524 for (NodeIt n(_graph); n != INVALID; ++n) {
528 for (EdgeIt e(_graph); e != INVALID; ++e) {
535 typename Graph::template NodeMap<bool> reached(_graph, false);
537 reached.set(_source, true);
539 bool first_set = true;
541 for (NodeIt t(_graph); t != INVALID; ++t) {
542 if (reached[t]) continue;
543 _sets.push_front(std::list<int>());
544 _sets.front().push_front(bucket_num);
545 _dormant[bucket_num] = !first_set;
547 _bucket->set(t, bucket_num);
548 _first[bucket_num] = _last[bucket_num] = t;
549 _next->set(t, INVALID);
550 _prev->set(t, INVALID);
554 std::vector<Node> queue;
556 reached.set(t, true);
558 while (!queue.empty()) {
559 _sets.front().push_front(bucket_num);
560 _dormant[bucket_num] = !first_set;
561 _first[bucket_num] = _last[bucket_num] = INVALID;
563 std::vector<Node> nqueue;
564 for (int i = 0; i < int(queue.size()); ++i) {
566 for (OutEdgeIt e(_graph, n); e != INVALID; ++e) {
567 Node u = _graph.target(e);
568 if (!reached[u] && _tolerance.positive((*_capacity)[e])) {
569 reached.set(u, true);
570 addItem(u, bucket_num);
578 _sets.front().pop_front();
583 _bucket->set(_source, 0);
586 _source_set->set(_source, true);
588 Node target = _last[_sets.back().back()];
590 for (InEdgeIt e(_graph, _source); e != INVALID; ++e) {
591 if (_tolerance.positive((*_capacity)[e])) {
592 Node u = _graph.source(e);
593 _flow->set(e, (*_capacity)[e]);
594 _excess->set(u, (*_excess)[u] + (*_capacity)[e]);
595 if (!(*_active)[u] && u != _source) {
600 if ((*_active)[target]) {
604 _highest = _sets.back().begin();
605 while (_highest != _sets.back().end() &&
606 !(*_active)[_first[*_highest]]) {
613 while (_highest != _sets.back().end()) {
614 Node n = _first[*_highest];
615 Value excess = (*_excess)[n];
616 int next_bucket = _node_num;
619 if (++std::list<int>::iterator(_highest) == _sets.back().end()) {
622 under_bucket = *(++std::list<int>::iterator(_highest));
625 for (InEdgeIt e(_graph, n); e != INVALID; ++e) {
626 Node v = _graph.source(e);
627 if (_dormant[(*_bucket)[v]]) continue;
628 Value rem = (*_capacity)[e] - (*_flow)[e];
629 if (!_tolerance.positive(rem)) continue;
630 if ((*_bucket)[v] == under_bucket) {
631 if (!(*_active)[v] && v != target) {
634 if (!_tolerance.less(rem, excess)) {
635 _flow->set(e, (*_flow)[e] + excess);
636 _excess->set(v, (*_excess)[v] + excess);
641 _excess->set(v, (*_excess)[v] + rem);
642 _flow->set(e, (*_capacity)[e]);
644 } else if (next_bucket > (*_bucket)[v]) {
645 next_bucket = (*_bucket)[v];
649 for (OutEdgeIt e(_graph, n); e != INVALID; ++e) {
650 Node v = _graph.target(e);
651 if (_dormant[(*_bucket)[v]]) continue;
652 Value rem = (*_flow)[e];
653 if (!_tolerance.positive(rem)) continue;
654 if ((*_bucket)[v] == under_bucket) {
655 if (!(*_active)[v] && v != target) {
658 if (!_tolerance.less(rem, excess)) {
659 _flow->set(e, (*_flow)[e] - excess);
660 _excess->set(v, (*_excess)[v] + excess);
665 _excess->set(v, (*_excess)[v] + rem);
668 } else if (next_bucket > (*_bucket)[v]) {
669 next_bucket = (*_bucket)[v];
675 _excess->set(n, excess);
678 if ((*_next)[n] == INVALID) {
679 typename std::list<std::list<int> >::iterator new_set =
680 _sets.insert(--_sets.end(), std::list<int>());
681 new_set->splice(new_set->end(), _sets.back(),
682 _sets.back().begin(), ++_highest);
683 for (std::list<int>::iterator it = new_set->begin();
684 it != new_set->end(); ++it) {
685 _dormant[*it] = true;
687 while (_highest != _sets.back().end() &&
688 !(*_active)[_first[*_highest]]) {
691 } else if (next_bucket == _node_num) {
692 _first[(*_bucket)[n]] = (*_next)[n];
693 _prev->set((*_next)[n], INVALID);
695 std::list<std::list<int> >::iterator new_set =
696 _sets.insert(--_sets.end(), std::list<int>());
698 new_set->push_front(bucket_num);
699 _bucket->set(n, bucket_num);
700 _first[bucket_num] = _last[bucket_num] = n;
701 _next->set(n, INVALID);
702 _prev->set(n, INVALID);
703 _dormant[bucket_num] = true;
706 while (_highest != _sets.back().end() &&
707 !(*_active)[_first[*_highest]]) {
711 _first[*_highest] = (*_next)[n];
712 _prev->set((*_next)[n], INVALID);
714 while (next_bucket != *_highest) {
717 if (_highest == _sets.back().begin()) {
718 _sets.back().push_front(bucket_num);
719 _dormant[bucket_num] = false;
720 _first[bucket_num] = _last[bucket_num] = INVALID;
725 _bucket->set(n, *_highest);
726 _next->set(n, _first[*_highest]);
727 if (_first[*_highest] != INVALID) {
728 _prev->set(_first[*_highest], n);
730 _last[*_highest] = n;
732 _first[*_highest] = n;
737 if (!(*_active)[_first[*_highest]]) {
739 if (_highest != _sets.back().end() &&
740 !(*_active)[_first[*_highest]]) {
741 _highest = _sets.back().end();
747 if ((*_excess)[target] < _min_cut) {
748 _min_cut = (*_excess)[target];
749 for (NodeIt i(_graph); i != INVALID; ++i) {
750 _min_cut_map->set(i, false);
752 for (std::list<int>::iterator it = _sets.back().begin();
753 it != _sets.back().end(); ++it) {
754 Node n = _first[*it];
755 while (n != INVALID) {
756 _min_cut_map->set(n, true);
764 if ((*_prev)[target] != INVALID) {
765 _last[(*_bucket)[target]] = (*_prev)[target];
766 _next->set((*_prev)[target], INVALID);
767 new_target = (*_prev)[target];
769 _sets.back().pop_back();
770 if (_sets.back().empty()) {
774 for (std::list<int>::iterator it = _sets.back().begin();
775 it != _sets.back().end(); ++it) {
776 _dormant[*it] = false;
779 new_target = _last[_sets.back().back()];
782 _bucket->set(target, 0);
784 _source_set->set(target, true);
785 for (InEdgeIt e(_graph, target); e != INVALID; ++e) {
786 Value rem = (*_capacity)[e] - (*_flow)[e];
787 if (!_tolerance.positive(rem)) continue;
788 Node v = _graph.source(e);
789 if (!(*_active)[v] && !(*_source_set)[v]) {
792 _excess->set(v, (*_excess)[v] + rem);
793 _flow->set(e, (*_capacity)[e]);
796 for (OutEdgeIt e(_graph, target); e != INVALID; ++e) {
797 Value rem = (*_flow)[e];
798 if (!_tolerance.positive(rem)) continue;
799 Node v = _graph.target(e);
800 if (!(*_active)[v] && !(*_source_set)[v]) {
803 _excess->set(v, (*_excess)[v] + rem);
808 if ((*_active)[target]) {
812 _highest = _sets.back().begin();
813 while (_highest != _sets.back().end() &&
814 !(*_active)[_first[*_highest]]) {
823 /// \name Execution control
824 /// The simplest way to execute the algorithm is to use
825 /// one of the member functions called \c run(...).
827 /// If you need more control on the execution,
828 /// first you must call \ref init(), then the \ref calculateIn() or
829 /// \ref calculateIn() functions.
833 /// \brief Initializes the internal data structures.
835 /// Initializes the internal data structures. It creates
836 /// the maps, residual graph adaptors and some bucket structures
837 /// for the algorithm.
839 init(NodeIt(_graph));
842 /// \brief Initializes the internal data structures.
844 /// Initializes the internal data structures. It creates
845 /// the maps, residual graph adaptor and some bucket structures
846 /// for the algorithm. Node \c source is used as the push-relabel
847 /// algorithm's source.
848 void init(const Node& source) {
851 _node_num = countNodes(_graph);
853 _first.resize(_node_num);
854 _last.resize(_node_num);
856 _dormant.resize(_node_num);
859 _flow = new FlowMap(_graph);
862 _next = new typename Graph::template NodeMap<Node>(_graph);
865 _prev = new typename Graph::template NodeMap<Node>(_graph);
868 _active = new typename Graph::template NodeMap<bool>(_graph);
871 _bucket = new typename Graph::template NodeMap<int>(_graph);
874 _excess = new ExcessMap(_graph);
877 _source_set = new SourceSetMap(_graph);
880 _min_cut_map = new MinCutMap(_graph);
883 _min_cut = std::numeric_limits<Value>::max();
887 /// \brief Calculates a minimum cut with \f$ source \f$ on the
890 /// Calculates a minimum cut with \f$ source \f$ on the
891 /// source-side (i.e. a set \f$ X\subsetneq V \f$ with \f$ source
892 /// \in X \f$ and minimal out-degree).
893 void calculateOut() {
897 /// \brief Calculates a minimum cut with \f$ source \f$ on the
900 /// Calculates a minimum cut with \f$ source \f$ on the
901 /// target-side (i.e. a set \f$ X\subsetneq V \f$ with \f$ source
902 /// \in X \f$ and minimal out-degree).
908 /// \brief Runs the algorithm.
910 /// Runs the algorithm. It finds nodes \c source and \c target
911 /// arbitrarily and then calls \ref init(), \ref calculateOut()
912 /// and \ref calculateIn().
919 /// \brief Runs the algorithm.
921 /// Runs the algorithm. It uses the given \c source node, finds a
922 /// proper \c target and then calls the \ref init(), \ref
923 /// calculateOut() and \ref calculateIn().
924 void run(const Node& s) {
932 /// \name Query Functions
933 /// The result of the %HaoOrlin algorithm
934 /// can be obtained using these functions.
936 /// Before using these functions, either \ref run(), \ref
937 /// calculateOut() or \ref calculateIn() must be called.
941 /// \brief Returns the value of the minimum value cut.
943 /// Returns the value of the minimum value cut.
944 Value minCut() const {
949 /// \brief Returns a minimum cut.
951 /// Sets \c nodeMap to the characteristic vector of a minimum
952 /// value cut: it will give a nonempty set \f$ X\subsetneq V \f$
953 /// with minimal out-degree (i.e. \c nodeMap will be true exactly
954 /// for the nodes of \f$ X \f$). \pre nodeMap should be a
955 /// bool-valued node-map.
956 template <typename NodeMap>
957 Value minCut(NodeMap& nodeMap) const {
958 for (NodeIt it(_graph); it != INVALID; ++it) {
959 nodeMap.set(it, (*_min_cut_map)[it]);
971 #endif //LEMON_HAO_ORLIN_H