!
!
!
1
1
42
42
2
2
1
1
2
2
10
10
4
3
1
1
7
7
92
92
10
10
2
2
45
45
6
6
47
47
2
2
4
4
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 |
... | ... |
@@ -274,9 +274,9 @@ |
274 | 274 |
\brief Algorithms for finding shortest paths. |
275 | 275 |
|
276 | 276 |
This group contains the algorithms for finding shortest paths in digraphs. |
277 | 277 |
|
278 |
- \ref Dijkstra Dijkstra's algorithm for finding shortest paths from a |
|
278 |
- \ref Dijkstra Dijkstra's algorithm for finding shortest paths from a |
|
279 | 279 |
source node when all arc lengths are non-negative. |
280 | 280 |
- \ref Suurballe A successive shortest path algorithm for finding |
281 | 281 |
arc-disjoint paths between two nodes having minimum total length. |
282 | 282 |
*/ |
... | ... |
@@ -305,9 +305,9 @@ |
305 | 305 |
Tarjan for solving this problem. It also provides functions to query the |
306 | 306 |
minimum cut, which is the dual problem of maximum flow. |
307 | 307 |
|
308 | 308 |
|
309 |
\ref Circulation is a preflow push-relabel algorithm implemented directly |
|
309 |
\ref Circulation is a preflow push-relabel algorithm implemented directly |
|
310 | 310 |
for finding feasible circulations, which is a somewhat different problem, |
311 | 311 |
but it is strongly related to maximum flow. |
312 | 312 |
For more information, see \ref Circulation. |
313 | 313 |
*/ |
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 |
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 |
... | ... |
@@ -80,9 +80,9 @@ |
80 | 80 |
- For all \f$u\in V\f$ nodes: |
81 | 81 |
- \f$\pi(u)<=0\f$; |
82 | 82 |
- if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$, |
83 | 83 |
then \f$\pi(u)=0\f$. |
84 |
|
|
84 |
|
|
85 | 85 |
Here \f$cost^\pi(uv)\f$ denotes the \e reduced \e cost of the arc |
86 | 86 |
\f$uv\in A\f$ with respect to the potential function \f$\pi\f$, i.e. |
87 | 87 |
\f[ cost^\pi(uv) = cost(uv) + \pi(u) - \pi(v).\f] |
88 | 88 |
|
... | ... |
@@ -118,9 +118,9 @@ |
118 | 118 |
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \leq |
119 | 119 |
sup(u) \quad \forall u\in V \f] |
120 | 120 |
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f] |
121 | 121 |
|
122 |
It means that the total demand must be less or equal to the |
|
122 |
It means that the total demand must be less or equal to the |
|
123 | 123 |
total supply (i.e. \f$\sum_{u\in V} sup(u)\f$ must be zero or |
124 | 124 |
positive) and all the demands have to be satisfied, but there |
125 | 125 |
could be supplies that are not carried out from the supply |
126 | 126 |
nodes. |
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 |
... | ... |
@@ -417,9 +417,9 @@ |
417 | 417 |
|
418 | 418 |
void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) { |
419 | 419 |
Parent::initialize(digraph); |
420 | 420 |
_node_filter = &node_filter; |
421 |
_arc_filter = &arc_filter; |
|
421 |
_arc_filter = &arc_filter; |
|
422 | 422 |
} |
423 | 423 |
|
424 | 424 |
public: |
425 | 425 |
|
... | ... |
@@ -504,13 +504,13 @@ |
504 | 504 |
|
505 | 505 |
public: |
506 | 506 |
|
507 | 507 |
template <typename V> |
508 |
class NodeMap |
|
509 |
: public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, |
|
510 |
|
|
508 |
class NodeMap |
|
509 |
: public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, |
|
510 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> { |
|
511 | 511 |
typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, |
512 |
|
|
512 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent; |
|
513 | 513 |
|
514 | 514 |
public: |
515 | 515 |
typedef V Value; |
516 | 516 |
|
... | ... |
@@ -531,11 +531,11 @@ |
531 | 531 |
} |
532 | 532 |
}; |
533 | 533 |
|
534 | 534 |
template <typename V> |
535 |
class ArcMap |
|
535 |
class ArcMap |
|
536 | 536 |
: public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, |
537 |
|
|
537 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> { |
|
538 | 538 |
typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, |
539 | 539 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent; |
540 | 540 |
|
541 | 541 |
public: |
... | ... |
@@ -578,9 +578,9 @@ |
578 | 578 |
|
579 | 579 |
void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) { |
580 | 580 |
Parent::initialize(digraph); |
581 | 581 |
_node_filter = &node_filter; |
582 |
_arc_filter = &arc_filter; |
|
582 |
_arc_filter = &arc_filter; |
|
583 | 583 |
} |
584 | 584 |
|
585 | 585 |
public: |
586 | 586 |
|
... | ... |
@@ -647,12 +647,12 @@ |
647 | 647 |
return arc; |
648 | 648 |
} |
649 | 649 |
|
650 | 650 |
template <typename V> |
651 |
class NodeMap |
|
651 |
class NodeMap |
|
652 | 652 |
: public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, |
653 | 653 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> { |
654 |
typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, |
|
654 |
typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, |
|
655 | 655 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent; |
656 | 656 |
|
657 | 657 |
public: |
658 | 658 |
typedef V Value; |
... | ... |
@@ -674,9 +674,9 @@ |
674 | 674 |
} |
675 | 675 |
}; |
676 | 676 |
|
677 | 677 |
template <typename V> |
678 |
class ArcMap |
|
678 |
class ArcMap |
|
679 | 679 |
: public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, |
680 | 680 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> { |
681 | 681 |
typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, |
682 | 682 |
LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent; |
... | ... |
@@ -1015,12 +1015,12 @@ |
1015 | 1015 |
return edge; |
1016 | 1016 |
} |
1017 | 1017 |
|
1018 | 1018 |
template <typename V> |
1019 |
class NodeMap |
|
1019 |
class NodeMap |
|
1020 | 1020 |
: public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
1021 | 1021 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> { |
1022 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
|
1022 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
|
1023 | 1023 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent; |
1024 | 1024 |
|
1025 | 1025 |
public: |
1026 | 1026 |
typedef V Value; |
... | ... |
@@ -1042,12 +1042,12 @@ |
1042 | 1042 |
} |
1043 | 1043 |
}; |
1044 | 1044 |
|
1045 | 1045 |
template <typename V> |
1046 |
class ArcMap |
|
1046 |
class ArcMap |
|
1047 | 1047 |
: public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
1048 | 1048 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> { |
1049 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
|
1049 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
|
1050 | 1050 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent; |
1051 | 1051 |
|
1052 | 1052 |
public: |
1053 | 1053 |
typedef V Value; |
... | ... |
@@ -1069,12 +1069,12 @@ |
1069 | 1069 |
} |
1070 | 1070 |
}; |
1071 | 1071 |
|
1072 | 1072 |
template <typename V> |
1073 |
class EdgeMap |
|
1073 |
class EdgeMap |
|
1074 | 1074 |
: public SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
1075 | 1075 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> { |
1076 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
|
1076 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, |
|
1077 | 1077 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; |
1078 | 1078 |
|
1079 | 1079 |
public: |
1080 | 1080 |
typedef V Value; |
... | ... |
@@ -1111,10 +1111,10 @@ |
1111 | 1111 |
typedef SubGraphBase Adaptor; |
1112 | 1112 |
protected: |
1113 | 1113 |
NF* _node_filter; |
1114 | 1114 |
EF* _edge_filter; |
1115 |
SubGraphBase() |
|
1116 |
: Parent(), _node_filter(0), _edge_filter(0) { } |
|
1115 |
SubGraphBase() |
|
1116 |
: Parent(), _node_filter(0), _edge_filter(0) { } |
|
1117 | 1117 |
|
1118 | 1118 |
void initialize(GR& graph, NF& node_filter, EF& edge_filter) { |
1119 | 1119 |
Parent::initialize(graph); |
1120 | 1120 |
_node_filter = &node_filter; |
... | ... |
@@ -1213,12 +1213,12 @@ |
1213 | 1213 |
return edge; |
1214 | 1214 |
} |
1215 | 1215 |
|
1216 | 1216 |
template <typename V> |
1217 |
class NodeMap |
|
1217 |
class NodeMap |
|
1218 | 1218 |
: public SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
1219 | 1219 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> { |
1220 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
|
1220 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
|
1221 | 1221 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent; |
1222 | 1222 |
|
1223 | 1223 |
public: |
1224 | 1224 |
typedef V Value; |
... | ... |
@@ -1240,12 +1240,12 @@ |
1240 | 1240 |
} |
1241 | 1241 |
}; |
1242 | 1242 |
|
1243 | 1243 |
template <typename V> |
1244 |
class ArcMap |
|
1244 |
class ArcMap |
|
1245 | 1245 |
: public SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
1246 | 1246 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> { |
1247 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
|
1247 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
|
1248 | 1248 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent; |
1249 | 1249 |
|
1250 | 1250 |
public: |
1251 | 1251 |
typedef V Value; |
... | ... |
@@ -1267,13 +1267,13 @@ |
1267 | 1267 |
} |
1268 | 1268 |
}; |
1269 | 1269 |
|
1270 | 1270 |
template <typename V> |
1271 |
class EdgeMap |
|
1271 |
class EdgeMap |
|
1272 | 1272 |
: public SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
1273 | 1273 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> { |
1274 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
|
1275 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; |
|
1274 |
typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, |
|
1275 |
LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent; |
|
1276 | 1276 |
|
1277 | 1277 |
public: |
1278 | 1278 |
typedef V Value; |
1279 | 1279 |
|
... | ... |
@@ -1494,9 +1494,9 @@ |
1494 | 1494 |
SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, |
1495 | 1495 |
true> > { |
1496 | 1496 |
#endif |
1497 | 1497 |
typedef DigraphAdaptorExtender< |
1498 |
SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, |
|
1498 |
SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, |
|
1499 | 1499 |
true> > Parent; |
1500 | 1500 |
|
1501 | 1501 |
public: |
1502 | 1502 |
|
... | ... |
@@ -1515,9 +1515,9 @@ |
1515 | 1515 |
/// \brief Constructor |
1516 | 1516 |
/// |
1517 | 1517 |
/// Creates a subgraph for the given digraph or graph with the |
1518 | 1518 |
/// given node filter map. |
1519 |
FilterNodes(GR& graph, NF& node_filter) |
|
1519 |
FilterNodes(GR& graph, NF& node_filter) |
|
1520 | 1520 |
: Parent(), const_true_map() |
1521 | 1521 |
{ |
1522 | 1522 |
Parent::initialize(graph, node_filter, const_true_map); |
1523 | 1523 |
} |
... | ... |
@@ -1553,13 +1553,13 @@ |
1553 | 1553 |
template<typename GR, typename NF> |
1554 | 1554 |
class FilterNodes<GR, NF, |
1555 | 1555 |
typename enable_if<UndirectedTagIndicator<GR> >::type> : |
1556 | 1556 |
public GraphAdaptorExtender< |
1557 |
SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, |
|
1557 |
SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, |
|
1558 | 1558 |
true> > { |
1559 | 1559 |
|
1560 | 1560 |
typedef GraphAdaptorExtender< |
1561 |
SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, |
|
1561 |
SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, |
|
1562 | 1562 |
true> > Parent; |
1563 | 1563 |
|
1564 | 1564 |
public: |
1565 | 1565 |
|
... | ... |
@@ -1641,9 +1641,9 @@ |
1641 | 1641 |
SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, |
1642 | 1642 |
AF, false> > { |
1643 | 1643 |
#endif |
1644 | 1644 |
typedef DigraphAdaptorExtender< |
1645 |
SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, |
|
1645 |
SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, |
|
1646 | 1646 |
AF, false> > Parent; |
1647 | 1647 |
|
1648 | 1648 |
public: |
1649 | 1649 |
|
... | ... |
@@ -1747,13 +1747,13 @@ |
1747 | 1747 |
template<typename GR, |
1748 | 1748 |
typename EF = typename GR::template EdgeMap<bool> > |
1749 | 1749 |
class FilterEdges : |
1750 | 1750 |
public GraphAdaptorExtender< |
1751 |
SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, |
|
1751 |
SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, |
|
1752 | 1752 |
EF, false> > { |
1753 | 1753 |
#endif |
1754 | 1754 |
typedef GraphAdaptorExtender< |
1755 |
SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, |
|
1755 |
SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, |
|
1756 | 1756 |
EF, false> > Parent; |
1757 | 1757 |
|
1758 | 1758 |
public: |
1759 | 1759 |
|
... | ... |
@@ -1776,9 +1776,9 @@ |
1776 | 1776 |
/// \brief Constructor |
1777 | 1777 |
/// |
1778 | 1778 |
/// Creates a subgraph for the given graph with the given edge |
1779 | 1779 |
/// filter map. |
1780 |
FilterEdges(GR& graph, EF& edge_filter) |
|
1780 |
FilterEdges(GR& graph, EF& edge_filter) |
|
1781 | 1781 |
: Parent(), const_true_map() { |
1782 | 1782 |
Parent::initialize(graph, const_true_map, edge_filter); |
1783 | 1783 |
} |
1784 | 1784 |
|
... | ... |
@@ -1844,9 +1844,9 @@ |
1844 | 1844 |
protected: |
1845 | 1845 |
Edge _edge; |
1846 | 1846 |
bool _forward; |
1847 | 1847 |
|
1848 |
Arc(const Edge& edge, bool forward) |
|
1848 |
Arc(const Edge& edge, bool forward) |
|
1849 | 1849 |
: _edge(edge), _forward(forward) {} |
1850 | 1850 |
|
1851 | 1851 |
public: |
1852 | 1852 |
Arc() {} |
... | ... |
@@ -2084,9 +2084,9 @@ |
2084 | 2084 |
ArcMapBase(const UndirectorBase<DGR>& adaptor) : |
2085 | 2085 |
_forward(*adaptor._digraph), _backward(*adaptor._digraph) {} |
2086 | 2086 |
|
2087 | 2087 |
ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value) |
2088 |
: _forward(*adaptor._digraph, value), |
|
2088 |
: _forward(*adaptor._digraph, value), |
|
2089 | 2089 |
_backward(*adaptor._digraph, value) {} |
2090 | 2090 |
|
2091 | 2091 |
void set(const Arc& a, const V& value) { |
2092 | 2092 |
if (direction(a)) { |
... | ... |
@@ -2202,9 +2202,9 @@ |
2202 | 2202 |
NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); } |
2203 | 2203 |
|
2204 | 2204 |
typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier; |
2205 | 2205 |
EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); } |
2206 |
|
|
2206 |
|
|
2207 | 2207 |
typedef EdgeNotifier ArcNotifier; |
2208 | 2208 |
ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); } |
2209 | 2209 |
|
2210 | 2210 |
protected: |
... | ... |
@@ -2706,9 +2706,9 @@ |
2706 | 2706 |
template<typename DGR, |
2707 | 2707 |
typename CM = typename DGR::template ArcMap<int>, |
2708 | 2708 |
typename FM = CM, |
2709 | 2709 |
typename TL = Tolerance<typename CM::Value> > |
2710 |
class ResidualDigraph |
|
2710 |
class ResidualDigraph |
|
2711 | 2711 |
: public SubDigraph< |
2712 | 2712 |
Undirector<const DGR>, |
2713 | 2713 |
ConstMap<typename DGR::Node, Const<bool, true> >, |
2714 | 2714 |
typename Undirector<const DGR>::template CombinedArcMap< |
... | ... |
@@ -2763,9 +2763,9 @@ |
2763 | 2763 |
/// Constructor of the residual digraph adaptor. The parameters are the |
2764 | 2764 |
/// digraph, the capacity map, the flow map, and a tolerance object. |
2765 | 2765 |
ResidualDigraph(const DGR& digraph, const CM& capacity, |
2766 | 2766 |
FM& flow, const TL& tolerance = Tolerance()) |
2767 |
: Parent(), _capacity(&capacity), _flow(&flow), |
|
2767 |
: Parent(), _capacity(&capacity), _flow(&flow), |
|
2768 | 2768 |
_graph(digraph), _node_filter(), |
2769 | 2769 |
_forward_filter(capacity, flow, tolerance), |
2770 | 2770 |
_backward_filter(capacity, flow, tolerance), |
2771 | 2771 |
_arc_filter(_forward_filter, _backward_filter) |
... | ... |
@@ -2845,9 +2845,9 @@ |
2845 | 2845 |
/// The value type of the map |
2846 | 2846 |
typedef typename CapacityMap::Value Value; |
2847 | 2847 |
|
2848 | 2848 |
/// Constructor |
2849 |
ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) |
|
2849 |
ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) |
|
2850 | 2850 |
: _adaptor(&adaptor) {} |
2851 | 2851 |
|
2852 | 2852 |
/// Returns the value associated with the given residual arc |
2853 | 2853 |
Value operator[](const Arc& a) const { |
... | ... |
@@ -3422,9 +3422,9 @@ |
3422 | 3422 |
/// |
3423 | 3423 |
/// This map adaptor class adapts two node maps of the original digraph |
3424 | 3424 |
/// to get a node map of the split digraph. |
3425 | 3425 |
/// Its value type is inherited from the first node map type (\c IN). |
3426 |
/// \tparam IN The type of the node map for the in-nodes. |
|
3426 |
/// \tparam IN The type of the node map for the in-nodes. |
|
3427 | 3427 |
/// \tparam OUT The type of the node map for the out-nodes. |
3428 | 3428 |
template <typename IN, typename OUT> |
3429 | 3429 |
class CombinedNodeMap { |
3430 | 3430 |
public: |
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 |
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 |
... | ... |
@@ -69,9 +69,9 @@ |
69 | 69 |
// The notifier type. |
70 | 70 |
typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; |
71 | 71 |
|
72 | 72 |
private: |
73 |
|
|
73 |
|
|
74 | 74 |
// The MapBase of the Map which imlements the core regisitry function. |
75 | 75 |
typedef typename Notifier::ObserverBase Parent; |
76 | 76 |
|
77 | 77 |
typedef std::allocator<Value> Allocator; |
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 |
... | ... |
@@ -156,9 +156,9 @@ |
156 | 156 |
typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; |
157 | 157 |
|
158 | 158 |
public: |
159 | 159 |
typedef DefaultMap<_Graph, _Item, _Value> Map; |
160 |
|
|
160 |
|
|
161 | 161 |
typedef typename Parent::GraphType GraphType; |
162 | 162 |
typedef typename Parent::Value Value; |
163 | 163 |
|
164 | 164 |
explicit DefaultMap(const GraphType& graph) : Parent(graph) {} |
1 |
/* -*- C++ -*- |
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
|
2 | 2 |
* |
3 |
* This file is a part of LEMON, a generic C++ optimization library |
|
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 |
... | ... |
@@ -62,13 +62,13 @@ |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
Node oppositeNode(const Node &n, const Arc &e) const { |
65 | 65 |
if (n == Parent::source(e)) |
66 |
|
|
66 |
return Parent::target(e); |
|
67 | 67 |
else if(n==Parent::target(e)) |
68 |
|
|
68 |
return Parent::source(e); |
|
69 | 69 |
else |
70 |
|
|
70 |
return INVALID; |
|
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
|
74 | 74 |
// Alteration notifier extensions |
... | ... |
@@ -90,97 +90,97 @@ |
90 | 90 |
} |
91 | 91 |
|
92 | 92 |
// Iterable extensions |
93 | 93 |
|
94 |
class NodeIt : public Node { |
|
94 |
class NodeIt : public Node { |
|
95 | 95 |
const Digraph* digraph; |
96 | 96 |
public: |
97 | 97 |
|
98 | 98 |
NodeIt() {} |
99 | 99 |
|
100 | 100 |
NodeIt(Invalid i) : Node(i) { } |
101 | 101 |
|
102 | 102 |
explicit NodeIt(const Digraph& _graph) : digraph(&_graph) { |
103 |
|
|
103 |
_graph.first(static_cast<Node&>(*this)); |
|
104 | 104 |
} |
105 | 105 |
|
106 |
NodeIt(const Digraph& _graph, const Node& node) |
|
107 |
: Node(node), digraph(&_graph) {} |
|
106 |
NodeIt(const Digraph& _graph, const Node& node) |
|
107 |
: Node(node), digraph(&_graph) {} |
|
108 | 108 |
|
109 |
NodeIt& operator++() { |
|
110 |
digraph->next(*this); |
|
111 |
|
|
109 |
NodeIt& operator++() { |
|
110 |
digraph->next(*this); |
|
111 |
return *this; |
|
112 | 112 |
} |
113 | 113 |
|
114 | 114 |
}; |
115 | 115 |
|
116 | 116 |
|
117 |
class ArcIt : public Arc { |
|
117 |
class ArcIt : public Arc { |
|
118 | 118 |
const Digraph* digraph; |
119 | 119 |
public: |
120 | 120 |
|
121 | 121 |
ArcIt() { } |
122 | 122 |
|
123 | 123 |
ArcIt(Invalid i) : Arc(i) { } |
124 | 124 |
|
125 | 125 |
explicit ArcIt(const Digraph& _graph) : digraph(&_graph) { |
126 |
|
|
126 |
_graph.first(static_cast<Arc&>(*this)); |
|
127 | 127 |
} |
128 | 128 |
|
129 |
ArcIt(const Digraph& _graph, const Arc& e) : |
|
130 |
Arc(e), digraph(&_graph) { } |
|
129 |
ArcIt(const Digraph& _graph, const Arc& e) : |
|
130 |
Arc(e), digraph(&_graph) { } |
|
131 | 131 |
|
132 |
ArcIt& operator++() { |
|
133 |
digraph->next(*this); |
|
134 |
|
|
132 |
ArcIt& operator++() { |
|
133 |
digraph->next(*this); |
|
134 |
return *this; |
|
135 | 135 |
} |
136 | 136 |
|
137 | 137 |
}; |
138 | 138 |
|
139 | 139 |
|
140 |
class OutArcIt : public Arc { |
|
140 |
class OutArcIt : public Arc { |
|
141 | 141 |
const Digraph* digraph; |
142 | 142 |
public: |
143 | 143 |
|
144 | 144 |
OutArcIt() { } |
145 | 145 |
|
146 | 146 |
OutArcIt(Invalid i) : Arc(i) { } |
147 | 147 |
|
148 |
OutArcIt(const Digraph& _graph, const Node& node) |
|
149 |
: digraph(&_graph) { |
|
150 |
|
|
148 |
OutArcIt(const Digraph& _graph, const Node& node) |
|
149 |
: digraph(&_graph) { |
|
150 |
_graph.firstOut(*this, node); |
|
151 | 151 |
} |
152 | 152 |
|
153 |
OutArcIt(const Digraph& _graph, const Arc& arc) |
|
154 |
: Arc(arc), digraph(&_graph) {} |
|
153 |
OutArcIt(const Digraph& _graph, const Arc& arc) |
|
154 |
: Arc(arc), digraph(&_graph) {} |
|
155 | 155 |
|
156 |
OutArcIt& operator++() { |
|
157 |
digraph->nextOut(*this); |
|
158 |
|
|
156 |
OutArcIt& operator++() { |
|
157 |
digraph->nextOut(*this); |
|
158 |
return *this; |
|
159 | 159 |
} |
160 | 160 |
|
161 | 161 |
}; |
162 | 162 |
|
163 | 163 |
|
164 |
class InArcIt : public Arc { |
|
164 |
class InArcIt : public Arc { |
|
165 | 165 |
const Digraph* digraph; |
166 | 166 |
public: |
167 | 167 |
|
168 | 168 |
InArcIt() { } |
169 | 169 |
|
170 | 170 |
InArcIt(Invalid i) : Arc(i) { } |
171 | 171 |
|
172 |
InArcIt(const Digraph& _graph, const Node& node) |
|
173 |
: digraph(&_graph) { |
|
174 |
|
|
172 |
InArcIt(const Digraph& _graph, const Node& node) |
|
173 |
: digraph(&_graph) { |
|
174 |
_graph.firstIn(*this, node); |
|
175 | 175 |
} |
176 | 176 |
|
177 |
InArcIt(const Digraph& _graph, const Arc& arc) : |
|
178 |
Arc(arc), digraph(&_graph) {} |
|
177 |
InArcIt(const Digraph& _graph, const Arc& arc) : |
|
178 |
Arc(arc), digraph(&_graph) {} |
|
179 | 179 |
|
180 |
InArcIt& operator++() { |
|
181 |
digraph->nextIn(*this); |
|
182 |
|
|
180 |
InArcIt& operator++() { |
|
181 |
digraph->nextIn(*this); |
|
182 |
return *this; |
|
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
}; |
186 | 186 |
|
... | ... |
@@ -214,28 +214,28 @@ |
214 | 214 |
|
215 | 215 |
using Parent::first; |
216 | 216 |
|
217 | 217 |
// Mappable extension |
218 |
|
|
218 |
|
|
219 | 219 |
template <typename _Value> |
220 |
class ArcMap |
|
220 |
class ArcMap |
|
221 | 221 |
: public MapExtender<DefaultMap<Digraph, Arc, _Value> > { |
222 | 222 |
typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; |
223 | 223 |
|
224 | 224 |
public: |
225 |
explicit ArcMap(const Digraph& _g) |
|
226 |
: Parent(_g) {} |
|
227 |
ArcMap(const Digraph& _g, const _Value& _v) |
|
228 |
: Parent(_g, _v) {} |
|
225 |
explicit ArcMap(const Digraph& _g) |
|
226 |
: Parent(_g) {} |
|
227 |
ArcMap(const Digraph& _g, const _Value& _v) |
|
228 |
: Parent(_g, _v) {} |
|
229 | 229 |
|
230 | 230 |
ArcMap& operator=(const ArcMap& cmap) { |
231 |
|
|
231 |
return operator=<ArcMap>(cmap); |
|
232 | 232 |
} |
233 | 233 |
|
234 | 234 |
template <typename CMap> |
235 | 235 |
ArcMap& operator=(const CMap& cmap) { |
236 | 236 |
Parent::operator=(cmap); |
237 |
|
|
237 |
return *this; |
|
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
}; |
241 | 241 |
|
... | ... |
@@ -246,9 +246,9 @@ |
246 | 246 |
Arc arc = Parent::addArc(from, to); |
247 | 247 |
notifier(Arc()).add(arc); |
248 | 248 |
return arc; |
249 | 249 |
} |
250 |
|
|
250 |
|
|
251 | 251 |
void clear() { |
252 | 252 |
notifier(Arc()).clear(); |
253 | 253 |
Parent::clear(); |
254 | 254 |
} |
... | ... |
@@ -311,13 +311,13 @@ |
311 | 311 |
} |
312 | 312 |
|
313 | 313 |
Node oppositeNode(const Node &n, const Edge &e) const { |
314 | 314 |
if( n == Parent::u(e)) |
315 |
|
|
315 |
return Parent::v(e); |
|
316 | 316 |
else if( n == Parent::v(e)) |
317 |
|
|
317 |
return Parent::u(e); |
|
318 | 318 |
else |
319 |
|
|
319 |
return INVALID; |
|
320 | 320 |
} |
321 | 321 |
|
322 | 322 |
Arc oppositeArc(const Arc &e) const { |
323 | 323 |
return Parent::direct(e, !Parent::direction(e)); |
... | ... |
@@ -339,9 +339,9 @@ |
339 | 339 |
|
340 | 340 |
public: |
341 | 341 |
|
342 | 342 |
using Parent::notifier; |
343 |
|
|
343 |
|
|
344 | 344 |
ArcNotifier& notifier(Arc) const { |
345 | 345 |
return arc_notifier; |
346 | 346 |
} |
347 | 347 |
|
... | ... |
@@ -349,120 +349,120 @@ |
349 | 349 |
return edge_notifier; |
350 | 350 |
} |
351 | 351 |
|
352 | 352 |
|
353 |
class NodeIt : public Node { |
|
353 |
class NodeIt : public Node { |
|
354 | 354 |
const Graph* graph; |
355 | 355 |
public: |
356 | 356 |
|
357 | 357 |
NodeIt() {} |
358 | 358 |
|
359 | 359 |
NodeIt(Invalid i) : Node(i) { } |
360 | 360 |
|
361 | 361 |
explicit NodeIt(const Graph& _graph) : graph(&_graph) { |
362 |
|
|
362 |
_graph.first(static_cast<Node&>(*this)); |
|
363 | 363 |
} |
364 | 364 |
|
365 |
NodeIt(const Graph& _graph, const Node& node) |
|
366 |
: Node(node), graph(&_graph) {} |
|
365 |
NodeIt(const Graph& _graph, const Node& node) |
|
366 |
: Node(node), graph(&_graph) {} |
|
367 | 367 |
|
368 |
NodeIt& operator++() { |
|
369 |
graph->next(*this); |
|
370 |
|
|
368 |
NodeIt& operator++() { |
|
369 |
graph->next(*this); |
|
370 |
return *this; |
|
371 | 371 |
} |
372 | 372 |
|
373 | 373 |
}; |
374 | 374 |
|
375 | 375 |
|
376 |
class ArcIt : public Arc { |
|
376 |
class ArcIt : public Arc { |
|
377 | 377 |
const Graph* graph; |
378 | 378 |
public: |
379 | 379 |
|
380 | 380 |
ArcIt() { } |
381 | 381 |
|
382 | 382 |
ArcIt(Invalid i) : Arc(i) { } |
383 | 383 |
|
384 | 384 |
explicit ArcIt(const Graph& _graph) : graph(&_graph) { |
385 |
|
|
385 |
_graph.first(static_cast<Arc&>(*this)); |
|
386 | 386 |
} |
387 | 387 |
|
388 |
ArcIt(const Graph& _graph, const Arc& e) : |
|
389 |
Arc(e), graph(&_graph) { } |
|
388 |
ArcIt(const Graph& _graph, const Arc& e) : |
|
389 |
Arc(e), graph(&_graph) { } |
|
390 | 390 |
|
391 |
ArcIt& operator++() { |
|
392 |
graph->next(*this); |
|
393 |
|
|
391 |
ArcIt& operator++() { |
|
392 |
graph->next(*this); |
|
393 |
return *this; |
|
394 | 394 |
} |
395 | 395 |
|
396 | 396 |
}; |
397 | 397 |
|
398 | 398 |
|
399 |
class OutArcIt : public Arc { |
|
399 |
class OutArcIt : public Arc { |
|
400 | 400 |
const Graph* graph; |
401 | 401 |
public: |
402 | 402 |
|
403 | 403 |
OutArcIt() { } |
404 | 404 |
|
405 | 405 |
OutArcIt(Invalid i) : Arc(i) { } |
406 | 406 |
|
407 |
OutArcIt(const Graph& _graph, const Node& node) |
|
408 |
: graph(&_graph) { |
|
409 |
|
|
407 |
OutArcIt(const Graph& _graph, const Node& node) |
|
408 |
: graph(&_graph) { |
|
409 |
_graph.firstOut(*this, node); |
|
410 | 410 |
} |
411 | 411 |
|
412 |
OutArcIt(const Graph& _graph, const Arc& arc) |
|
413 |
: Arc(arc), graph(&_graph) {} |
|
412 |
OutArcIt(const Graph& _graph, const Arc& arc) |
|
413 |
: Arc(arc), graph(&_graph) {} |
|
414 | 414 |
|
415 |
OutArcIt& operator++() { |
|
416 |
graph->nextOut(*this); |
|
417 |
|
|
415 |
OutArcIt& operator++() { |
|
416 |
graph->nextOut(*this); |
|
417 |
return *this; |
|
418 | 418 |
} |
419 | 419 |
|
420 | 420 |
}; |
421 | 421 |
|
422 | 422 |
|
423 |
class InArcIt : public Arc { |
|
423 |
class InArcIt : public Arc { |
|
424 | 424 |
const Graph* graph; |
425 | 425 |
public: |
426 | 426 |
|
427 | 427 |
InArcIt() { } |
428 | 428 |
|
429 | 429 |
InArcIt(Invalid i) : Arc(i) { } |
430 | 430 |
|
431 |
InArcIt(const Graph& _graph, const Node& node) |
|
432 |
: graph(&_graph) { |
|
433 |
|
|
431 |
InArcIt(const Graph& _graph, const Node& node) |
|
432 |
: graph(&_graph) { |
|
433 |
_graph.firstIn(*this, node); |
|
434 | 434 |
} |
435 | 435 |
|
436 |
InArcIt(const Graph& _graph, const Arc& arc) : |
|
437 |
Arc(arc), graph(&_graph) {} |
|
436 |
InArcIt(const Graph& _graph, const Arc& arc) : |
|
437 |
Arc(arc), graph(&_graph) {} |
|
438 | 438 |
|
439 |
InArcIt& operator++() { |
|
440 |
graph->nextIn(*this); |
|
441 |
|
|
439 |
InArcIt& operator++() { |
|
440 |
graph->nextIn(*this); |
|
441 |
return *this; |
|
442 | 442 |
} |
443 | 443 |
|
444 | 444 |
}; |
445 | 445 |
|
446 | 446 |
|
447 |
class EdgeIt : public Parent::Edge { |
|
447 |
class EdgeIt : public Parent::Edge { |
|
448 | 448 |
const Graph* graph; |
449 | 449 |
public: |
450 | 450 |
|
451 | 451 |
EdgeIt() { } |
452 | 452 |
|
453 | 453 |
EdgeIt(Invalid i) : Edge(i) { } |
454 | 454 |
|
455 | 455 |
explicit EdgeIt(const Graph& _graph) : graph(&_graph) { |
456 |
|
|
456 |
_graph.first(static_cast<Edge&>(*this)); |
|
457 | 457 |
} |
458 | 458 |
|
459 |
EdgeIt(const Graph& _graph, const Edge& e) : |
|
460 |
Edge(e), graph(&_graph) { } |
|
459 |
EdgeIt(const Graph& _graph, const Edge& e) : |
|
460 |
Edge(e), graph(&_graph) { } |
|
461 | 461 |
|
462 |
EdgeIt& operator++() { |
|
463 |
graph->next(*this); |
|
464 |
|
|
462 |
EdgeIt& operator++() { |
|
463 |
graph->next(*this); |
|
464 |
return *this; |
|
465 | 465 |
} |
466 | 466 |
|
467 | 467 |
}; |
468 | 468 |
|
... | ... |
@@ -476,19 +476,19 @@ |
476 | 476 |
|
477 | 477 |
IncEdgeIt(Invalid i) : Edge(i), direction(false) { } |
478 | 478 |
|
479 | 479 |
IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) { |
480 |
|
|
480 |
_graph.firstInc(*this, direction, n); |
|
481 | 481 |
} |
482 | 482 |
|
483 | 483 |
IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n) |
484 |
: graph(&_graph), Edge(ue) { |
|
485 |
direction = (_graph.source(ue) == n); |
|
484 |
: graph(&_graph), Edge(ue) { |
|
485 |
direction = (_graph.source(ue) == n); |
|
486 | 486 |
} |
487 | 487 |
|
488 | 488 |
IncEdgeIt& operator++() { |
489 |
graph->nextInc(*this, direction); |
|
490 |
return *this; |
|
489 |
graph->nextInc(*this, direction); |
|
490 |
return *this; |
|
491 | 491 |
} |
492 | 492 |
}; |
493 | 493 |
|
494 | 494 |
// \brief Base node of the iterator |
... | ... |
@@ -533,51 +533,51 @@ |
533 | 533 |
} |
534 | 534 |
|
535 | 535 |
|
536 | 536 |
template <typename _Value> |
537 |
class ArcMap |
|
537 |
class ArcMap |
|
538 | 538 |
: public MapExtender<DefaultMap<Graph, Arc, _Value> > { |
539 | 539 |
typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; |
540 | 540 |
|
541 | 541 |
public: |
542 |
explicit ArcMap(const Graph& _g) |
|
543 |
: Parent(_g) {} |
|
544 |
ArcMap(const Graph& _g, const _Value& _v) |
|
545 |
: Parent(_g, _v) {} |
|
542 |
explicit ArcMap(const Graph& _g) |
|
543 |
: Parent(_g) {} |
|
544 |
ArcMap(const Graph& _g, const _Value& _v) |
|
545 |
: Parent(_g, _v) {} |
|
546 | 546 |
|
547 | 547 |
ArcMap& operator=(const ArcMap& cmap) { |
548 |
|
|
548 |
return operator=<ArcMap>(cmap); |
|
549 | 549 |
} |
550 | 550 |
|
551 | 551 |
template <typename CMap> |
552 | 552 |
ArcMap& operator=(const CMap& cmap) { |
553 | 553 |
Parent::operator=(cmap); |
554 |
|
|
554 |
return *this; |
|
555 | 555 |
} |
556 | 556 |
|
557 | 557 |
}; |
558 | 558 |
|
559 | 559 |
|
560 | 560 |
template <typename _Value> |
561 |
class EdgeMap |
|
561 |
class EdgeMap |
|
562 | 562 |
: public MapExtender<DefaultMap<Graph, Edge, _Value> > { |
563 | 563 |
typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; |
564 | 564 |
|
565 | 565 |
public: |
566 |
explicit EdgeMap(const Graph& _g) |
|
567 |
: Parent(_g) {} |
|
566 |
explicit EdgeMap(const Graph& _g) |
|
567 |
: Parent(_g) {} |
|
568 | 568 |
|
569 |
EdgeMap(const Graph& _g, const _Value& _v) |
|
570 |
: Parent(_g, _v) {} |
|
569 |
EdgeMap(const Graph& _g, const _Value& _v) |
|
570 |
: Parent(_g, _v) {} |
|
571 | 571 |
|
572 | 572 |
EdgeMap& operator=(const EdgeMap& cmap) { |
573 |
|
|
573 |
return operator=<EdgeMap>(cmap); |
|
574 | 574 |
} |
575 | 575 |
|
576 | 576 |
template <typename CMap> |
577 | 577 |
EdgeMap& operator=(const CMap& cmap) { |
578 | 578 |
Parent::operator=(cmap); |
579 |
|
|
579 |
return *this; |
|
580 | 580 |
} |
581 | 581 |
|
582 | 582 |
}; |
583 | 583 |
|
... | ... |
@@ -592,9 +592,9 @@ |
592 | 592 |
arcs.push_back(Parent::direct(edge, false)); |
593 | 593 |
notifier(Arc()).add(arcs); |
594 | 594 |
return edge; |
595 | 595 |
} |
596 |
|
|
596 |
|
|
597 | 597 |
void clear() { |
598 | 598 |
notifier(Arc()).clear(); |
599 | 599 |
notifier(Edge()).clear(); |
600 | 600 |
Parent::clear(); |
... | ... |
@@ -618,9 +618,9 @@ |
618 | 618 |
~EdgeSetExtender() { |
619 | 619 |
edge_notifier.clear(); |
620 | 620 |
arc_notifier.clear(); |
621 | 621 |
} |
622 |
|
|
622 |
|
|
623 | 623 |
}; |
624 | 624 |
|
625 | 625 |
} |
626 | 626 |
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 |
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 |
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 |
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 |
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 |
... | ... |
@@ -97,9 +97,9 @@ |
97 | 97 |
#ifdef WIN32 |
98 | 98 |
SYSTEMTIME time; |
99 | 99 |
GetSystemTime(&time); |
100 | 100 |
char buf1[11], buf2[9], buf3[5]; |
101 |
|
|
101 |
if (GetDateFormat(MY_LOCALE, 0, &time, |
|
102 | 102 |
("ddd MMM dd"), buf1, 11) && |
103 | 103 |
GetTimeFormat(MY_LOCALE, 0, &time, |
104 | 104 |
("HH':'mm':'ss"), buf2, 9) && |
105 | 105 |
GetDateFormat(MY_LOCALE, 0, &time, |
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 |
... | ... |
@@ -119,9 +119,9 @@ |
119 | 119 |
void _applyMessageLevel(); |
120 | 120 |
|
121 | 121 |
int _message_level; |
122 | 122 |
|
123 |
|
|
123 |
|
|
124 | 124 |
|
125 | 125 |
}; |
126 | 126 |
|
127 | 127 |
} |
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 |
... | ... |
@@ -58,10 +58,10 @@ |
58 | 58 |
typedef UM UpperMap; |
59 | 59 |
|
60 | 60 |
/// \brief The type of supply map. |
61 | 61 |
/// |
62 |
/// The type of the map that stores the signed supply values of the |
|
63 |
/// nodes. |
|
62 |
/// The type of the map that stores the signed supply values of the |
|
63 |
/// nodes. |
|
64 | 64 |
/// It must conform to the \ref concepts::ReadMap "ReadMap" concept. |
65 | 65 |
typedef SM SupplyMap; |
66 | 66 |
|
67 | 67 |
/// \brief The type of the flow and supply values. |
... | ... |
@@ -133,9 +133,9 @@ |
133 | 133 |
|
134 | 134 |
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) |
135 | 135 |
\geq sup(u) \quad \forall u\in V, \f] |
136 | 136 |
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A. \f] |
137 |
|
|
137 |
|
|
138 | 138 |
The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be |
139 | 139 |
zero or negative in order to have a feasible solution (since the sum |
140 | 140 |
of the expressions on the left-hand side of the inequalities is zero). |
141 | 141 |
It means that the total demand must be greater or equal to the total |
... | ... |
@@ -143,9 +143,9 @@ |
143 | 143 |
but there could be demands that are not satisfied. |
144 | 144 |
If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand |
145 | 145 |
constraints have to be satisfied with equality, i.e. all demands |
146 | 146 |
have to be satisfied and all supplies have to be used. |
147 |
|
|
147 |
|
|
148 | 148 |
If you need the opposite inequalities in the supply/demand constraints |
149 | 149 |
(i.e. the total demand is less than the total supply and all the demands |
150 | 150 |
have to be satisfied while there could be supplies that are not used), |
151 | 151 |
then you could easily transform the problem to the above form by reversing |
... | ... |
@@ -324,9 +324,9 @@ |
324 | 324 |
/// The constructor of the class. |
325 | 325 |
/// |
326 | 326 |
/// \param graph The digraph the algorithm runs on. |
327 | 327 |
/// \param lower The lower bounds for the flow values on the arcs. |
328 |
/// \param upper The upper bounds (capacities) for the flow values |
|
328 |
/// \param upper The upper bounds (capacities) for the flow values |
|
329 | 329 |
/// on the arcs. |
330 | 330 |
/// \param supply The signed supply values of the nodes. |
331 | 331 |
Circulation(const Digraph &graph, const LowerMap &lower, |
332 | 332 |
const UpperMap &upper, const SupplyMap &supply) |
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 |
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 |
... | ... |
@@ -136,9 +136,9 @@ |
136 | 136 |
|
137 | 137 |
virtual void _clear(); |
138 | 138 |
|
139 | 139 |
virtual void _messageLevel(MessageLevel); |
140 |
|
|
140 |
|
|
141 | 141 |
public: |
142 | 142 |
|
143 | 143 |
///Solves LP with primal simplex method. |
144 | 144 |
SolveExitStatus solvePrimal(); |
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 |
... | ... |
@@ -434,9 +434,9 @@ |
434 | 434 |
NodeMap(const Digraph&, T) { } |
435 | 435 |
|
436 | 436 |
private: |
437 | 437 |
///Copy constructor |
438 |
NodeMap(const NodeMap& nm) : |
|
438 |
NodeMap(const NodeMap& nm) : |
|
439 | 439 |
ReferenceMap<Node, T, T&, const T&>(nm) { } |
440 | 440 |
///Assignment operator |
441 | 441 |
template <typename CMap> |
442 | 442 |
NodeMap& operator=(const CMap&) { |
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 |
... | ... |
@@ -37,9 +37,9 @@ |
37 | 37 |
/// subtypes of digraph and graph types. |
38 | 38 |
/// |
39 | 39 |
/// \note This class is a template class so that we can use it to |
40 | 40 |
/// create graph skeleton classes. The reason for this is that \c Node |
41 |
/// and \c Arc (or \c Edge) types should \e not derive from the same |
|
41 |
/// and \c Arc (or \c Edge) types should \e not derive from the same |
|
42 | 42 |
/// base class. For \c Node you should instantiate it with character |
43 | 43 |
/// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'. |
44 | 44 |
#ifndef DOXYGEN |
45 | 45 |
template <char sel = '0'> |
... | ... |
@@ -88,9 +88,9 @@ |
88 | 88 |
|
89 | 89 |
/// \brief Ordering operator. |
90 | 90 |
/// |
91 | 91 |
/// This operator defines an ordering of the items. |
92 |
/// It makes possible to use graph item types as key types in |
|
92 |
/// It makes possible to use graph item types as key types in |
|
93 | 93 |
/// associative containers (e.g. \c std::map). |
94 | 94 |
/// |
95 | 95 |
/// \note This operator only have to define some strict ordering of |
96 | 96 |
/// the items; this order has nothing to do with the iteration |
... | ... |
@@ -121,9 +121,9 @@ |
121 | 121 |
/// \brief Base skeleton class for directed graphs. |
122 | 122 |
/// |
123 | 123 |
/// This class describes the base interface of directed graph types. |
124 | 124 |
/// All digraph %concepts have to conform to this class. |
125 |
/// It just provides types for nodes and arcs and functions |
|
125 |
/// It just provides types for nodes and arcs and functions |
|
126 | 126 |
/// to get the source and the target nodes of arcs. |
127 | 127 |
class BaseDigraphComponent { |
128 | 128 |
public: |
129 | 129 |
|
... | ... |
@@ -425,9 +425,9 @@ |
425 | 425 |
}; |
426 | 426 |
|
427 | 427 |
/// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types. |
428 | 428 |
/// |
429 |
/// This class describes the concept of \c NodeIt, \c ArcIt and |
|
429 |
/// This class describes the concept of \c NodeIt, \c ArcIt and |
|
430 | 430 |
/// \c EdgeIt subtypes of digraph and graph types. |
431 | 431 |
template <typename GR, typename Item> |
432 | 432 |
class GraphItemIt : public Item { |
433 | 433 |
public: |
... | ... |
@@ -465,9 +465,9 @@ |
465 | 465 |
/// |
466 | 466 |
/// This operator increments the iterator, i.e. assigns it to the |
467 | 467 |
/// next item. |
468 | 468 |
GraphItemIt& operator++() { return *this; } |
469 |
|
|
469 |
|
|
470 | 470 |
/// \brief Equality operator |
471 | 471 |
/// |
472 | 472 |
/// Equality operator. |
473 | 473 |
/// Two iterators are equal if and only if they point to the |
... | ... |
@@ -500,17 +500,17 @@ |
500 | 500 |
const GR& g; |
501 | 501 |
}; |
502 | 502 |
}; |
503 | 503 |
|
504 |
/// \brief Concept class for \c InArcIt, \c OutArcIt and |
|
504 |
/// \brief Concept class for \c InArcIt, \c OutArcIt and |
|
505 | 505 |
/// \c IncEdgeIt types. |
506 | 506 |
/// |
507 |
/// This class describes the concept of \c InArcIt, \c OutArcIt |
|
507 |
/// This class describes the concept of \c InArcIt, \c OutArcIt |
|
508 | 508 |
/// and \c IncEdgeIt subtypes of digraph and graph types. |
509 | 509 |
/// |
510 | 510 |
/// \note Since these iterator classes do not inherit from the same |
511 | 511 |
/// base class, there is an additional template parameter (selector) |
512 |
/// \c sel. For \c InArcIt you should instantiate it with character |
|
512 |
/// \c sel. For \c InArcIt you should instantiate it with character |
|
513 | 513 |
/// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'. |
514 | 514 |
template <typename GR, |
515 | 515 |
typename Item = typename GR::Arc, |
516 | 516 |
typename Base = typename GR::Node, |
... | ... |
@@ -529,12 +529,12 @@ |
529 | 529 |
/// |
530 | 530 |
/// Copy constructor. |
531 | 531 |
GraphIncIt(const GraphIncIt& it) : Item(it) {} |
532 | 532 |
|
533 |
/// \brief Constructor that sets the iterator to the first |
|
533 |
/// \brief Constructor that sets the iterator to the first |
|
534 | 534 |
/// incoming or outgoing arc. |
535 | 535 |
/// |
536 |
/// Constructor that sets the iterator to the first arc |
|
536 |
/// Constructor that sets the iterator to the first arc |
|
537 | 537 |
/// incoming to or outgoing from the given node. |
538 | 538 |
explicit GraphIncIt(const GR&, const Base&) {} |
539 | 539 |
|
540 | 540 |
/// \brief Constructor for conversion from \c INVALID. |
... | ... |
@@ -803,18 +803,18 @@ |
803 | 803 |
void next(Edge&) const {} |
804 | 804 |
|
805 | 805 |
/// \brief Return the first edge incident to the given node. |
806 | 806 |
/// |
807 |
/// This function gives back the first edge incident to the given |
|
807 |
/// This function gives back the first edge incident to the given |
|
808 | 808 |
/// node. The bool parameter gives back the direction for which the |
809 |
/// source node of the directed arc representing the edge is the |
|
809 |
/// source node of the directed arc representing the edge is the |
|
810 | 810 |
/// given node. |
811 | 811 |
void firstInc(Edge&, bool&, const Node&) const {} |
812 | 812 |
|
813 | 813 |
/// \brief Gives back the next of the edges from the |
814 | 814 |
/// given node. |
815 | 815 |
/// |
816 |
/// This function gives back the next edge incident to the given |
|
816 |
/// This function gives back the next edge incident to the given |
|
817 | 817 |
/// node. The bool parameter should be used as \c firstInc() use it. |
818 | 818 |
void nextInc(Edge&, bool&) const {} |
819 | 819 |
|
820 | 820 |
using IterableDigraphComponent<Base>::baseNode; |
... | ... |
@@ -989,9 +989,9 @@ |
989 | 989 |
|
990 | 990 |
/// \brief Concept class for standard graph maps. |
991 | 991 |
/// |
992 | 992 |
/// This class describes the concept of standard graph maps, i.e. |
993 |
/// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and |
|
993 |
/// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and |
|
994 | 994 |
/// graph types, which can be used for associating data to graph items. |
995 | 995 |
/// The standard graph maps must conform to the ReferenceMap concept. |
996 | 996 |
template <typename GR, typename K, typename V> |
997 | 997 |
class GraphMap : public ReferenceMap<K, V, V&, const V&> { |
... | ... |
@@ -1044,9 +1044,9 @@ |
1044 | 1044 |
checkConcept |
1045 | 1045 |
<ReferenceMap<Key, Value, Value&, const Value&>, _Map>(); |
1046 | 1046 |
_Map m1(g); |
1047 | 1047 |
_Map m2(g,t); |
1048 |
|
|
1048 |
|
|
1049 | 1049 |
// Copy constructor |
1050 | 1050 |
// _Map m3(m); |
1051 | 1051 |
|
1052 | 1052 |
// Assignment operator |
... | ... |
@@ -1067,9 +1067,9 @@ |
1067 | 1067 |
|
1068 | 1068 |
/// \brief Skeleton class for mappable directed graphs. |
1069 | 1069 |
/// |
1070 | 1070 |
/// This class describes the interface of mappable directed graphs. |
1071 |
/// It extends \ref BaseDigraphComponent with the standard digraph |
|
1071 |
/// It extends \ref BaseDigraphComponent with the standard digraph |
|
1072 | 1072 |
/// map classes, namely \c NodeMap and \c ArcMap. |
1073 | 1073 |
/// This concept is part of the Digraph concept. |
1074 | 1074 |
template <typename BAS = BaseDigraphComponent> |
1075 | 1075 |
class MappableDigraphComponent : public BAS { |
... | ... |
@@ -1204,9 +1204,9 @@ |
1204 | 1204 |
|
1205 | 1205 |
/// \brief Skeleton class for mappable undirected graphs. |
1206 | 1206 |
/// |
1207 | 1207 |
/// This class describes the interface of mappable undirected graphs. |
1208 |
/// It extends \ref MappableDigraphComponent with the standard graph |
|
1208 |
/// It extends \ref MappableDigraphComponent with the standard graph |
|
1209 | 1209 |
/// map class for edges (\c EdgeMap). |
1210 | 1210 |
/// This concept is part of the Graph concept. |
1211 | 1211 |
template <typename BAS = BaseGraphComponent> |
1212 | 1212 |
class MappableGraphComponent : public MappableDigraphComponent<BAS> { |
... | ... |
@@ -1289,9 +1289,9 @@ |
1289 | 1289 |
|
1290 | 1290 |
/// \brief Skeleton class for extendable directed graphs. |
1291 | 1291 |
/// |
1292 | 1292 |
/// This class describes the interface of extendable directed graphs. |
1293 |
/// It extends \ref BaseDigraphComponent with functions for adding |
|
1293 |
/// It extends \ref BaseDigraphComponent with functions for adding |
|
1294 | 1294 |
/// nodes and arcs to the digraph. |
1295 | 1295 |
/// This concept requires \ref AlterableDigraphComponent. |
1296 | 1296 |
template <typename BAS = BaseDigraphComponent> |
1297 | 1297 |
class ExtendableDigraphComponent : public BAS { |
... | ... |
@@ -1333,9 +1333,9 @@ |
1333 | 1333 |
|
1334 | 1334 |
/// \brief Skeleton class for extendable undirected graphs. |
1335 | 1335 |
/// |
1336 | 1336 |
/// This class describes the interface of extendable undirected graphs. |
1337 |
/// It extends \ref BaseGraphComponent with functions for adding |
|
1337 |
/// It extends \ref BaseGraphComponent with functions for adding |
|
1338 | 1338 |
/// nodes and edges to the graph. |
1339 | 1339 |
/// This concept requires \ref AlterableGraphComponent. |
1340 | 1340 |
template <typename BAS = BaseGraphComponent> |
1341 | 1341 |
class ExtendableGraphComponent : public BAS { |
... | ... |
@@ -1377,9 +1377,9 @@ |
1377 | 1377 |
|
1378 | 1378 |
/// \brief Skeleton class for erasable directed graphs. |
1379 | 1379 |
/// |
1380 | 1380 |
/// This class describes the interface of erasable directed graphs. |
1381 |
/// It extends \ref BaseDigraphComponent with functions for removing |
|
1381 |
/// It extends \ref BaseDigraphComponent with functions for removing |
|
1382 | 1382 |
/// nodes and arcs from the digraph. |
1383 | 1383 |
/// This concept requires \ref AlterableDigraphComponent. |
1384 | 1384 |
template <typename BAS = BaseDigraphComponent> |
1385 | 1385 |
class ErasableDigraphComponent : public BAS { |
... | ... |
@@ -1390,9 +1390,9 @@ |
1390 | 1390 |
typedef typename Base::Arc Arc; |
1391 | 1391 |
|
1392 | 1392 |
/// \brief Erase a node from the digraph. |
1393 | 1393 |
/// |
1394 |
/// This function erases the given node from the digraph and all arcs |
|
1394 |
/// This function erases the given node from the digraph and all arcs |
|
1395 | 1395 |
/// connected to the node. |
1396 | 1396 |
void erase(const Node&) {} |
1397 | 1397 |
|
1398 | 1398 |
/// \brief Erase an arc from the digraph. |
... | ... |
@@ -1416,9 +1416,9 @@ |
1416 | 1416 |
|
1417 | 1417 |
/// \brief Skeleton class for erasable undirected graphs. |
1418 | 1418 |
/// |
1419 | 1419 |
/// This class describes the interface of erasable undirected graphs. |
1420 |
/// It extends \ref BaseGraphComponent with functions for removing |
|
1420 |
/// It extends \ref BaseGraphComponent with functions for removing |
|
1421 | 1421 |
/// nodes and edges from the graph. |
1422 | 1422 |
/// This concept requires \ref AlterableGraphComponent. |
1423 | 1423 |
template <typename BAS = BaseGraphComponent> |
1424 | 1424 |
class ErasableGraphComponent : public BAS { |
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 |
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 |
... | ... |
@@ -257,9 +257,9 @@ |
257 | 257 |
/// connected with directed paths in both direction. |
258 | 258 |
/// |
259 | 259 |
/// \return \c true if the digraph is strongly connected. |
260 | 260 |
/// \note By definition, the empty digraph is strongly connected. |
261 |
/// |
|
261 |
/// |
|
262 | 262 |
/// \see countStronglyConnectedComponents(), stronglyConnectedComponents() |
263 | 263 |
/// \see connected() |
264 | 264 |
template <typename Digraph> |
265 | 265 |
bool stronglyConnected(const Digraph& digraph) { |
... | ... |
@@ -309,9 +309,9 @@ |
309 | 309 |
} |
310 | 310 |
|
311 | 311 |
/// \ingroup graph_properties |
312 | 312 |
/// |
313 |
/// \brief Count the number of strongly connected components of a |
|
313 |
/// \brief Count the number of strongly connected components of a |
|
314 | 314 |
/// directed graph |
315 | 315 |
/// |
316 | 316 |
/// This function counts the number of strongly connected components of |
317 | 317 |
/// the given directed graph. |
... | ... |
@@ -743,9 +743,9 @@ |
743 | 743 |
/// \ingroup graph_properties |
744 | 744 |
/// |
745 | 745 |
/// \brief Check whether an undirected graph is bi-node-connected. |
746 | 746 |
/// |
747 |
/// This function checks whether the given undirected graph is |
|
747 |
/// This function checks whether the given undirected graph is |
|
748 | 748 |
/// bi-node-connected, i.e. any two edges are on same circle. |
749 | 749 |
/// |
750 | 750 |
/// \return \c true if the graph bi-node-connected. |
751 | 751 |
/// \note By definition, the empty graph is bi-node-connected. |
... | ... |
@@ -757,9 +757,9 @@ |
757 | 757 |
} |
758 | 758 |
|
759 | 759 |
/// \ingroup graph_properties |
760 | 760 |
/// |
761 |
/// \brief Count the number of bi-node-connected components of an |
|
761 |
/// \brief Count the number of bi-node-connected components of an |
|
762 | 762 |
/// undirected graph. |
763 | 763 |
/// |
764 | 764 |
/// This function counts the number of bi-node-connected components of |
765 | 765 |
/// the given undirected graph. |
... | ... |
@@ -811,9 +811,9 @@ |
811 | 811 |
/// |
812 | 812 |
/// \param graph The undirected graph. |
813 | 813 |
/// \retval compMap A writable edge map. The values will be set from 0 |
814 | 814 |
/// to the number of the bi-node-connected components minus one. Each |
815 |
/// value of the map will be set exactly once, and the values of a |
|
815 |
/// value of the map will be set exactly once, and the values of a |
|
816 | 816 |
/// certain component will be set continuously. |
817 | 817 |
/// \return The number of bi-node-connected components. |
818 | 818 |
/// |
819 | 819 |
/// \see biNodeConnected(), countBiNodeConnectedComponents() |
... | ... |
@@ -857,9 +857,9 @@ |
857 | 857 |
/// The bi-node-connected components are separted by the cut nodes of |
858 | 858 |
/// the components. |
859 | 859 |
/// |
860 | 860 |
/// \param graph The undirected graph. |
861 |
/// \retval cutMap A writable node map. The values will be set to |
|
861 |
/// \retval cutMap A writable node map. The values will be set to |
|
862 | 862 |
/// \c true for the nodes that separate two or more components |
863 | 863 |
/// (exactly once for each cut node), and will not be changed for |
864 | 864 |
/// other nodes. |
865 | 865 |
/// \return The number of the cut nodes. |
... | ... |
@@ -1084,9 +1084,9 @@ |
1084 | 1084 |
/// \ingroup graph_properties |
1085 | 1085 |
/// |
1086 | 1086 |
/// \brief Check whether an undirected graph is bi-edge-connected. |
1087 | 1087 |
/// |
1088 |
/// This function checks whether the given undirected graph is |
|
1088 |
/// This function checks whether the given undirected graph is |
|
1089 | 1089 |
/// bi-edge-connected, i.e. any two nodes are connected with at least |
1090 | 1090 |
/// two edge-disjoint paths. |
1091 | 1091 |
/// |
1092 | 1092 |
/// \return \c true if the graph is bi-edge-connected. |
... | ... |
@@ -1191,9 +1191,9 @@ |
1191 | 1191 |
/// |
1192 | 1192 |
/// \brief Find the bi-edge-connected cut edges in an undirected graph. |
1193 | 1193 |
/// |
1194 | 1194 |
/// This function finds the bi-edge-connected cut edges in the given |
1195 |
/// undirected graph. |
|
1195 |
/// undirected graph. |
|
1196 | 1196 |
/// |
1197 | 1197 |
/// The bi-edge-connected components are the classes of an equivalence |
1198 | 1198 |
/// relation on the nodes of an undirected graph. Two nodes are in the |
1199 | 1199 |
/// same class if they are connected with at least two edge-disjoint |
... | ... |
@@ -1348,9 +1348,9 @@ |
1348 | 1348 |
/// is DAG. |
1349 | 1349 |
/// |
1350 | 1350 |
/// \param digraph The digraph. |
1351 | 1351 |
/// \retval order A readable and writable node map. The values will be |
1352 |
/// set from 0 to the number of the nodes in the digraph minus one. |
|
1352 |
/// set from 0 to the number of the nodes in the digraph minus one. |
|
1353 | 1353 |
/// Each value of the map will be set exactly once, and the values will |
1354 | 1354 |
/// be set descending order. |
1355 | 1355 |
/// \return \c false if the digraph is not DAG. |
1356 | 1356 |
/// |
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 |
... | ... |
@@ -1240,9 +1240,10 @@ |
1240 | 1240 |
typedef GR Digraph; |
1241 | 1241 |
|
1242 | 1242 |
protected: |
1243 | 1243 |
|
1244 |
class AutoNodeMap : |
|
1244 |
class AutoNodeMap : |
|
1245 |
public ItemSetTraits<GR, Node>::template Map<Arc>::Type { |
|
1245 | 1246 |
typedef typename ItemSetTraits<GR, Node>::template Map<Arc>::Type Parent; |
1246 | 1247 |
|
1247 | 1248 |
public: |
1248 | 1249 |
|
... | ... |
@@ -1279,9 +1280,9 @@ |
1279 | 1280 |
return g.target(a)<g.target(b); |
1280 | 1281 |
} |
1281 | 1282 |
}; |
1282 | 1283 |
|
1283 |
protected: |
|
1284 |
protected: |
|
1284 | 1285 |
|
1285 | 1286 |
const Digraph &_g; |
1286 | 1287 |
AutoNodeMap _head; |
1287 | 1288 |
typename Digraph::template ArcMap<Arc> _parent; |
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 |
... | ... |
@@ -455,9 +455,9 @@ |
455 | 455 |
} |
456 | 456 |
} |
457 | 457 |
|
458 | 458 |
void CplexBase::_applyMessageLevel() { |
459 |
CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, |
|
459 |
CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, |
|
460 | 460 |
_message_enabled ? CPX_ON : CPX_OFF); |
461 | 461 |
} |
462 | 462 |
|
463 | 463 |
// CplexLp members |
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 |
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 |
... | ... |
@@ -60,9 +60,9 @@ |
60 | 60 |
|
61 | 61 |
///Discover the type of a DIMACS file |
62 | 62 |
|
63 | 63 |
///This function starts seeking the beginning of the given file for the |
64 |
///problem type and size info. |
|
64 |
///problem type and size info. |
|
65 | 65 |
///The found data is returned in a special struct that can be evaluated |
66 | 66 |
///and passed to the appropriate reader function. |
67 | 67 |
DimacsDescriptor dimacsType(std::istream& is) |
68 | 68 |
{ |
... | ... |
@@ -211,9 +211,9 @@ |
211 | 211 |
if(infty==0) |
212 | 212 |
infty = std::numeric_limits<Capacity>::has_infinity ? |
213 | 213 |
std::numeric_limits<Capacity>::infinity() : |
214 | 214 |
std::numeric_limits<Capacity>::max(); |
215 |
|
|
215 |
|
|
216 | 216 |
while (is >> c) { |
217 | 217 |
switch (c) { |
218 | 218 |
case 'c': // comment line |
219 | 219 |
getline(is, str); |
... | ... |
@@ -236,9 +236,9 @@ |
236 | 236 |
is >> i >> j >> _cap; |
237 | 237 |
getline(is, str); |
238 | 238 |
e = g.addArc(nodes[i], nodes[j]); |
239 | 239 |
capacity.set(e, _cap); |
240 |
} |
|
240 |
} |
|
241 | 241 |
else if (desc.type==DimacsDescriptor::MAX) { |
242 | 242 |
is >> i >> j >> _cap; |
243 | 243 |
getline(is, str); |
244 | 244 |
e = g.addArc(nodes[i], nodes[j]); |
... | ... |
@@ -361,13 +361,13 @@ |
361 | 361 |
dummy<1> = 1) |
362 | 362 |
{ |
363 | 363 |
g.addArc(s,t); |
364 | 364 |
} |
365 |
|
|
365 |
|
|
366 | 366 |
/// \brief DIMACS plain (di)graph reader function. |
367 | 367 |
/// |
368 | 368 |
/// This function reads a plain (di)graph without any designated nodes |
369 |
/// and maps (e.g. a matching instance) from DIMACS format, i.e. from |
|
369 |
/// and maps (e.g. a matching instance) from DIMACS format, i.e. from |
|
370 | 370 |
/// DIMACS files having a line starting with |
371 | 371 |
/// \code |
372 | 372 |
/// p mat |
373 | 373 |
/// \endcode |
... | ... |
@@ -391,9 +391,9 @@ |
391 | 391 |
nodes.resize(desc.nodeNum + 1); |
392 | 392 |
for (int k = 1; k <= desc.nodeNum; ++k) { |
393 | 393 |
nodes[k] = g.addNode(); |
394 | 394 |
} |
395 |
|
|
395 |
|
|
396 | 396 |
while (is >> c) { |
397 | 397 |
switch (c) { |
398 | 398 |
case 'c': // comment line |
399 | 399 |
getline(is, str); |
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 |
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 |
... | ... |
@@ -25,9 +25,9 @@ |
25 | 25 |
#include <list> |
26 | 26 |
|
27 | 27 |
/// \ingroup graph_properties |
28 | 28 |
/// \file |
29 |
/// \brief Euler tour iterators and a function for checking the \e Eulerian |
|
29 |
/// \brief Euler tour iterators and a function for checking the \e Eulerian |
|
30 | 30 |
/// property. |
31 | 31 |
/// |
32 | 32 |
///This file provides Euler tour iterators and a function to check |
33 | 33 |
///if a (di)graph is \e Eulerian. |
... | ... |
@@ -40,9 +40,9 @@ |
40 | 40 |
///This iterator provides an Euler tour (Eulerian circuit) of a \e directed |
41 | 41 |
///graph (if there exists) and it converts to the \c Arc type of the digraph. |
42 | 42 |
/// |
43 | 43 |
///For example, if the given digraph has an Euler tour (i.e it has only one |
44 |
///non-trivial component and the in-degree is equal to the out-degree |
|
44 |
///non-trivial component and the in-degree is equal to the out-degree |
|
45 | 45 |
///for all nodes), then the following code will put the arcs of \c g |
46 | 46 |
///to the vector \c et according to an Euler tour of \c g. |
47 | 47 |
///\code |
48 | 48 |
/// std::vector<ListDigraph::Arc> et; |
... | ... |
@@ -137,18 +137,18 @@ |
137 | 137 |
///This iterator provides an Euler tour (Eulerian circuit) of an |
138 | 138 |
///\e undirected graph (if there exists) and it converts to the \c Arc |
139 | 139 |
///and \c Edge types of the graph. |
140 | 140 |
/// |
141 |
///For example, if the given graph has an Euler tour (i.e it has only one |
|
141 |
///For example, if the given graph has an Euler tour (i.e it has only one |
|
142 | 142 |
///non-trivial component and the degree of each node is even), |
143 | 143 |
///the following code will print the arc IDs according to an |
144 | 144 |
///Euler tour of \c g. |
145 | 145 |
///\code |
146 | 146 |
/// for(EulerIt<ListGraph> e(g); e!=INVALID; ++e) { |
147 | 147 |
/// std::cout << g.id(Edge(e)) << std::eol; |
148 | 148 |
/// } |
149 | 149 |
///\endcode |
150 |
///Although this iterator is for undirected graphs, it still returns |
|
150 |
///Although this iterator is for undirected graphs, it still returns |
|
151 | 151 |
///arcs in order to indicate the direction of the tour. |
152 | 152 |
///(But arcs convert to edges, of course.) |
153 | 153 |
/// |
154 | 154 |
///If \c g has no Euler tour, then the resulted walk will not be closed |
... | ... |
@@ -232,9 +232,9 @@ |
232 | 232 |
///Postfix incrementation |
233 | 233 |
|
234 | 234 |
/// Postfix incrementation. |
235 | 235 |
/// |
236 |
///\warning This incrementation returns an \c Arc (which converts to |
|
236 |
///\warning This incrementation returns an \c Arc (which converts to |
|
237 | 237 |
///an \c Edge), not an \ref EulerIt, as one may expect. |
238 | 238 |
Arc operator++(int) |
239 | 239 |
{ |
240 | 240 |
Arc e=*this; |
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 |
... | ... |
@@ -29,18 +29,18 @@ |
29 | 29 |
|
30 | 30 |
namespace _solver_bits { |
31 | 31 |
class VoidPtr { |
32 | 32 |
private: |
33 |
void *_ptr; |
|
33 |
void *_ptr; |
|
34 | 34 |
public: |
35 | 35 |
VoidPtr() : _ptr(0) {} |
36 | 36 |
|
37 | 37 |
template <typename T> |
38 | 38 |
VoidPtr(T* ptr) : _ptr(reinterpret_cast<void*>(ptr)) {} |
39 | 39 |
|
40 | 40 |
template <typename T> |
41 |
VoidPtr& operator=(T* ptr) { |
|
42 |
_ptr = reinterpret_cast<void*>(ptr); |
|
41 |
VoidPtr& operator=(T* ptr) { |
|
42 |
_ptr = reinterpret_cast<void*>(ptr); |
|
43 | 43 |
return *this; |
44 | 44 |
} |
45 | 45 |
|
46 | 46 |
template <typename T> |
... | ... |
@@ -122,15 +122,15 @@ |
122 | 122 |
~FreeEnvHelper() { |
123 | 123 |
freeEnv(); |
124 | 124 |
} |
125 | 125 |
}; |
126 |
|
|
126 |
|
|
127 | 127 |
static FreeEnvHelper freeEnvHelper; |
128 | 128 |
|
129 | 129 |
protected: |
130 |
|
|
130 |
|
|
131 | 131 |
int _message_level; |
132 |
|
|
132 |
|
|
133 | 133 |
public: |
134 | 134 |
|
135 | 135 |
///Pointer to the underlying GLPK data structure. |
136 | 136 |
_solver_bits::VoidPtr lpx() {return lp;} |
1 |
/* -*- C++ -*- |
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
|
2 | 2 |
* |
3 |
* This file is a part of LEMON, a generic C++ optimization library |
|
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 |
... | ... |
@@ -26,9 +26,9 @@ |
26 | 26 |
#include <lemon/concept_check.h> |
27 | 27 |
#include <lemon/concepts/maps.h> |
28 | 28 |
|
29 | 29 |
/// \ingroup min_cut |
30 |
/// \file |
|
30 |
/// \file |
|
31 | 31 |
/// \brief Gomory-Hu cut tree in graphs. |
32 | 32 |
|
33 | 33 |
namespace lemon { |
34 | 34 |
|
... | ... |
@@ -37,15 +37,15 @@ |
37 | 37 |
/// \brief Gomory-Hu cut tree algorithm |
38 | 38 |
/// |
39 | 39 |
/// The Gomory-Hu tree is a tree on the node set of a given graph, but it |
40 | 40 |
/// may contain edges which are not in the original graph. It has the |
41 |
/// property that the minimum capacity edge of the path between two nodes |
|
41 |
/// property that the minimum capacity edge of the path between two nodes |
|
42 | 42 |
/// in this tree has the same weight as the minimum cut in the graph |
43 | 43 |
/// between these nodes. Moreover the components obtained by removing |
44 | 44 |
/// this edge from the tree determine the corresponding minimum cut. |
45 | 45 |
/// Therefore once this tree is computed, the minimum cut between any pair |
46 | 46 |
/// of nodes can easily be obtained. |
47 |
/// |
|
47 |
/// |
|
48 | 48 |
/// The algorithm calculates \e n-1 distinct minimum cuts (currently with |
49 | 49 |
/// the \ref Preflow algorithm), thus it has \f$O(n^3\sqrt{e})\f$ overall |
50 | 50 |
/// time complexity. It calculates a rooted Gomory-Hu tree. |
51 | 51 |
/// The structure of the tree and the edge weights can be |
... | ... |
@@ -59,12 +59,12 @@ |
59 | 59 |
/// \tparam CAP The type of the edge map containing the capacities. |
60 | 60 |
/// The default map type is \ref concepts::Graph::EdgeMap "GR::EdgeMap<int>". |
61 | 61 |
#ifdef DOXYGEN |
62 | 62 |
template <typename GR, |
63 |
|
|
63 |
typename CAP> |
|
64 | 64 |
#else |
65 | 65 |
template <typename GR, |
66 |
|
|
66 |
typename CAP = typename GR::template EdgeMap<int> > |
|
67 | 67 |
#endif |
68 | 68 |
class GomoryHu { |
69 | 69 |
public: |
70 | 70 |
|
... | ... |
@@ -73,9 +73,9 @@ |
73 | 73 |
/// The capacity map type of the algorithm |
74 | 74 |
typedef CAP Capacity; |
75 | 75 |
/// The value type of capacities |
76 | 76 |
typedef typename Capacity::Value Value; |
77 |
|
|
77 |
|
|
78 | 78 |
private: |
79 | 79 |
|
80 | 80 |
TEMPLATE_GRAPH_TYPEDEFS(Graph); |
81 | 81 |
|
... | ... |
@@ -88,40 +88,40 @@ |
88 | 88 |
typename Graph::template NodeMap<int>* _order; |
89 | 89 |
|
90 | 90 |
void createStructures() { |
91 | 91 |
if (!_pred) { |
92 |
|
|
92 |
_pred = new typename Graph::template NodeMap<Node>(_graph); |
|
93 | 93 |
} |
94 | 94 |
if (!_weight) { |
95 |
|
|
95 |
_weight = new typename Graph::template NodeMap<Value>(_graph); |
|
96 | 96 |
} |
97 | 97 |
if (!_order) { |
98 |
|
|
98 |
_order = new typename Graph::template NodeMap<int>(_graph); |
|
99 | 99 |
} |
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
void destroyStructures() { |
103 | 103 |
if (_pred) { |
104 |
|
|
104 |
delete _pred; |
|
105 | 105 |
} |
106 | 106 |
if (_weight) { |
107 |
|
|
107 |
delete _weight; |
|
108 | 108 |
} |
109 | 109 |
if (_order) { |
110 |
|
|
110 |
delete _order; |
|
111 | 111 |
} |
112 | 112 |
} |
113 |
|
|
113 |
|
|
114 | 114 |
public: |
115 | 115 |
|
116 | 116 |
/// \brief Constructor |
117 | 117 |
/// |
118 | 118 |
/// Constructor. |
119 | 119 |
/// \param graph The undirected graph the algorithm runs on. |
120 | 120 |
/// \param capacity The edge capacity map. |
121 |
GomoryHu(const Graph& graph, const Capacity& capacity) |
|
121 |
GomoryHu(const Graph& graph, const Capacity& capacity) |
|
122 | 122 |
: _graph(graph), _capacity(capacity), |
123 |
|
|
123 |
_pred(0), _weight(0), _order(0) |
|
124 | 124 |
{ |
125 | 125 |
checkConcept<concepts::ReadMap<Edge, Value>, Capacity>(); |
126 | 126 |
} |
127 | 127 |
|
... | ... |
@@ -133,9 +133,9 @@ |
133 | 133 |
destroyStructures(); |
134 | 134 |
} |
135 | 135 |
|
136 | 136 |
private: |
137 |
|
|
137 |
|
|
138 | 138 |
// Initialize the internal data structures |
139 | 139 |
void init() { |
140 | 140 |
createStructures(); |
141 | 141 |
|
... | ... |
@@ -144,61 +144,61 @@ |
144 | 144 |
(*_pred)[n] = _root; |
145 | 145 |
(*_order)[n] = -1; |
146 | 146 |
} |
147 | 147 |
(*_pred)[_root] = INVALID; |
148 |
(*_weight)[_root] = std::numeric_limits<Value>::max(); |
|
148 |
(*_weight)[_root] = std::numeric_limits<Value>::max(); |
|
149 | 149 |
} |
150 | 150 |
|
151 | 151 |
|
152 | 152 |
// Start the algorithm |
153 | 153 |
void start() { |
154 | 154 |
Preflow<Graph, Capacity> fa(_graph, _capacity, _root, INVALID); |
155 | 155 |
|
156 | 156 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
157 |
|
|
157 |
if (n == _root) continue; |
|
158 | 158 |
|
159 |
Node pn = (*_pred)[n]; |
|
160 |
fa.source(n); |
|
161 |
|
|
159 |
Node pn = (*_pred)[n]; |
|
160 |
fa.source(n); |
|
161 |
fa.target(pn); |
|
162 | 162 |
|
163 |
|
|
163 |
fa.runMinCut(); |
|
164 | 164 |
|
165 |
|
|
165 |
(*_weight)[n] = fa.flowValue(); |
|
166 | 166 |
|
167 |
for (NodeIt nn(_graph); nn != INVALID; ++nn) { |
|
168 |
if (nn != n && fa.minCut(nn) && (*_pred)[nn] == pn) { |
|
169 |
(*_pred)[nn] = n; |
|
170 |
} |
|
171 |
} |
|
172 |
if ((*_pred)[pn] != INVALID && fa.minCut((*_pred)[pn])) { |
|
173 |
(*_pred)[n] = (*_pred)[pn]; |
|
174 |
(*_pred)[pn] = n; |
|
175 |
(*_weight)[n] = (*_weight)[pn]; |
|
176 |
(*_weight)[pn] = fa.flowValue(); |
|
177 |
|
|
167 |
for (NodeIt nn(_graph); nn != INVALID; ++nn) { |
|
168 |
if (nn != n && fa.minCut(nn) && (*_pred)[nn] == pn) { |
|
169 |
(*_pred)[nn] = n; |
|
170 |
} |
|
171 |
} |
|
172 |
if ((*_pred)[pn] != INVALID && fa.minCut((*_pred)[pn])) { |
|
173 |
(*_pred)[n] = (*_pred)[pn]; |
|
174 |
(*_pred)[pn] = n; |
|
175 |
(*_weight)[n] = (*_weight)[pn]; |
|
176 |
(*_weight)[pn] = fa.flowValue(); |
|
177 |
} |
|
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
(*_order)[_root] = 0; |
181 | 181 |
int index = 1; |
182 | 182 |
|
183 | 183 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
184 |
std::vector<Node> st; |
|
185 |
Node nn = n; |
|
186 |
while ((*_order)[nn] == -1) { |
|
187 |
st.push_back(nn); |
|
188 |
nn = (*_pred)[nn]; |
|
189 |
} |
|
190 |
while (!st.empty()) { |
|
191 |
(*_order)[st.back()] = index++; |
|
192 |
st.pop_back(); |
|
193 |
} |
|
184 |
std::vector<Node> st; |
|
185 |
Node nn = n; |
|
186 |
while ((*_order)[nn] == -1) { |
|
187 |
st.push_back(nn); |
|
188 |
nn = (*_pred)[nn]; |
|
189 |
} |
|
190 |
while (!st.empty()) { |
|
191 |
(*_order)[st.back()] = index++; |
|
192 |
st.pop_back(); |
|
193 |
} |
|
194 | 194 |
} |
195 | 195 |
} |
196 | 196 |
|
197 | 197 |
public: |
198 | 198 |
|
199 | 199 |
///\name Execution Control |
200 |
|
|
200 |
|
|
201 | 201 |
///@{ |
202 | 202 |
|
203 | 203 |
/// \brief Run the Gomory-Hu algorithm. |
204 | 204 |
/// |
... | ... |
@@ -206,9 +206,9 @@ |
206 | 206 |
void run() { |
207 | 207 |
init(); |
208 | 208 |
start(); |
209 | 209 |
} |
210 |
|
|
210 |
|
|
211 | 211 |
/// @} |
212 | 212 |
|
213 | 213 |
///\name Query Functions |
214 | 214 |
///The results of the algorithm can be obtained using these |
... | ... |
@@ -231,9 +231,9 @@ |
231 | 231 |
|
232 | 232 |
/// \brief Return the weight of the predecessor edge in the |
233 | 233 |
/// Gomory-Hu tree. |
234 | 234 |
/// |
235 |
/// This function returns the weight of the predecessor edge of the |
|
235 |
/// This function returns the weight of the predecessor edge of the |
|
236 | 236 |
/// given node in the Gomory-Hu tree. |
237 | 237 |
/// If \c node is the root of the tree, the result is undefined. |
238 | 238 |
/// |
239 | 239 |
/// \pre \ref run() must be called before using this function. |
... | ... |
@@ -253,26 +253,26 @@ |
253 | 253 |
|
254 | 254 |
/// \brief Return the minimum cut value between two nodes |
255 | 255 |
/// |
256 | 256 |
/// This function returns the minimum cut value between the nodes |
257 |
/// \c s and \c t. |
|
257 |
/// \c s and \c t. |
|
258 | 258 |
/// It finds the nearest common ancestor of the given nodes in the |
259 | 259 |
/// Gomory-Hu tree and calculates the minimum weight edge on the |
260 | 260 |
/// paths to the ancestor. |
261 | 261 |
/// |
262 | 262 |
/// \pre \ref run() must be called before using this function. |
263 | 263 |
Value minCutValue(const Node& s, const Node& t) const { |
264 | 264 |
Node sn = s, tn = t; |
265 | 265 |
Value value = std::numeric_limits<Value>::max(); |
266 |
|
|
266 |
|
|
267 | 267 |
while (sn != tn) { |
268 |
if ((*_order)[sn] < (*_order)[tn]) { |
|
269 |
if ((*_weight)[tn] <= value) value = (*_weight)[tn]; |
|
270 |
tn = (*_pred)[tn]; |
|
271 |
} else { |
|
272 |
if ((*_weight)[sn] <= value) value = (*_weight)[sn]; |
|
273 |
sn = (*_pred)[sn]; |
|
274 |
|
|
268 |
if ((*_order)[sn] < (*_order)[tn]) { |
|
269 |
if ((*_weight)[tn] <= value) value = (*_weight)[tn]; |
|
270 |
tn = (*_pred)[tn]; |
|
271 |
} else { |
|
272 |
if ((*_weight)[sn] <= value) value = (*_weight)[sn]; |
|
273 |
sn = (*_pred)[sn]; |
|
274 |
} |
|
275 | 275 |
} |
276 | 276 |
return value; |
277 | 277 |
} |
278 | 278 |
|
... | ... |
@@ -293,35 +293,35 @@ |
293 | 293 |
/// \return The value of the minimum cut between \c s and \c t. |
294 | 294 |
/// |
295 | 295 |
/// \pre \ref run() must be called before using this function. |
296 | 296 |
template <typename CutMap> |
297 |
Value minCutMap(const Node& s, ///< |
|
297 |
Value minCutMap(const Node& s, ///< |
|
298 | 298 |
const Node& t, |
299 |
///< |
|
299 |
///< |
|
300 | 300 |
CutMap& cutMap |
301 |
///< |
|
301 |
///< |
|
302 | 302 |
) const { |
303 | 303 |
Node sn = s, tn = t; |
304 | 304 |
bool s_root=false; |
305 | 305 |
Node rn = INVALID; |
306 | 306 |
Value value = std::numeric_limits<Value>::max(); |
307 |
|
|
307 |
|
|
308 | 308 |
while (sn != tn) { |
309 |
if ((*_order)[sn] < (*_order)[tn]) { |
|
310 |
if ((*_weight)[tn] <= value) { |
|
311 |
|
|
309 |
if ((*_order)[sn] < (*_order)[tn]) { |
|
310 |
if ((*_weight)[tn] <= value) { |
|
311 |
rn = tn; |
|
312 | 312 |
s_root = false; |
313 |
value = (*_weight)[tn]; |
|
314 |
} |
|
315 |
tn = (*_pred)[tn]; |
|
316 |
} else { |
|
317 |
if ((*_weight)[sn] <= value) { |
|
318 |
rn = sn; |
|
313 |
value = (*_weight)[tn]; |
|
314 |
} |
|
315 |
tn = (*_pred)[tn]; |
|
316 |
} else { |
|
317 |
if ((*_weight)[sn] <= value) { |
|
318 |
rn = sn; |
|
319 | 319 |
s_root = true; |
320 |
value = (*_weight)[sn]; |
|
321 |
} |
|
322 |
sn = (*_pred)[sn]; |
|
323 |
} |
|
320 |
value = (*_weight)[sn]; |
|
321 |
} |
|
322 |
sn = (*_pred)[sn]; |
|
323 |
} |
|
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
typename Graph::template NodeMap<bool> reached(_graph, false); |
327 | 327 |
reached[_root] = true; |
... | ... |
@@ -330,29 +330,29 @@ |
330 | 330 |
cutMap.set(rn, s_root); |
331 | 331 |
|
332 | 332 |
std::vector<Node> st; |
333 | 333 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
334 |
|
|
334 |
st.clear(); |
|
335 | 335 |
Node nn = n; |
336 |
while (!reached[nn]) { |
|
337 |
st.push_back(nn); |
|
338 |
nn = (*_pred)[nn]; |
|
339 |
} |
|
340 |
while (!st.empty()) { |
|
341 |
cutMap.set(st.back(), cutMap[nn]); |
|
342 |
st.pop_back(); |
|
343 |
} |
|
336 |
while (!reached[nn]) { |
|
337 |
st.push_back(nn); |
|
338 |
nn = (*_pred)[nn]; |
|
339 |
} |
|
340 |
while (!st.empty()) { |
|
341 |
cutMap.set(st.back(), cutMap[nn]); |
|
342 |
st.pop_back(); |
|
343 |
} |
|
344 | 344 |
} |
345 |
|
|
345 |
|
|
346 | 346 |
return value; |
347 | 347 |
} |
348 | 348 |
|
349 | 349 |
///@} |
350 | 350 |
|
351 | 351 |
friend class MinCutNodeIt; |
352 | 352 |
|
353 | 353 |
/// Iterate on the nodes of a minimum cut |
354 |
|
|
354 |
|
|
355 | 355 |
/// This iterator class lists the nodes of a minimum cut found by |
356 | 356 |
/// GomoryHu. Before using it, you must allocate a GomoryHu class |
357 | 357 |
/// and call its \ref GomoryHu::run() "run()" method. |
358 | 358 |
/// |
... | ... |
@@ -443,13 +443,13 @@ |
443 | 443 |
++(*this); |
444 | 444 |
return n; |
445 | 445 |
} |
446 | 446 |
}; |
447 |
|
|
447 |
|
|
448 | 448 |
friend class MinCutEdgeIt; |
449 |
|
|
449 |
|
|
450 | 450 |
/// Iterate on the edges of a minimum cut |
451 |
|
|
451 |
|
|
452 | 452 |
/// This iterator class lists the edges of a minimum cut found by |
453 | 453 |
/// GomoryHu. Before using it, you must allocate a GomoryHu class |
454 | 454 |
/// and call its \ref GomoryHu::run() "run()" method. |
455 | 455 |
/// |
... | ... |
@@ -480,9 +480,9 @@ |
480 | 480 |
if(_node_it!=INVALID) |
481 | 481 |
_arc_it=typename Graph::OutArcIt(_graph,_node_it); |
482 | 482 |
} |
483 | 483 |
} |
484 |
|
|
484 |
|
|
485 | 485 |
public: |
486 | 486 |
/// Constructor |
487 | 487 |
|
488 | 488 |
/// Constructor. |
... | ... |
@@ -549,9 +549,9 @@ |
549 | 549 |
while(_arc_it!=INVALID && _cut[_graph.target(_arc_it)]) step(); |
550 | 550 |
return *this; |
551 | 551 |
} |
552 | 552 |
/// Postfix incrementation |
553 |
|
|
553 |
|
|
554 | 554 |
/// Postfix incrementation. |
555 | 555 |
/// |
556 | 556 |
/// \warning This incrementation |
557 | 557 |
/// returns an \c Arc, not a \c MinCutEdgeIt, as one may expect. |
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 |
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 |
... | ... |
@@ -30,9 +30,9 @@ |
30 | 30 |
/// \file |
31 | 31 |
/// \ingroup min_cut |
32 | 32 |
/// \brief Implementation of the Hao-Orlin algorithm. |
33 | 33 |
/// |
34 |
/// Implementation of the Hao-Orlin algorithm for finding a minimum cut |
|
34 |
/// Implementation of the Hao-Orlin algorithm for finding a minimum cut |
|
35 | 35 |
/// in a digraph. |
36 | 36 |
|
37 | 37 |
namespace lemon { |
38 | 38 |
|
... | ... |
@@ -40,9 +40,9 @@ |
40 | 40 |
/// |
41 | 41 |
/// \brief Hao-Orlin algorithm for finding a minimum cut in a digraph. |
42 | 42 |
/// |
43 | 43 |
/// This class implements the Hao-Orlin algorithm for finding a minimum |
44 |
/// value cut in a directed graph \f$D=(V,A)\f$. |
|
44 |
/// value cut in a directed graph \f$D=(V,A)\f$. |
|
45 | 45 |
/// It takes a fixed node \f$ source \in V \f$ and |
46 | 46 |
/// consists of two phases: in the first phase it determines a |
47 | 47 |
/// minimum cut with \f$ source \f$ on the source-side (i.e. a set |
48 | 48 |
/// \f$ X\subsetneq V \f$ with \f$ source \in X \f$ and minimal outgoing |
... | ... |
@@ -57,9 +57,9 @@ |
57 | 57 |
/// purpose of such algorithm is e.g. testing network reliability. |
58 | 58 |
/// |
59 | 59 |
/// For an undirected graph you can run just the first phase of the |
60 | 60 |
/// algorithm or you can use the algorithm of Nagamochi and Ibaraki, |
61 |
/// which solves the undirected problem in \f$ O(nm + n^2 \log n) \f$ |
|
61 |
/// which solves the undirected problem in \f$ O(nm + n^2 \log n) \f$ |
|
62 | 62 |
/// time. It is implemented in the NagamochiIbaraki algorithm class. |
63 | 63 |
/// |
64 | 64 |
/// \tparam GR The type of the digraph the algorithm runs on. |
65 | 65 |
/// \tparam CAP The type of the arc map containing the capacities, |
... | ... |
@@ -75,9 +75,9 @@ |
75 | 75 |
typename TOL = Tolerance<typename CAP::Value> > |
76 | 76 |
#endif |
77 | 77 |
class HaoOrlin { |
78 | 78 |
public: |
79 |
|
|
79 |
|
|
80 | 80 |
/// The digraph type of the algorithm |
81 | 81 |
typedef GR Digraph; |
82 | 82 |
/// The capacity map type of the algorithm |
83 | 83 |
typedef CAP CapacityMap; |
... | ... |
@@ -846,9 +846,9 @@ |
846 | 846 |
|
847 | 847 |
/// \brief Initialize the internal data structures. |
848 | 848 |
/// |
849 | 849 |
/// This function initializes the internal data structures. It creates |
850 |
/// the maps and some bucket structures for the algorithm. |
|
850 |
/// the maps and some bucket structures for the algorithm. |
|
851 | 851 |
/// The given node is used as the source node for the push-relabel |
852 | 852 |
/// algorithm. |
853 | 853 |
void init(const Node& source) { |
854 | 854 |
_source = source; |
... | ... |
@@ -926,9 +926,9 @@ |
926 | 926 |
} |
927 | 927 |
|
928 | 928 |
/// \brief Run the algorithm. |
929 | 929 |
/// |
930 |
/// This function runs the algorithm. It uses the given \c source node, |
|
930 |
/// This function runs the algorithm. It uses the given \c source node, |
|
931 | 931 |
/// finds a proper \c target node and then calls the \ref init(), |
932 | 932 |
/// \ref calculateOut() and \ref calculateIn(). |
933 | 933 |
void run(const Node& s) { |
934 | 934 |
init(s); |
... | ... |
@@ -940,18 +940,18 @@ |
940 | 940 |
|
941 | 941 |
/// \name Query Functions |
942 | 942 |
/// The result of the %HaoOrlin algorithm |
943 | 943 |
/// can be obtained using these functions.\n |
944 |
/// \ref run(), \ref calculateOut() or \ref calculateIn() |
|
944 |
/// \ref run(), \ref calculateOut() or \ref calculateIn() |
|
945 | 945 |
/// should be called before using them. |
946 | 946 |
|
947 | 947 |
/// @{ |
948 | 948 |
|
949 | 949 |
/// \brief Return the value of the minimum cut. |
950 | 950 |
/// |
951 | 951 |
/// This function returns the value of the minimum cut. |
952 | 952 |
/// |
953 |
/// \pre \ref run(), \ref calculateOut() or \ref calculateIn() |
|
953 |
/// \pre \ref run(), \ref calculateOut() or \ref calculateIn() |
|
954 | 954 |
/// must be called before using this function. |
955 | 955 |
Value minCutValue() const { |
956 | 956 |
return _min_cut; |
957 | 957 |
} |
... | ... |
@@ -968,9 +968,9 @@ |
968 | 968 |
/// \c bool (or convertible) value type. |
969 | 969 |
/// |
970 | 970 |
/// \return The value of the minimum cut. |
971 | 971 |
/// |
972 |
/// \pre \ref run(), \ref calculateOut() or \ref calculateIn() |
|
972 |
/// \pre \ref run(), \ref calculateOut() or \ref calculateIn() |
|
973 | 973 |
/// must be called before using this function. |
974 | 974 |
template <typename CutMap> |
975 | 975 |
Value minCutMap(CutMap& cutMap) const { |
976 | 976 |
for (NodeIt it(_graph); it != INVALID; ++it) { |
... | ... |
@@ -561,9 +561,9 @@ |
561 | 561 |
|
562 | 562 |
template <typename TDGR> |
563 | 563 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is); |
564 | 564 |
template <typename TDGR> |
565 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, |
|
565 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, |
|
566 | 566 |
const std::string& fn); |
567 | 567 |
template <typename TDGR> |
568 | 568 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn); |
569 | 569 |
|
... | ... |
@@ -1193,16 +1193,16 @@ |
1193 | 1193 |
|
1194 | 1194 |
/// @} |
1195 | 1195 |
|
1196 | 1196 |
}; |
1197 |
|
|
1197 |
|
|
1198 | 1198 |
/// \ingroup lemon_io |
1199 | 1199 |
/// |
1200 | 1200 |
/// \brief Return a \ref DigraphReader class |
1201 | 1201 |
/// |
1202 | 1202 |
/// This function just returns a \ref DigraphReader class. |
1203 | 1203 |
/// |
1204 |
/// With this function a digraph can be read from an |
|
1204 |
/// With this function a digraph can be read from an |
|
1205 | 1205 |
/// \ref lgf-format "LGF" file or input stream with several maps and |
1206 | 1206 |
/// attributes. For example, there is network flow problem on a |
1207 | 1207 |
/// digraph, i.e. a digraph with a \e capacity map on the arcs and |
1208 | 1208 |
/// \e source and \e target nodes. This digraph can be read with the |
... | ... |
@@ -1255,9 +1255,9 @@ |
1255 | 1255 |
} |
1256 | 1256 |
|
1257 | 1257 |
template <typename GR> |
1258 | 1258 |
class GraphReader; |
1259 |
|
|
1259 |
|
|
1260 | 1260 |
template <typename TGR> |
1261 | 1261 |
GraphReader<TGR> graphReader(TGR& graph, std::istream& is = std::cin); |
1262 | 1262 |
template <typename TGR> |
1263 | 1263 |
GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); |
... | ... |
@@ -1392,9 +1392,9 @@ |
1392 | 1392 |
private: |
1393 | 1393 |
template <typename TGR> |
1394 | 1394 |
friend GraphReader<TGR> graphReader(TGR& graph, std::istream& is); |
1395 | 1395 |
template <typename TGR> |
1396 |
friend GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); |
|
1396 |
friend GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); |
|
1397 | 1397 |
template <typename TGR> |
1398 | 1398 |
friend GraphReader<TGR> graphReader(TGR& graph, const char *fn); |
1399 | 1399 |
|
1400 | 1400 |
GraphReader(GraphReader& other) |
... | ... |
@@ -2076,11 +2076,11 @@ |
2076 | 2076 |
/// \ingroup lemon_io |
2077 | 2077 |
/// |
2078 | 2078 |
/// \brief Return a \ref GraphReader class |
2079 | 2079 |
/// |
2080 |
/// This function just returns a \ref GraphReader class. |
|
2080 |
/// This function just returns a \ref GraphReader class. |
|
2081 | 2081 |
/// |
2082 |
/// With this function a graph can be read from an |
|
2082 |
/// With this function a graph can be read from an |
|
2083 | 2083 |
/// \ref lgf-format "LGF" file or input stream with several maps and |
2084 | 2084 |
/// attributes. For example, there is weighted matching problem on a |
2085 | 2085 |
/// graph, i.e. a graph with a \e weight map on the edges. This |
2086 | 2086 |
/// graph can be read with the following code: |
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 |
... | ... |
@@ -350,9 +350,9 @@ |
350 | 350 |
template <typename DGR> |
351 | 351 |
class DigraphWriter; |
352 | 352 |
|
353 | 353 |
template <typename TDGR> |
354 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
354 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
355 | 355 |
std::ostream& os = std::cout); |
356 | 356 |
template <typename TDGR> |
357 | 357 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const std::string& fn); |
358 | 358 |
|
... | ... |
@@ -503,9 +503,9 @@ |
503 | 503 |
|
504 | 504 |
private: |
505 | 505 |
|
506 | 506 |
template <typename TDGR> |
507 |
friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
507 |
friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
508 | 508 |
std::ostream& os); |
509 | 509 |
template <typename TDGR> |
510 | 510 |
friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
511 | 511 |
const std::string& fn); |
... | ... |
@@ -916,9 +916,9 @@ |
916 | 916 |
/// \ingroup lemon_io |
917 | 917 |
/// |
918 | 918 |
/// \brief Return a \ref DigraphWriter class |
919 | 919 |
/// |
920 |
/// This function just returns a \ref DigraphWriter class. |
|
920 |
/// This function just returns a \ref DigraphWriter class. |
|
921 | 921 |
/// |
922 | 922 |
/// With this function a digraph can be write to a file or output |
923 | 923 |
/// stream in \ref lgf-format "LGF" format with several maps and |
924 | 924 |
/// attributes. For example, with the following code a network flow |
... | ... |
@@ -956,9 +956,9 @@ |
956 | 956 |
/// This function just returns a \ref DigraphWriter class. |
957 | 957 |
/// \relates DigraphWriter |
958 | 958 |
/// \sa digraphWriter(const TDGR& digraph, std::ostream& os) |
959 | 959 |
template <typename TDGR> |
960 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
960 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
961 | 961 |
const std::string& fn) { |
962 | 962 |
DigraphWriter<TDGR> tmp(digraph, fn); |
963 | 963 |
return tmp; |
964 | 964 |
} |
... | ... |
@@ -1100,13 +1100,13 @@ |
1100 | 1100 |
|
1101 | 1101 |
template <typename TGR> |
1102 | 1102 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os); |
1103 | 1103 |
template <typename TGR> |
1104 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, |
|
1104 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, |
|
1105 | 1105 |
const std::string& fn); |
1106 | 1106 |
template <typename TGR> |
1107 | 1107 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, const char *fn); |
1108 |
|
|
1108 |
|
|
1109 | 1109 |
GraphWriter(GraphWriter& other) |
1110 | 1110 |
: _os(other._os), local_os(other.local_os), _graph(other._graph), |
1111 | 1111 |
_skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) { |
1112 | 1112 |
|
... | ... |
@@ -1555,9 +1555,9 @@ |
1555 | 1555 |
/// \ingroup lemon_io |
1556 | 1556 |
/// |
1557 | 1557 |
/// \brief Return a \ref GraphWriter class |
1558 | 1558 |
/// |
1559 |
/// This function just returns a \ref GraphWriter class. |
|
1559 |
/// This function just returns a \ref GraphWriter class. |
|
1560 | 1560 |
/// |
1561 | 1561 |
/// With this function a graph can be write to a file or output |
1562 | 1562 |
/// stream in \ref lgf-format "LGF" format with several maps and |
1563 | 1563 |
/// attributes. For example, with the following code a weighted |
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 |
... | ... |
@@ -83,9 +83,9 @@ |
83 | 83 |
# define DEFAULT_LP SOPLEX |
84 | 84 |
typedef SoplexLp Lp; |
85 | 85 |
#elif LEMON_HAVE_CLP |
86 | 86 |
# define DEFAULT_LP CLP |
87 |
typedef ClpLp Lp; |
|
87 |
typedef ClpLp Lp; |
|
88 | 88 |
#endif |
89 | 89 |
#endif |
90 | 90 |
|
91 | 91 |
} //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 |
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 |
... | ... |
@@ -81,9 +81,9 @@ |
81 | 81 |
MESSAGE_NORMAL, |
82 | 82 |
/// Verbose output. |
83 | 83 |
MESSAGE_VERBOSE |
84 | 84 |
}; |
85 |
|
|
85 |
|
|
86 | 86 |
|
87 | 87 |
///The floating point type used by the solver |
88 | 88 |
typedef double Value; |
89 | 89 |
///The infinity constant |
... | ... |
@@ -113,16 +113,16 @@ |
113 | 113 |
public: |
114 | 114 |
typedef Value ExprValue; |
115 | 115 |
typedef True LpCol; |
116 | 116 |
/// Default constructor |
117 |
|
|
117 |
|
|
118 | 118 |
/// \warning The default constructor sets the Col to an |
119 | 119 |
/// undefined value. |
120 | 120 |
Col() {} |
121 | 121 |
/// Invalid constructor \& conversion. |
122 |
|
|
122 |
|
|
123 | 123 |
/// This constructor initializes the Col to be invalid. |
124 |
/// \sa Invalid for more details. |
|
124 |
/// \sa Invalid for more details. |
|
125 | 125 |
Col(const Invalid&) : _id(-1) {} |
126 | 126 |
/// Equality operator |
127 | 127 |
|
128 | 128 |
/// Two \ref Col "Col"s are equal if and only if they point to |
... | ... |
@@ -155,27 +155,27 @@ |
155 | 155 |
class ColIt : public Col { |
156 | 156 |
const LpBase *_solver; |
157 | 157 |
public: |
158 | 158 |
/// Default constructor |
159 |
|
|
159 |
|
|
160 | 160 |
/// \warning The default constructor sets the iterator |
161 | 161 |
/// to an undefined value. |
162 | 162 |
ColIt() {} |
163 | 163 |
/// Sets the iterator to the first Col |
164 |
|
|
164 |
|
|
165 | 165 |
/// Sets the iterator to the first Col. |
166 | 166 |
/// |
167 | 167 |
ColIt(const LpBase &solver) : _solver(&solver) |
168 | 168 |
{ |
169 | 169 |
_solver->cols.firstItem(_id); |
170 | 170 |
} |
171 | 171 |
/// Invalid constructor \& conversion |
172 |
|
|
172 |
|
|
173 | 173 |
/// Initialize the iterator to be invalid. |
174 | 174 |
/// \sa Invalid for more details. |
175 | 175 |
ColIt(const Invalid&) : Col(INVALID) {} |
176 | 176 |
/// Next column |
177 |
|
|
177 |
|
|
178 | 178 |
/// Assign the iterator to the next column. |
179 | 179 |
/// |
180 | 180 |
ColIt &operator++() |
181 | 181 |
{ |
... | ... |
@@ -208,24 +208,24 @@ |
208 | 208 |
public: |
209 | 209 |
typedef Value ExprValue; |
210 | 210 |
typedef True LpRow; |
211 | 211 |
/// Default constructor |
212 |
|
|
212 |
|
|
213 | 213 |
/// \warning The default constructor sets the Row to an |
214 | 214 |
/// undefined value. |
215 | 215 |
Row() {} |
216 | 216 |
/// Invalid constructor \& conversion. |
217 |
|
|
217 |
|
|
218 | 218 |
/// This constructor initializes the Row to be invalid. |
219 |
/// \sa Invalid for more details. |
|
219 |
/// \sa Invalid for more details. |
|
220 | 220 |
Row(const Invalid&) : _id(-1) {} |
221 | 221 |
/// Equality operator |
222 | 222 |
|
223 | 223 |
/// Two \ref Row "Row"s are equal if and only if they point to |
224 | 224 |
/// the same LP row or both are invalid. |
225 | 225 |
bool operator==(Row r) const {return _id == r._id;} |
226 | 226 |
/// Inequality operator |
227 |
|
|
227 |
|
|
228 | 228 |
/// \sa operator==(Row r) |
229 | 229 |
/// |
230 | 230 |
bool operator!=(Row r) const {return _id != r._id;} |
231 | 231 |
/// Artificial ordering operator. |
... | ... |
@@ -250,27 +250,27 @@ |
250 | 250 |
class RowIt : public Row { |
251 | 251 |
const LpBase *_solver; |
252 | 252 |
public: |
253 | 253 |
/// Default constructor |
254 |
|
|
254 |
|
|
255 | 255 |
/// \warning The default constructor sets the iterator |
256 | 256 |
/// to an undefined value. |
257 | 257 |
RowIt() {} |
258 | 258 |
/// Sets the iterator to the first Row |
259 |
|
|
259 |
|
|
260 | 260 |
/// Sets the iterator to the first Row. |
261 | 261 |
/// |
262 | 262 |
RowIt(const LpBase &solver) : _solver(&solver) |
263 | 263 |
{ |
264 | 264 |
_solver->rows.firstItem(_id); |
265 | 265 |
} |
266 | 266 |
/// Invalid constructor \& conversion |
267 |
|
|
267 |
|
|
268 | 268 |
/// Initialize the iterator to be invalid. |
269 | 269 |
/// \sa Invalid for more details. |
270 | 270 |
RowIt(const Invalid&) : Row(INVALID) {} |
271 | 271 |
/// Next row |
272 |
|
|
272 |
|
|
273 | 273 |
/// Assign the iterator to the next row. |
274 | 274 |
/// |
275 | 275 |
RowIt &operator++() |
276 | 276 |
{ |
... | ... |
@@ -346,9 +346,9 @@ |
346 | 346 |
|
347 | 347 |
public: |
348 | 348 |
typedef True SolverExpr; |
349 | 349 |
/// Default constructor |
350 |
|
|
350 |
|
|
351 | 351 |
/// Construct an empty expression, the coefficients and |
352 | 352 |
/// the constant component are initialized to zero. |
353 | 353 |
Expr() : const_comp(0) {} |
354 | 354 |
/// Construct an expression from a column |
... | ... |
@@ -447,11 +447,11 @@ |
447 | 447 |
return *this; |
448 | 448 |
} |
449 | 449 |
|
450 | 450 |
///Iterator over the expression |
451 |
|
|
452 |
///The iterator iterates over the terms of the expression. |
|
453 |
|
|
451 |
|
|
452 |
///The iterator iterates over the terms of the expression. |
|
453 |
/// |
|
454 | 454 |
///\code |
455 | 455 |
///double s=0; |
456 | 456 |
///for(LpBase::Expr::CoeffIt i(e);i!=INVALID;++i) |
457 | 457 |
/// s+= *i * primal(i); |
... | ... |
@@ -463,9 +463,9 @@ |
463 | 463 |
|
464 | 464 |
public: |
465 | 465 |
|
466 | 466 |
/// Sets the iterator to the first term |
467 |
|
|
467 |
|
|
468 | 468 |
/// Sets the iterator to the first term of the expression. |
469 | 469 |
/// |
470 | 470 |
CoeffIt(Expr& e) |
471 | 471 |
: _it(e.comps.begin()), _end(e.comps.end()){} |
... | ... |
@@ -480,9 +480,9 @@ |
480 | 480 |
|
481 | 481 |
/// Returns the coefficient of the term |
482 | 482 |
const Value& operator*() const { return _it->second; } |
483 | 483 |
/// Next term |
484 |
|
|
484 |
|
|
485 | 485 |
/// Assign the iterator to the next term. |
486 | 486 |
/// |
487 | 487 |
CoeffIt& operator++() { ++_it; return *this; } |
488 | 488 |
|
... | ... |
@@ -492,11 +492,11 @@ |
492 | 492 |
bool operator!=(Invalid) const { return _it != _end; } |
493 | 493 |
}; |
494 | 494 |
|
495 | 495 |
/// Const iterator over the expression |
496 |
|
|
497 |
///The iterator iterates over the terms of the expression. |
|
498 |
|
|
496 |
|
|
497 |
///The iterator iterates over the terms of the expression. |
|
498 |
/// |
|
499 | 499 |
///\code |
500 | 500 |
///double s=0; |
501 | 501 |
///for(LpBase::Expr::ConstCoeffIt i(e);i!=INVALID;++i) |
502 | 502 |
/// s+=*i * primal(i); |
... | ... |
@@ -508,9 +508,9 @@ |
508 | 508 |
|
509 | 509 |
public: |
510 | 510 |
|
511 | 511 |
/// Sets the iterator to the first term |
512 |
|
|
512 |
|
|
513 | 513 |
/// Sets the iterator to the first term of the expression. |
514 | 514 |
/// |
515 | 515 |
ConstCoeffIt(const Expr& e) |
516 | 516 |
: _it(e.comps.begin()), _end(e.comps.end()){} |
... | ... |
@@ -523,9 +523,9 @@ |
523 | 523 |
/// Returns the coefficient of the term |
524 | 524 |
const Value& operator*() const { return _it->second; } |
525 | 525 |
|
526 | 526 |
/// Next term |
527 |
|
|
527 |
|
|
528 | 528 |
/// Assign the iterator to the next term. |
529 | 529 |
/// |
530 | 530 |
ConstCoeffIt& operator++() { ++_it; return *this; } |
531 | 531 |
|
... | ... |
@@ -672,9 +672,9 @@ |
672 | 672 |
|
673 | 673 |
public: |
674 | 674 |
typedef True SolverExpr; |
675 | 675 |
/// Default constructor |
676 |
|
|
676 |
|
|
677 | 677 |
/// Construct an empty expression, the coefficients are |
678 | 678 |
/// initialized to zero. |
679 | 679 |
DualExpr() {} |
680 | 680 |
/// Construct an expression from a row |
... | ... |
@@ -707,9 +707,9 @@ |
707 | 707 |
comps.erase(id(r)); |
708 | 708 |
} |
709 | 709 |
} |
710 | 710 |
/// \brief Removes the coefficients which's absolute value does |
711 |
/// not exceed \c epsilon. |
|
711 |
/// not exceed \c epsilon. |
|
712 | 712 |
void simplify(Value epsilon = 0.0) { |
713 | 713 |
std::map<int, Value>::iterator it=comps.begin(); |
714 | 714 |
while (it != comps.end()) { |
715 | 715 |
std::map<int, Value>::iterator jt=it; |
... | ... |
@@ -756,11 +756,11 @@ |
756 | 756 |
return *this; |
757 | 757 |
} |
758 | 758 |
|
759 | 759 |
///Iterator over the expression |
760 |
|
|
761 |
///The iterator iterates over the terms of the expression. |
|
762 |
|
|
760 |
|
|
761 |
///The iterator iterates over the terms of the expression. |
|
762 |
/// |
|
763 | 763 |
///\code |
764 | 764 |
///double s=0; |
765 | 765 |
///for(LpBase::DualExpr::CoeffIt i(e);i!=INVALID;++i) |
766 | 766 |
/// s+= *i * dual(i); |
... | ... |
@@ -772,9 +772,9 @@ |
772 | 772 |
|
773 | 773 |
public: |
774 | 774 |
|
775 | 775 |
/// Sets the iterator to the first term |
776 |
|
|
776 |
|
|
777 | 777 |
/// Sets the iterator to the first term of the expression. |
778 | 778 |
/// |
779 | 779 |
CoeffIt(DualExpr& e) |
780 | 780 |
: _it(e.comps.begin()), _end(e.comps.end()){} |
... | ... |
@@ -790,9 +790,9 @@ |
790 | 790 |
/// Returns the coefficient of the term |
791 | 791 |
const Value& operator*() const { return _it->second; } |
792 | 792 |
|
793 | 793 |
/// Next term |
794 |
|
|
794 |
|
|
795 | 795 |
/// Assign the iterator to the next term. |
796 | 796 |
/// |
797 | 797 |
CoeffIt& operator++() { ++_it; return *this; } |
798 | 798 |
|
... | ... |
@@ -802,11 +802,11 @@ |
802 | 802 |
bool operator!=(Invalid) const { return _it != _end; } |
803 | 803 |
}; |
804 | 804 |
|
805 | 805 |
///Iterator over the expression |
806 |
|
|
807 |
///The iterator iterates over the terms of the expression. |
|
808 |
|
|
806 |
|
|
807 |
///The iterator iterates over the terms of the expression. |
|
808 |
/// |
|
809 | 809 |
///\code |
810 | 810 |
///double s=0; |
811 | 811 |
///for(LpBase::DualExpr::ConstCoeffIt i(e);i!=INVALID;++i) |
812 | 812 |
/// s+= *i * dual(i); |
... | ... |
@@ -818,9 +818,9 @@ |
818 | 818 |
|
819 | 819 |
public: |
820 | 820 |
|
821 | 821 |
/// Sets the iterator to the first term |
822 |
|
|
822 |
|
|
823 | 823 |
/// Sets the iterator to the first term of the expression. |
824 | 824 |
/// |
825 | 825 |
ConstCoeffIt(const DualExpr& e) |
826 | 826 |
: _it(e.comps.begin()), _end(e.comps.end()){} |
... | ... |
@@ -833,9 +833,9 @@ |
833 | 833 |
/// Returns the coefficient of the term |
834 | 834 |
const Value& operator*() const { return _it->second; } |
835 | 835 |
|
836 | 836 |
/// Next term |
837 |
|
|
837 |
|
|
838 | 838 |
/// Assign the iterator to the next term. |
839 | 839 |
/// |
840 | 840 |
ConstCoeffIt& operator++() { ++_it; return *this; } |
841 | 841 |
|
... | ... |
@@ -1802,12 +1802,12 @@ |
1802 | 1802 |
|
1803 | 1803 |
///The basis status of variables |
1804 | 1804 |
enum VarStatus { |
1805 | 1805 |
/// The variable is in the basis |
1806 |
BASIC, |
|
1806 |
BASIC, |
|
1807 | 1807 |
/// The variable is free, but not basic |
1808 | 1808 |
FREE, |
1809 |
/// The variable has active lower bound |
|
1809 |
/// The variable has active lower bound |
|
1810 | 1810 |
LOWER, |
1811 | 1811 |
/// The variable has active upper bound |
1812 | 1812 |
UPPER, |
1813 | 1813 |
/// The variable is non-basic and fixed |
... | ... |
@@ -1884,9 +1884,9 @@ |
1884 | 1884 |
} |
1885 | 1885 |
return res; |
1886 | 1886 |
} |
1887 | 1887 |
/// Returns a component of the primal ray |
1888 |
|
|
1888 |
|
|
1889 | 1889 |
/// The primal ray is solution of the modified primal problem, |
1890 | 1890 |
/// where we change each finite bound to 0, and we looking for a |
1891 | 1891 |
/// negative objective value in case of minimization, and positive |
1892 | 1892 |
/// objective value for maximization. If there is such solution, |
... | ... |
@@ -1918,9 +1918,9 @@ |
1918 | 1918 |
return res; |
1919 | 1919 |
} |
1920 | 1920 |
|
1921 | 1921 |
/// Returns a component of the dual ray |
1922 |
|
|
1922 |
|
|
1923 | 1923 |
/// The dual ray is solution of the modified primal problem, where |
1924 | 1924 |
/// we change each finite bound to 0 (i.e. the objective function |
1925 | 1925 |
/// coefficients in the primal problem), and we looking for a |
1926 | 1926 |
/// ositive objective value. If there is such solution, that |
... | ... |
@@ -2060,9 +2060,9 @@ |
2060 | 2060 |
} |
2061 | 2061 |
return res; |
2062 | 2062 |
} |
2063 | 2063 |
///The value of the objective function |
2064 |
|
|
2064 |
|
|
2065 | 2065 |
///\return |
2066 | 2066 |
///- \ref INF or -\ref INF means either infeasibility or unboundedness |
2067 | 2067 |
/// of the problem, depending on whether we minimize or maximize. |
2068 | 2068 |
///- \ref NaN if no primal solution is found. |
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 |
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 |
... | ... |
@@ -22,15 +22,15 @@ |
22 | 22 |
#include <lemon/lp_base.h> |
23 | 23 |
|
24 | 24 |
///\file |
25 | 25 |
///\brief Skeleton file to implement LP/MIP solver interfaces |
26 |
/// |
|
26 |
/// |
|
27 | 27 |
///The classes in this file do nothing, but they can serve as skeletons when |
28 | 28 |
///implementing an interface to new solvers. |
29 | 29 |
namespace lemon { |
30 | 30 |
|
31 | 31 |
///A skeleton class to implement LP/MIP solver base interface |
32 |
|
|
32 |
|
|
33 | 33 |
///This class does nothing, but it can serve as a skeleton when |
34 | 34 |
///implementing an interface to new solvers. |
35 | 35 |
class SkeletonSolverBase : public virtual LpBase { |
36 | 36 |
int col_num,row_num; |
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 |
... | ... |
@@ -1817,9 +1817,9 @@ |
1817 | 1817 |
|
1818 | 1818 |
/// \brief Provides an immutable and unique id for each item in a graph. |
1819 | 1819 |
/// |
1820 | 1820 |
/// IdMap provides a unique and immutable id for each item of the |
1821 |
/// same type (\c Node, \c Arc or \c Edge) in a graph. This id is |
|
1821 |
/// same type (\c Node, \c Arc or \c Edge) in a graph. This id is |
|
1822 | 1822 |
/// - \b unique: different items get different ids, |
1823 | 1823 |
/// - \b immutable: the id of an item does not change (even if you |
1824 | 1824 |
/// delete other nodes). |
1825 | 1825 |
/// |
... | ... |
@@ -2272,9 +2272,9 @@ |
2272 | 2272 |
return Map::operator[](item); |
2273 | 2273 |
} |
2274 | 2274 |
|
2275 | 2275 |
/// \brief Gives back the item belonging to a \e RangeId |
2276 |
/// |
|
2276 |
/// |
|
2277 | 2277 |
/// Gives back the item belonging to a \e RangeId. |
2278 | 2278 |
Item operator()(int id) const { |
2279 | 2279 |
return _inv_map[id]; |
2280 | 2280 |
} |
... | ... |
@@ -2498,9 +2498,9 @@ |
2498 | 2498 |
/// the degrees are stored in a standard \c NodeMap, so each query is done |
2499 | 2499 |
/// in constant time. On the other hand, the values are updated automatically |
2500 | 2500 |
/// whenever the digraph changes. |
2501 | 2501 |
/// |
2502 |
/// \warning Besides \c addNode() and \c addArc(), a digraph structure |
|
2502 |
/// \warning Besides \c addNode() and \c addArc(), a digraph structure |
|
2503 | 2503 |
/// may provide alternative ways to modify the digraph. |
2504 | 2504 |
/// The correct behavior of InDegMap is not guarantied if these additional |
2505 | 2505 |
/// features are used. For example the functions |
2506 | 2506 |
/// \ref ListDigraph::changeSource() "changeSource()", |
... | ... |
@@ -2514,9 +2514,9 @@ |
2514 | 2514 |
: protected ItemSetTraits<GR, typename GR::Arc> |
2515 | 2515 |
::ItemNotifier::ObserverBase { |
2516 | 2516 |
|
2517 | 2517 |
public: |
2518 |
|
|
2518 |
|
|
2519 | 2519 |
/// The graph type of InDegMap |
2520 | 2520 |
typedef GR Graph; |
2521 | 2521 |
typedef GR Digraph; |
2522 | 2522 |
/// The key type |
... | ... |
@@ -2628,9 +2628,9 @@ |
2628 | 2628 |
/// the degrees are stored in a standard \c NodeMap, so each query is done |
2629 | 2629 |
/// in constant time. On the other hand, the values are updated automatically |
2630 | 2630 |
/// whenever the digraph changes. |
2631 | 2631 |
/// |
2632 |
/// \warning Besides \c addNode() and \c addArc(), a digraph structure |
|
2632 |
/// \warning Besides \c addNode() and \c addArc(), a digraph structure |
|
2633 | 2633 |
/// may provide alternative ways to modify the digraph. |
2634 | 2634 |
/// The correct behavior of OutDegMap is not guarantied if these additional |
2635 | 2635 |
/// features are used. For example the functions |
2636 | 2636 |
/// \ref ListDigraph::changeSource() "changeSource()", |
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 |
... | ... |
@@ -40,9 +40,9 @@ |
40 | 40 |
/// \brief Maximum cardinality matching in general graphs |
41 | 41 |
/// |
42 | 42 |
/// This class implements Edmonds' alternating forest matching algorithm |
43 | 43 |
/// for finding a maximum cardinality matching in a general undirected graph. |
44 |
/// It can be started from an arbitrary initial matching |
|
44 |
/// It can be started from an arbitrary initial matching |
|
45 | 45 |
/// (the default is the empty one). |
46 | 46 |
/// |
47 | 47 |
/// The dual solution of the problem is a map of the nodes to |
48 | 48 |
/// \ref MaxMatching::Status "Status", having values \c EVEN (or \c D), |
... | ... |
@@ -68,13 +68,13 @@ |
68 | 68 |
MatchingMap; |
69 | 69 |
|
70 | 70 |
///\brief Status constants for Gallai-Edmonds decomposition. |
71 | 71 |
/// |
72 |
///These constants are used for indicating the Gallai-Edmonds |
|
72 |
///These constants are used for indicating the Gallai-Edmonds |
|
73 | 73 |
///decomposition of a graph. The nodes with status \c EVEN (or \c D) |
74 | 74 |
///induce a subgraph with factor-critical components, the nodes with |
75 | 75 |
///status \c ODD (or \c A) form the canonical barrier, and the nodes |
76 |
///with status \c MATCHED (or \c C) induce a subgraph having a |
|
76 |
///with status \c MATCHED (or \c C) induce a subgraph having a |
|
77 | 77 |
///perfect matching. |
78 | 78 |
enum Status { |
79 | 79 |
EVEN = 1, ///< = 1. (\c D is an alias for \c EVEN.) |
80 | 80 |
D = 1, |
... | ... |
@@ -511,9 +511,9 @@ |
511 | 511 |
} |
512 | 512 |
} |
513 | 513 |
} |
514 | 514 |
|
515 |
/// \brief Start Edmonds' algorithm with a heuristic improvement |
|
515 |
/// \brief Start Edmonds' algorithm with a heuristic improvement |
|
516 | 516 |
/// for dense graphs |
517 | 517 |
/// |
518 | 518 |
/// This function runs Edmonds' algorithm with a heuristic of postponing |
519 | 519 |
/// shrinks, therefore resulting in a faster algorithm for dense graphs. |
... | ... |
@@ -533,10 +533,10 @@ |
533 | 533 |
|
534 | 534 |
|
535 | 535 |
/// \brief Run Edmonds' algorithm |
536 | 536 |
/// |
537 |
/// This function runs Edmonds' algorithm. An additional heuristic of |
|
538 |
/// postponing shrinks is used for relatively dense graphs |
|
537 |
/// This function runs Edmonds' algorithm. An additional heuristic of |
|
538 |
/// postponing shrinks is used for relatively dense graphs |
|
539 | 539 |
/// (for which <tt>m>=2*n</tt> holds). |
540 | 540 |
void run() { |
541 | 541 |
if (countEdges(_graph) < 2 * countNodes(_graph)) { |
542 | 542 |
greedyInit(); |
... | ... |
@@ -555,9 +555,9 @@ |
555 | 555 |
/// @{ |
556 | 556 |
|
557 | 557 |
/// \brief Return the size (cardinality) of the matching. |
558 | 558 |
/// |
559 |
/// This function returns the size (cardinality) of the current matching. |
|
559 |
/// This function returns the size (cardinality) of the current matching. |
|
560 | 560 |
/// After run() it returns the size of the maximum matching in the graph. |
561 | 561 |
int matchingSize() const { |
562 | 562 |
int size = 0; |
563 | 563 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
... | ... |
@@ -569,18 +569,18 @@ |
569 | 569 |
} |
570 | 570 |
|
571 | 571 |
/// \brief Return \c true if the given edge is in the matching. |
572 | 572 |
/// |
573 |
/// This function returns \c true if the given edge is in the current |
|
573 |
/// This function returns \c true if the given edge is in the current |
|
574 | 574 |
/// matching. |
575 | 575 |
bool matching(const Edge& edge) const { |
576 | 576 |
return edge == (*_matching)[_graph.u(edge)]; |
577 | 577 |
} |
578 | 578 |
|
579 | 579 |
/// \brief Return the matching arc (or edge) incident to the given node. |
580 | 580 |
/// |
581 | 581 |
/// This function returns the matching arc (or edge) incident to the |
582 |
/// given node in the current matching or \c INVALID if the node is |
|
582 |
/// given node in the current matching or \c INVALID if the node is |
|
583 | 583 |
/// not covered by the matching. |
584 | 584 |
Arc matching(const Node& n) const { |
585 | 585 |
return (*_matching)[n]; |
586 | 586 |
} |
... | ... |
@@ -594,9 +594,9 @@ |
594 | 594 |
} |
595 | 595 |
|
596 | 596 |
/// \brief Return the mate of the given node. |
597 | 597 |
/// |
598 |
/// This function returns the mate of the given node in the current |
|
598 |
/// This function returns the mate of the given node in the current |
|
599 | 599 |
/// matching or \c INVALID if the node is not covered by the matching. |
600 | 600 |
Node mate(const Node& n) const { |
601 | 601 |
return (*_matching)[n] != INVALID ? |
602 | 602 |
_graph.target((*_matching)[n]) : INVALID; |
... | ... |
@@ -604,9 +604,9 @@ |
604 | 604 |
|
605 | 605 |
/// @} |
606 | 606 |
|
607 | 607 |
/// \name Dual Solution |
608 |
/// Functions to get the dual solution, i.e. the Gallai-Edmonds |
|
608 |
/// Functions to get the dual solution, i.e. the Gallai-Edmonds |
|
609 | 609 |
/// decomposition. |
610 | 610 |
|
611 | 611 |
/// @{ |
612 | 612 |
|
... | ... |
@@ -647,10 +647,10 @@ |
647 | 647 |
/// maximum weighted matching algorithm. The implementation is based |
648 | 648 |
/// on extensive use of priority queues and provides |
649 | 649 |
/// \f$O(nm\log n)\f$ time complexity. |
650 | 650 |
/// |
651 |
/// The maximum weighted matching problem is to find a subset of the |
|
652 |
/// edges in an undirected graph with maximum overall weight for which |
|
651 |
/// The maximum weighted matching problem is to find a subset of the |
|
652 |
/// edges in an undirected graph with maximum overall weight for which |
|
653 | 653 |
/// each node has at most one incident edge. |
654 | 654 |
/// It can be formulated with the following linear program. |
655 | 655 |
/// \f[ \sum_{e \in \delta(u)}x_e \le 1 \quad \forall u\in V\f] |
656 | 656 |
/** \f[ \sum_{e \in \gamma(B)}x_e \le \frac{\vert B \vert - 1}{2} |
... | ... |
@@ -672,18 +672,18 @@ |
672 | 672 |
/// \f[z_B \ge 0 \quad \forall B \in \mathcal{O}\f] |
673 | 673 |
/** \f[\min \sum_{u \in V}y_u + \sum_{B \in \mathcal{O}} |
674 | 674 |
\frac{\vert B \vert - 1}{2}z_B\f] */ |
675 | 675 |
/// |
676 |
/// The algorithm can be executed with the run() function. |
|
676 |
/// The algorithm can be executed with the run() function. |
|
677 | 677 |
/// After it the matching (the primal solution) and the dual solution |
678 |
/// can be obtained using the query functions and the |
|
679 |
/// \ref MaxWeightedMatching::BlossomIt "BlossomIt" nested class, |
|
680 |
/// |
|
678 |
/// can be obtained using the query functions and the |
|
679 |
/// \ref MaxWeightedMatching::BlossomIt "BlossomIt" nested class, |
|
680 |
/// which is able to iterate on the nodes of a blossom. |
|
681 | 681 |
/// If the value type is integer, then the dual solution is multiplied |
682 | 682 |
/// by \ref MaxWeightedMatching::dualScale "4". |
683 | 683 |
/// |
684 | 684 |
/// \tparam GR The undirected graph type the algorithm runs on. |
685 |
/// \tparam WM The type edge weight map. The default type is |
|
685 |
/// \tparam WM The type edge weight map. The default type is |
|
686 | 686 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<int>". |
687 | 687 |
#ifdef DOXYGEN |
688 | 688 |
template <typename GR, typename WM> |
689 | 689 |
#else |
... | ... |
@@ -1719,9 +1719,9 @@ |
1719 | 1719 |
for (int i = 0; i < _blossom_num; ++i) { |
1720 | 1720 |
(*_delta2_index)[i] = _delta2->PRE_HEAP; |
1721 | 1721 |
(*_delta4_index)[i] = _delta4->PRE_HEAP; |
1722 | 1722 |
} |
1723 |
|
|
1723 |
|
|
1724 | 1724 |
_delta1->clear(); |
1725 | 1725 |
_delta2->clear(); |
1726 | 1726 |
_delta3->clear(); |
1727 | 1727 |
_delta4->clear(); |
... | ... |
@@ -1867,9 +1867,9 @@ |
1867 | 1867 |
|
1868 | 1868 |
/// @} |
1869 | 1869 |
|
1870 | 1870 |
/// \name Primal Solution |
1871 |
/// Functions to get the primal solution, i.e. the maximum weighted |
|
1871 |
/// Functions to get the primal solution, i.e. the maximum weighted |
|
1872 | 1872 |
/// matching.\n |
1873 | 1873 |
/// Either \ref run() or \ref start() function should be called before |
1874 | 1874 |
/// using them. |
1875 | 1875 |
|
... | ... |
@@ -1906,9 +1906,9 @@ |
1906 | 1906 |
} |
1907 | 1907 |
|
1908 | 1908 |
/// \brief Return \c true if the given edge is in the matching. |
1909 | 1909 |
/// |
1910 |
/// This function returns \c true if the given edge is in the found |
|
1910 |
/// This function returns \c true if the given edge is in the found |
|
1911 | 1911 |
/// matching. |
1912 | 1912 |
/// |
1913 | 1913 |
/// \pre Either run() or start() must be called before using this function. |
1914 | 1914 |
bool matching(const Edge& edge) const { |
... | ... |
@@ -1917,9 +1917,9 @@ |
1917 | 1917 |
|
1918 | 1918 |
/// \brief Return the matching arc (or edge) incident to the given node. |
1919 | 1919 |
/// |
1920 | 1920 |
/// This function returns the matching arc (or edge) incident to the |
1921 |
/// given node in the found matching or \c INVALID if the node is |
|
1921 |
/// given node in the found matching or \c INVALID if the node is |
|
1922 | 1922 |
/// not covered by the matching. |
1923 | 1923 |
/// |
1924 | 1924 |
/// \pre Either run() or start() must be called before using this function. |
1925 | 1925 |
Arc matching(const Node& node) const { |
... | ... |
@@ -1935,9 +1935,9 @@ |
1935 | 1935 |
} |
1936 | 1936 |
|
1937 | 1937 |
/// \brief Return the mate of the given node. |
1938 | 1938 |
/// |
1939 |
/// This function returns the mate of the given node in the found |
|
1939 |
/// This function returns the mate of the given node in the found |
|
1940 | 1940 |
/// matching or \c INVALID if the node is not covered by the matching. |
1941 | 1941 |
/// |
1942 | 1942 |
/// \pre Either run() or start() must be called before using this function. |
1943 | 1943 |
Node mate(const Node& node) const { |
... | ... |
@@ -1955,10 +1955,10 @@ |
1955 | 1955 |
/// @{ |
1956 | 1956 |
|
1957 | 1957 |
/// \brief Return the value of the dual solution. |
1958 | 1958 |
/// |
1959 |
/// This function returns the value of the dual solution. |
|
1960 |
/// It should be equal to the primal value scaled by \ref dualScale |
|
1959 |
/// This function returns the value of the dual solution. |
|
1960 |
/// It should be equal to the primal value scaled by \ref dualScale |
|
1961 | 1961 |
/// "dual scale". |
1962 | 1962 |
/// |
1963 | 1963 |
/// \pre Either run() or start() must be called before using this function. |
1964 | 1964 |
Value dualValue() const { |
... | ... |
@@ -2011,21 +2011,21 @@ |
2011 | 2011 |
} |
2012 | 2012 |
|
2013 | 2013 |
/// \brief Iterator for obtaining the nodes of a blossom. |
2014 | 2014 |
/// |
2015 |
/// This class provides an iterator for obtaining the nodes of the |
|
2015 |
/// This class provides an iterator for obtaining the nodes of the |
|
2016 | 2016 |
/// given blossom. It lists a subset of the nodes. |
2017 |
/// Before using this iterator, you must allocate a |
|
2017 |
/// Before using this iterator, you must allocate a |
|
2018 | 2018 |
/// MaxWeightedMatching class and execute it. |
2019 | 2019 |
class BlossomIt { |
2020 | 2020 |
public: |
2021 | 2021 |
|
2022 | 2022 |
/// \brief Constructor. |
2023 | 2023 |
/// |
2024 | 2024 |
/// Constructor to get the nodes of the given variable. |
2025 | 2025 |
/// |
2026 |
/// \pre Either \ref MaxWeightedMatching::run() "algorithm.run()" or |
|
2027 |
/// \ref MaxWeightedMatching::start() "algorithm.start()" must be |
|
2026 |
/// \pre Either \ref MaxWeightedMatching::run() "algorithm.run()" or |
|
2027 |
/// \ref MaxWeightedMatching::start() "algorithm.start()" must be |
|
2028 | 2028 |
/// called before initializing this iterator. |
2029 | 2029 |
BlossomIt(const MaxWeightedMatching& algorithm, int variable) |
2030 | 2030 |
: _algorithm(&algorithm) |
2031 | 2031 |
{ |
... | ... |
@@ -2076,10 +2076,10 @@ |
2076 | 2076 |
/// maximum weighted perfect matching algorithm. The implementation |
2077 | 2077 |
/// is based on extensive use of priority queues and provides |
2078 | 2078 |
/// \f$O(nm\log n)\f$ time complexity. |
2079 | 2079 |
/// |
2080 |
/// The maximum weighted perfect matching problem is to find a subset of |
|
2081 |
/// the edges in an undirected graph with maximum overall weight for which |
|
2080 |
/// The maximum weighted perfect matching problem is to find a subset of |
|
2081 |
/// the edges in an undirected graph with maximum overall weight for which |
|
2082 | 2082 |
/// each node has exactly one incident edge. |
2083 | 2083 |
/// It can be formulated with the following linear program. |
2084 | 2084 |
/// \f[ \sum_{e \in \delta(u)}x_e = 1 \quad \forall u\in V\f] |
2085 | 2085 |
/** \f[ \sum_{e \in \gamma(B)}x_e \le \frac{\vert B \vert - 1}{2} |
... | ... |
@@ -2100,18 +2100,18 @@ |
2100 | 2100 |
/// \f[z_B \ge 0 \quad \forall B \in \mathcal{O}\f] |
2101 | 2101 |
/** \f[\min \sum_{u \in V}y_u + \sum_{B \in \mathcal{O}} |
2102 | 2102 |
\frac{\vert B \vert - 1}{2}z_B\f] */ |
2103 | 2103 |
/// |
2104 |
/// The algorithm can be executed with the run() function. |
|
2104 |
/// The algorithm can be executed with the run() function. |
|
2105 | 2105 |
/// After it the matching (the primal solution) and the dual solution |
2106 |
/// can be obtained using the query functions and the |
|
2107 |
/// \ref MaxWeightedPerfectMatching::BlossomIt "BlossomIt" nested class, |
|
2108 |
/// |
|
2106 |
/// can be obtained using the query functions and the |
|
2107 |
/// \ref MaxWeightedPerfectMatching::BlossomIt "BlossomIt" nested class, |
|
2108 |
/// which is able to iterate on the nodes of a blossom. |
|
2109 | 2109 |
/// If the value type is integer, then the dual solution is multiplied |
2110 | 2110 |
/// by \ref MaxWeightedMatching::dualScale "4". |
2111 | 2111 |
/// |
2112 | 2112 |
/// \tparam GR The undirected graph type the algorithm runs on. |
2113 |
/// \tparam WM The type edge weight map. The default type is |
|
2113 |
/// \tparam WM The type edge weight map. The default type is |
|
2114 | 2114 |
/// \ref concepts::Graph::EdgeMap "GR::EdgeMap<int>". |
2115 | 2115 |
#ifdef DOXYGEN |
2116 | 2116 |
template <typename GR, typename WM> |
2117 | 2117 |
#else |
... | ... |
@@ -3114,9 +3114,9 @@ |
3114 | 3114 |
|
3115 | 3115 |
/// @} |
3116 | 3116 |
|
3117 | 3117 |
/// \name Primal Solution |
3118 |
/// Functions to get the primal solution, i.e. the maximum weighted |
|
3118 |
/// Functions to get the primal solution, i.e. the maximum weighted |
|
3119 | 3119 |
/// perfect matching.\n |
3120 | 3120 |
/// Either \ref run() or \ref start() function should be called before |
3121 | 3121 |
/// using them. |
3122 | 3122 |
|
... | ... |
@@ -3138,9 +3138,9 @@ |
3138 | 3138 |
} |
3139 | 3139 |
|
3140 | 3140 |
/// \brief Return \c true if the given edge is in the matching. |
3141 | 3141 |
/// |
3142 |
/// This function returns \c true if the given edge is in the found |
|
3142 |
/// This function returns \c true if the given edge is in the found |
|
3143 | 3143 |
/// matching. |
3144 | 3144 |
/// |
3145 | 3145 |
/// \pre Either run() or start() must be called before using this function. |
3146 | 3146 |
bool matching(const Edge& edge) const { |
... | ... |
@@ -3149,9 +3149,9 @@ |
3149 | 3149 |
|
3150 | 3150 |
/// \brief Return the matching arc (or edge) incident to the given node. |
3151 | 3151 |
/// |
3152 | 3152 |
/// This function returns the matching arc (or edge) incident to the |
3153 |
/// given node in the found matching or \c INVALID if the node is |
|
3153 |
/// given node in the found matching or \c INVALID if the node is |
|
3154 | 3154 |
/// not covered by the matching. |
3155 | 3155 |
/// |
3156 | 3156 |
/// \pre Either run() or start() must be called before using this function. |
3157 | 3157 |
Arc matching(const Node& node) const { |
... | ... |
@@ -3167,9 +3167,9 @@ |
3167 | 3167 |
} |
3168 | 3168 |
|
3169 | 3169 |
/// \brief Return the mate of the given node. |
3170 | 3170 |
/// |
3171 |
/// This function returns the mate of the given node in the found |
|
3171 |
/// This function returns the mate of the given node in the found |
|
3172 | 3172 |
/// matching or \c INVALID if the node is not covered by the matching. |
3173 | 3173 |
/// |
3174 | 3174 |
/// \pre Either run() or start() must be called before using this function. |
3175 | 3175 |
Node mate(const Node& node) const { |
... | ... |
@@ -3186,10 +3186,10 @@ |
3186 | 3186 |
/// @{ |
3187 | 3187 |
|
3188 | 3188 |
/// \brief Return the value of the dual solution. |
3189 | 3189 |
/// |
3190 |
/// This function returns the value of the dual solution. |
|
3191 |
/// It should be equal to the primal value scaled by \ref dualScale |
|
3190 |
/// This function returns the value of the dual solution. |
|
3191 |
/// It should be equal to the primal value scaled by \ref dualScale |
|
3192 | 3192 |
/// "dual scale". |
3193 | 3193 |
/// |
3194 | 3194 |
/// \pre Either run() or start() must be called before using this function. |
3195 | 3195 |
Value dualValue() const { |
... | ... |
@@ -3242,21 +3242,21 @@ |
3242 | 3242 |
} |
3243 | 3243 |
|
3244 | 3244 |
/// \brief Iterator for obtaining the nodes of a blossom. |
3245 | 3245 |
/// |
3246 |
/// This class provides an iterator for obtaining the nodes of the |
|
3246 |
/// This class provides an iterator for obtaining the nodes of the |
|
3247 | 3247 |
/// given blossom. It lists a subset of the nodes. |
3248 |
/// Before using this iterator, you must allocate a |
|
3248 |
/// Before using this iterator, you must allocate a |
|
3249 | 3249 |
/// MaxWeightedPerfectMatching class and execute it. |
3250 | 3250 |
class BlossomIt { |
3251 | 3251 |
public: |
3252 | 3252 |
|
3253 | 3253 |
/// \brief Constructor. |
3254 | 3254 |
/// |
3255 | 3255 |
/// Constructor to get the nodes of the given variable. |
3256 | 3256 |
/// |
3257 |
/// \pre Either \ref MaxWeightedPerfectMatching::run() "algorithm.run()" |
|
3258 |
/// or \ref MaxWeightedPerfectMatching::start() "algorithm.start()" |
|
3257 |
/// \pre Either \ref MaxWeightedPerfectMatching::run() "algorithm.run()" |
|
3258 |
/// or \ref MaxWeightedPerfectMatching::start() "algorithm.start()" |
|
3259 | 3259 |
/// must be called before initializing this iterator. |
3260 | 3260 |
BlossomIt(const MaxWeightedPerfectMatching& algorithm, int variable) |
3261 | 3261 |
: _algorithm(&algorithm) |
3262 | 3262 |
{ |
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 |
... | ... |
@@ -55,9 +55,9 @@ |
55 | 55 |
/// 1/sqrt(2) |
56 | 56 |
const long double SQRT1_2 = 0.7071067811865475244008443621048490L; |
57 | 57 |
|
58 | 58 |
///Check whether the parameter is NaN or not |
59 |
|
|
59 |
|
|
60 | 60 |
///This function checks whether the parameter is NaN or not. |
61 | 61 |
///Is should be equivalent with std::isnan(), but it is not |
62 | 62 |
///provided by all compilers. |
63 | 63 |
inline bool isNaN(double v) |
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 |
... | ... |
@@ -126,10 +126,10 @@ |
126 | 126 |
#endif |
127 | 127 |
class MinCostArborescence { |
128 | 128 |
public: |
129 | 129 |
|
130 |
/// \brief The \ref MinCostArborescenceDefaultTraits "traits class" |
|
131 |
/// of the algorithm. |
|
130 |
/// \brief The \ref MinCostArborescenceDefaultTraits "traits class" |
|
131 |
/// of the algorithm. |
|
132 | 132 |
typedef TR Traits; |
133 | 133 |
/// The type of the underlying digraph. |
134 | 134 |
typedef typename Traits::Digraph Digraph; |
135 | 135 |
/// The type of the map that stores the arc costs. |
... | ... |
@@ -434,9 +434,9 @@ |
434 | 434 |
/// setting \c PredMap type |
435 | 435 |
/// |
436 | 436 |
/// \ref named-templ-param "Named parameter" for setting |
437 | 437 |
/// \c PredMap type. |
438 |
/// It must meet the \ref concepts::WriteMap "WriteMap" concept, |
|
438 |
/// It must meet the \ref concepts::WriteMap "WriteMap" concept, |
|
439 | 439 |
/// and its value type must be the \c Arc type of the digraph. |
440 | 440 |
template <class T> |
441 | 441 |
struct SetPredMap |
442 | 442 |
: public MinCostArborescence<Digraph, CostMap, SetPredMapTraits<T> > { |
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 |
... | ... |
@@ -94,9 +94,9 @@ |
94 | 94 |
/// there is a directed cycle having negative total cost and |
95 | 95 |
/// infinite upper bound. |
96 | 96 |
UNBOUNDED |
97 | 97 |
}; |
98 |
|
|
98 |
|
|
99 | 99 |
/// \brief Constants for selecting the type of the supply constraints. |
100 | 100 |
/// |
101 | 101 |
/// Enum type containing constants for selecting the supply type, |
102 | 102 |
/// i.e. the direction of the inequalities in the supply/demand |
... | ... |
@@ -112,9 +112,9 @@ |
112 | 112 |
/// This option means that there are <em>"less or equal"</em> |
113 | 113 |
/// supply/demand constraints in the definition of the problem. |
114 | 114 |
LEQ |
115 | 115 |
}; |
116 |
|
|
116 |
|
|
117 | 117 |
/// \brief Constants for selecting the pivot rule. |
118 | 118 |
/// |
119 | 119 |
/// Enum type containing constants for selecting the pivot rule for |
120 | 120 |
/// the \ref run() function. |
... | ... |
@@ -155,9 +155,9 @@ |
155 | 155 |
/// It keeps only the several best eligible arcs from the former |
156 | 156 |
/// candidate list and extends this list in every iteration. |
157 | 157 |
ALTERING_LIST |
158 | 158 |
}; |
159 |
|
|
159 |
|
|
160 | 160 |
private: |
161 | 161 |
|
162 | 162 |
TEMPLATE_DIGRAPH_TYPEDEFS(GR); |
163 | 163 |
|
... | ... |
@@ -222,9 +222,9 @@ |
222 | 222 |
int stem, par_stem, new_stem; |
223 | 223 |
Value delta; |
224 | 224 |
|
225 | 225 |
public: |
226 |
|
|
226 |
|
|
227 | 227 |
/// \brief Constant for infinite upper bounds (capacities). |
228 | 228 |
/// |
229 | 229 |
/// Constant for infinite upper bounds (capacities). |
230 | 230 |
/// It is \c std::numeric_limits<Value>::infinity() if available, |
... | ... |
@@ -643,9 +643,9 @@ |
643 | 643 |
LEMON_ASSERT(std::numeric_limits<Value>::is_signed, |
644 | 644 |
"The flow type of NetworkSimplex must be signed"); |
645 | 645 |
LEMON_ASSERT(std::numeric_limits<Cost>::is_signed, |
646 | 646 |
"The cost type of NetworkSimplex must be signed"); |
647 |
|
|
647 |
|
|
648 | 648 |
// Resize vectors |
649 | 649 |
_node_num = countNodes(_graph); |
650 | 650 |
_arc_num = countArcs(_graph); |
651 | 651 |
int all_node_num = _node_num + 1; |
... | ... |
@@ -683,9 +683,9 @@ |
683 | 683 |
_source[i] = _node_id[_graph.source(a)]; |
684 | 684 |
_target[i] = _node_id[_graph.target(a)]; |
685 | 685 |
if ((i += k) >= _arc_num) i = (i % k) + 1; |
686 | 686 |
} |
687 |
|
|
687 |
|
|
688 | 688 |
// Initialize maps |
689 | 689 |
for (int i = 0; i != _node_num; ++i) { |
690 | 690 |
_supply[i] = 0; |
691 | 691 |
} |
... | ... |
@@ -808,9 +808,9 @@ |
808 | 808 |
_supply[_node_id[s]] = k; |
809 | 809 |
_supply[_node_id[t]] = -k; |
810 | 810 |
return *this; |
811 | 811 |
} |
812 |
|
|
812 |
|
|
813 | 813 |
/// \brief Set the type of the supply constraints. |
814 | 814 |
/// |
815 | 815 |
/// This function sets the type of the supply/demand constraints. |
816 | 816 |
/// If it is not used before calling \ref run(), the \ref GEQ supply |
... | ... |
@@ -834,9 +834,9 @@ |
834 | 834 |
/// \brief Run the algorithm. |
835 | 835 |
/// |
836 | 836 |
/// This function runs the algorithm. |
837 | 837 |
/// The paramters can be specified using functions \ref lowerMap(), |
838 |
/// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply(), |
|
838 |
/// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply(), |
|
839 | 839 |
/// \ref supplyType(). |
840 | 840 |
/// For example, |
841 | 841 |
/// \code |
842 | 842 |
/// NetworkSimplex<ListDigraph> ns(graph); |
... | ... |
@@ -1053,9 +1053,9 @@ |
1053 | 1053 |
for (int i = 0; i != _arc_num; ++i) { |
1054 | 1054 |
_flow[i] = 0; |
1055 | 1055 |
_state[i] = STATE_LOWER; |
1056 | 1056 |
} |
1057 |
|
|
1057 |
|
|
1058 | 1058 |
// Set data for the artificial root node |
1059 | 1059 |
_root = _node_num; |
1060 | 1060 |
_parent[_root] = -1; |
1061 | 1061 |
_pred[_root] = -1; |
... | ... |
@@ -1227,9 +1227,9 @@ |
1227 | 1227 |
} |
1228 | 1228 |
// Search the cycle along the path form the second node to the root |
1229 | 1229 |
for (int u = second; u != join; u = _parent[u]) { |
1230 | 1230 |
e = _pred[u]; |
1231 |
d = _forward[u] ? |
|
1231 |
d = _forward[u] ? |
|
1232 | 1232 |
(_cap[e] == INF ? INF : _cap[e] - _flow[e]) : _flow[e]; |
1233 | 1233 |
if (d <= delta) { |
1234 | 1234 |
delta = d; |
1235 | 1235 |
u_out = u; |
... | ... |
@@ -1434,9 +1434,9 @@ |
1434 | 1434 |
updateTreeStructure(); |
1435 | 1435 |
updatePotential(); |
1436 | 1436 |
} |
1437 | 1437 |
} |
1438 |
|
|
1438 |
|
|
1439 | 1439 |
// Check feasibility |
1440 | 1440 |
for (int e = _search_arc_num; e != _all_arc_num; ++e) { |
1441 | 1441 |
if (_flow[e] != 0) return INFEASIBLE; |
1442 | 1442 |
} |
... | ... |
@@ -1451,9 +1451,9 @@ |
1451 | 1451 |
_supply[_target[i]] -= c; |
1452 | 1452 |
} |
1453 | 1453 |
} |
1454 | 1454 |
} |
1455 |
|
|
1455 |
|
|
1456 | 1456 |
// Shift potentials to meet the requirements of the GEQ/LEQ type |
1457 | 1457 |
// optimality conditions |
1458 | 1458 |
if (_sum_supply == 0) { |
1459 | 1459 |
if (_stype == GEQ) { |
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 |
... | ... |
@@ -965,22 +965,22 @@ |
965 | 965 |
to.buildRev(from); |
966 | 966 |
} |
967 | 967 |
}; |
968 | 968 |
|
969 |
|
|
969 |
|
|
970 | 970 |
template <typename From, typename To, |
971 | 971 |
bool revEnable = RevPathTagIndicator<From>::value> |
972 | 972 |
struct PathCopySelector { |
973 | 973 |
static void copy(const From& from, To& to) { |
974 | 974 |
PathCopySelectorForward<From, To>::copy(from, to); |
975 |
} |
|
975 |
} |
|
976 | 976 |
}; |
977 | 977 |
|
978 | 978 |
template <typename From, typename To> |
979 | 979 |
struct PathCopySelector<From, To, true> { |
980 | 980 |
static void copy(const From& from, To& to) { |
981 | 981 |
PathCopySelectorBackward<From, To>::copy(from, to); |
982 |
} |
|
982 |
} |
|
983 | 983 |
}; |
984 | 984 |
|
985 | 985 |
} |
986 | 986 |
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 |
... | ... |
@@ -535,12 +535,12 @@ |
535 | 535 |
_flow->set(e, 0); |
536 | 536 |
(*_excess)[v] += rem; |
537 | 537 |
} |
538 | 538 |
} |
539 |
for (NodeIt n(_graph); n != INVALID; ++n) |
|
539 |
for (NodeIt n(_graph); n != INVALID; ++n) |
|
540 | 540 |
if(n!=_source && n!=_target && _tolerance.positive((*_excess)[n])) |
541 | 541 |
_level->activate(n); |
542 |
|
|
542 |
|
|
543 | 543 |
return true; |
544 | 544 |
} |
545 | 545 |
|
546 | 546 |
/// \brief Starts the first phase of the preflow algorithm. |
... | ... |
@@ -566,9 +566,9 @@ |
566 | 566 |
n = _level->highestActive(); |
567 | 567 |
if (n == INVALID) goto first_phase_done; |
568 | 568 |
level = _level->highestActiveLevel(); |
569 | 569 |
--num; |
570 |
|
|
570 |
|
|
571 | 571 |
Value excess = (*_excess)[n]; |
572 | 572 |
int new_level = _level->maxLevel(); |
573 | 573 |
|
574 | 574 |
for (OutArcIt e(_graph, n); e != INVALID; ++e) { |
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 |
... | ... |
@@ -273,9 +273,9 @@ |
273 | 273 |
|
274 | 274 |
SoplexLp::SolveExitStatus SoplexLp::_solve() { |
275 | 275 |
|
276 | 276 |
_clear_temporals(); |
277 |
|
|
277 |
|
|
278 | 278 |
_applyMessageLevel(); |
279 | 279 |
|
280 | 280 |
soplex::SPxSolver::Status status = soplex->solve(); |
281 | 281 |
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 |
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 |
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 |
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 |
... | ... |
@@ -82,9 +82,9 @@ |
82 | 82 |
n = bfs_test.processNextNode(nm, n); |
83 | 83 |
n = const_bfs_test.nextNode(); |
84 | 84 |
b = const_bfs_test.emptyQueue(); |
85 | 85 |
i = const_bfs_test.queueSize(); |
86 |
|
|
86 |
|
|
87 | 87 |
bfs_test.start(); |
88 | 88 |
bfs_test.start(t); |
89 | 89 |
bfs_test.start(nm); |
90 | 90 |
|
... | ... |
@@ -103,14 +103,14 @@ |
103 | 103 |
::SetReachedMap<concepts::ReadWriteMap<Node,bool> > |
104 | 104 |
::SetStandardProcessedMap |
105 | 105 |
::SetProcessedMap<concepts::WriteMap<Node,bool> > |
106 | 106 |
::Create bfs_test(G); |
107 |
|
|
107 |
|
|
108 | 108 |
concepts::ReadWriteMap<Node,Arc> pred_map; |
109 | 109 |
concepts::ReadWriteMap<Node,int> dist_map; |
110 | 110 |
concepts::ReadWriteMap<Node,bool> reached_map; |
111 | 111 |
concepts::WriteMap<Node,bool> processed_map; |
112 |
|
|
112 |
|
|
113 | 113 |
bfs_test |
114 | 114 |
.predMap(pred_map) |
115 | 115 |
.distMap(dist_map) |
116 | 116 |
.reachedMap(reached_map) |
... | ... |
@@ -118,18 +118,18 @@ |
118 | 118 |
|
119 | 119 |
bfs_test.run(s); |
120 | 120 |
bfs_test.run(s,t); |
121 | 121 |
bfs_test.run(); |
122 |
|
|
122 |
|
|
123 | 123 |
bfs_test.init(); |
124 | 124 |
bfs_test.addSource(s); |
125 | 125 |
n = bfs_test.processNextNode(); |
126 | 126 |
n = bfs_test.processNextNode(t, b); |
127 | 127 |
n = bfs_test.processNextNode(nm, n); |
128 | 128 |
n = bfs_test.nextNode(); |
129 | 129 |
b = bfs_test.emptyQueue(); |
130 | 130 |
i = bfs_test.queueSize(); |
131 |
|
|
131 |
|
|
132 | 132 |
bfs_test.start(); |
133 | 133 |
bfs_test.start(t); |
134 | 134 |
bfs_test.start(nm); |
135 | 135 |
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 |
... | ... |
@@ -80,9 +80,9 @@ |
80 | 80 |
::SetStandardElevator<LinkedElev> |
81 | 81 |
::Create CirculationType; |
82 | 82 |
CirculationType circ_test(g, lcap, ucap, supply); |
83 | 83 |
const CirculationType& const_circ_test = circ_test; |
84 |
|
|
84 |
|
|
85 | 85 |
circ_test |
86 | 86 |
.lowerMap(lcap) |
87 | 87 |
.upperMap(ucap) |
88 | 88 |
.supplyMap(supply) |
... | ... |
@@ -96,9 +96,9 @@ |
96 | 96 |
v = const_circ_test.flow(a); |
97 | 97 |
const FlowMap& fm = const_circ_test.flowMap(); |
98 | 98 |
b = const_circ_test.barrier(n); |
99 | 99 |
const_circ_test.barrierMap(bar); |
100 |
|
|
100 |
|
|
101 | 101 |
ignore_unused_variable_warning(fm); |
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
template <class G, class LM, class UM, class DM> |
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 |
... | ... |
@@ -28,14 +28,14 @@ |
28 | 28 |
int main() |
29 | 29 |
{ |
30 | 30 |
typedef ListDigraph Digraph; |
31 | 31 |
typedef Undirector<Digraph> Graph; |
32 |
|
|
32 |
|
|
33 | 33 |
{ |
34 | 34 |
Digraph d; |
35 | 35 |
Digraph::NodeMap<int> order(d); |
36 | 36 |
Graph g(d); |
37 |
|
|
37 |
|
|
38 | 38 |
check(stronglyConnected(d), "The empty digraph is strongly connected"); |
39 | 39 |
check(countStronglyConnectedComponents(d) == 0, |
40 | 40 |
"The empty digraph has 0 strongly connected component"); |
41 | 41 |
check(connected(g), "The empty graph is connected"); |
... | ... |
@@ -47,9 +47,9 @@ |
47 | 47 |
"The empty graph has 0 bi-node-connected component"); |
48 | 48 |
check(biEdgeConnected(g), "The empty graph is bi-edge-connected"); |
49 | 49 |
check(countBiEdgeConnectedComponents(g) == 0, |
50 | 50 |
"The empty graph has 0 bi-edge-connected component"); |
51 |
|
|
51 |
|
|
52 | 52 |
check(dag(d), "The empty digraph is DAG."); |
53 | 53 |
check(checkedTopologicalSort(d, order), "The empty digraph is DAG."); |
54 | 54 |
check(loopFree(d), "The empty digraph is loop-free."); |
55 | 55 |
check(parallelFree(d), "The empty digraph is parallel-free."); |
... | ... |
@@ -81,9 +81,9 @@ |
81 | 81 |
"This graph has 0 bi-node-connected component"); |
82 | 82 |
check(biEdgeConnected(g), "This graph is bi-edge-connected"); |
83 | 83 |
check(countBiEdgeConnectedComponents(g) == 1, |
84 | 84 |
"This graph has 1 bi-edge-connected component"); |
85 |
|
|
85 |
|
|
86 | 86 |
check(dag(d), "This digraph is DAG."); |
87 | 87 |
check(checkedTopologicalSort(d, order), "This digraph is DAG."); |
88 | 88 |
check(loopFree(d), "This digraph is loop-free."); |
89 | 89 |
check(parallelFree(d), "This digraph is parallel-free."); |
... | ... |
@@ -100,16 +100,16 @@ |
100 | 100 |
{ |
101 | 101 |
Digraph d; |
102 | 102 |
Digraph::NodeMap<int> order(d); |
103 | 103 |
Graph g(d); |
104 |
|
|
104 |
|
|
105 | 105 |
Digraph::Node n1 = d.addNode(); |
106 | 106 |
Digraph::Node n2 = d.addNode(); |
107 | 107 |
Digraph::Node n3 = d.addNode(); |
108 | 108 |
Digraph::Node n4 = d.addNode(); |
109 | 109 |
Digraph::Node n5 = d.addNode(); |
110 | 110 |
Digraph::Node n6 = d.addNode(); |
111 |
|
|
111 |
|
|
112 | 112 |
d.addArc(n1, n3); |
113 | 113 |
d.addArc(n3, n2); |
114 | 114 |
d.addArc(n2, n1); |
115 | 115 |
d.addArc(n4, n2); |
... | ... |
@@ -135,25 +135,25 @@ |
135 | 135 |
check(!bipartite(g), "This graph is not bipartite."); |
136 | 136 |
check(loopFree(g), "This graph is loop-free."); |
137 | 137 |
check(!parallelFree(g), "This graph is not parallel-free."); |
138 | 138 |
check(!simpleGraph(g), "This graph is not simple."); |
139 |
|
|
139 |
|
|
140 | 140 |
d.addArc(n3, n3); |
141 |
|
|
141 |
|
|
142 | 142 |
check(!loopFree(d), "This digraph is not loop-free."); |
143 | 143 |
check(!loopFree(g), "This graph is not loop-free."); |
144 | 144 |
check(!simpleGraph(d), "This digraph is not simple."); |
145 |
|
|
145 |
|
|
146 | 146 |
d.addArc(n3, n2); |
147 |
|
|
147 |
|
|
148 | 148 |
check(!parallelFree(d), "This digraph is not parallel-free."); |
149 | 149 |
} |
150 |
|
|
150 |
|
|
151 | 151 |
{ |
152 | 152 |
Digraph d; |
153 | 153 |
Digraph::ArcMap<bool> cutarcs(d, false); |
154 | 154 |
Graph g(d); |
155 |
|
|
155 |
|
|
156 | 156 |
Digraph::Node n1 = d.addNode(); |
157 | 157 |
Digraph::Node n2 = d.addNode(); |
158 | 158 |
Digraph::Node n3 = d.addNode(); |
159 | 159 |
Digraph::Node n4 = d.addNode(); |
... | ... |
@@ -171,9 +171,9 @@ |
171 | 171 |
d.addArc(n2, n5); |
172 | 172 |
d.addArc(n1, n8); |
173 | 173 |
d.addArc(n6, n7); |
174 | 174 |
d.addArc(n7, n6); |
175 |
|
|
175 |
|
|
176 | 176 |
check(!stronglyConnected(d), "This digraph is not strongly connected"); |
177 | 177 |
check(countStronglyConnectedComponents(d) == 3, |
178 | 178 |
"This digraph has 3 strongly connected components"); |
179 | 179 |
Digraph::NodeMap<int> scomp1(d); |
... | ... |
@@ -234,9 +234,9 @@ |
234 | 234 |
// DAG example for topological sort from the book New Algorithms |
235 | 235 |
// (T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein) |
236 | 236 |
Digraph d; |
237 | 237 |
Digraph::NodeMap<int> order(d); |
238 |
|
|
238 |
|
|
239 | 239 |
Digraph::Node belt = d.addNode(); |
240 | 240 |
Digraph::Node trousers = d.addNode(); |
241 | 241 |
Digraph::Node necktie = d.addNode(); |
242 | 242 |
Digraph::Node coat = d.addNode(); |
... | ... |
@@ -254,9 +254,9 @@ |
254 | 254 |
d.addArc(belt, coat); |
255 | 255 |
d.addArc(shirt, belt); |
256 | 256 |
d.addArc(shirt, necktie); |
257 | 257 |
d.addArc(necktie, coat); |
258 |
|
|
258 |
|
|
259 | 259 |
check(dag(d), "This digraph is DAG."); |
260 | 260 |
topologicalSort(d, order); |
261 | 261 |
for (Digraph::ArcIt a(d); a != INVALID; ++a) { |
262 | 262 |
check(order[d.source(a)] < order[d.target(a)], |
... | ... |
@@ -266,9 +266,9 @@ |
266 | 266 |
|
267 | 267 |
{ |
268 | 268 |
ListGraph g; |
269 | 269 |
ListGraph::NodeMap<bool> map(g); |
270 |
|
|
270 |
|
|
271 | 271 |
ListGraph::Node n1 = g.addNode(); |
272 | 272 |
ListGraph::Node n2 = g.addNode(); |
273 | 273 |
ListGraph::Node n3 = g.addNode(); |
274 | 274 |
ListGraph::Node n4 = g.addNode(); |
... | ... |
@@ -282,12 +282,12 @@ |
282 | 282 |
g.addEdge(n3, n6); |
283 | 283 |
g.addEdge(n4, n6); |
284 | 284 |
g.addEdge(n4, n7); |
285 | 285 |
g.addEdge(n5, n7); |
286 |
|
|
286 |
|
|
287 | 287 |
check(bipartite(g), "This graph is bipartite"); |
288 | 288 |
check(bipartitePartitions(g, map), "This graph is bipartite"); |
289 |
|
|
289 |
|
|
290 | 290 |
check(map[n1] == map[n2] && map[n1] == map[n6] && map[n1] == map[n7], |
291 | 291 |
"Wrong bipartitePartitions()"); |
292 | 292 |
check(map[n3] == map[n4] && map[n3] == map[n5], |
293 | 293 |
"Wrong bipartitePartitions()"); |
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 |
... | ... |
@@ -85,9 +85,9 @@ |
85 | 85 |
e = dfs_test.processNextArc(); |
86 | 86 |
e = const_dfs_test.nextArc(); |
87 | 87 |
b = const_dfs_test.emptyQueue(); |
88 | 88 |
i = const_dfs_test.queueSize(); |
89 |
|
|
89 |
|
|
90 | 90 |
dfs_test.start(); |
91 | 91 |
dfs_test.start(t); |
92 | 92 |
dfs_test.start(am); |
93 | 93 |
|
... | ... |
@@ -111,9 +111,9 @@ |
111 | 111 |
concepts::ReadWriteMap<Node,Arc> pred_map; |
112 | 112 |
concepts::ReadWriteMap<Node,int> dist_map; |
113 | 113 |
concepts::ReadWriteMap<Node,bool> reached_map; |
114 | 114 |
concepts::WriteMap<Node,bool> processed_map; |
115 |
|
|
115 |
|
|
116 | 116 |
dfs_test |
117 | 117 |
.predMap(pred_map) |
118 | 118 |
.distMap(dist_map) |
119 | 119 |
.reachedMap(reached_map) |
... | ... |
@@ -128,9 +128,9 @@ |
128 | 128 |
e = dfs_test.processNextArc(); |
129 | 129 |
e = dfs_test.nextArc(); |
130 | 130 |
b = dfs_test.emptyQueue(); |
131 | 131 |
i = dfs_test.queueSize(); |
132 |
|
|
132 |
|
|
133 | 133 |
dfs_test.start(); |
134 | 134 |
dfs_test.start(t); |
135 | 135 |
dfs_test.start(am); |
136 | 136 |
|
... | ... |
@@ -218,9 +218,9 @@ |
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 |
} |
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 |
... | ... |
@@ -84,9 +84,9 @@ |
84 | 84 |
n = dijkstra_test.processNextNode(); |
85 | 85 |
n = const_dijkstra_test.nextNode(); |
86 | 86 |
b = const_dijkstra_test.emptyQueue(); |
87 | 87 |
i = const_dijkstra_test.queueSize(); |
88 |
|
|
88 |
|
|
89 | 89 |
dijkstra_test.start(); |
90 | 90 |
dijkstra_test.start(t); |
91 | 91 |
dijkstra_test.start(nm); |
92 | 92 |
|
... | ... |
@@ -108,9 +108,9 @@ |
108 | 108 |
::SetProcessedMap<concepts::WriteMap<Node,bool> > |
109 | 109 |
::SetOperationTraits<DijkstraDefaultOperationTraits<VType> > |
110 | 110 |
::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > |
111 | 111 |
::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > > |
112 |
::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, |
|
112 |
::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, |
|
113 | 113 |
concepts::ReadWriteMap<Node,int> > |
114 | 114 |
::Create dijkstra_test(G,length); |
115 | 115 |
|
116 | 116 |
LengthMap length_map; |
... | ... |
@@ -118,9 +118,9 @@ |
118 | 118 |
concepts::ReadWriteMap<Node,VType> dist_map; |
119 | 119 |
concepts::WriteMap<Node,bool> processed_map; |
120 | 120 |
concepts::ReadWriteMap<Node,int> heap_cross_ref; |
121 | 121 |
BinHeap<VType, concepts::ReadWriteMap<Node,int> > heap(heap_cross_ref); |
122 |
|
|
122 |
|
|
123 | 123 |
dijkstra_test |
124 | 124 |
.lengthMap(length_map) |
125 | 125 |
.predMap(pred_map) |
126 | 126 |
.distMap(dist_map) |
... | ... |
@@ -135,9 +135,9 @@ |
135 | 135 |
n = dijkstra_test.processNextNode(); |
136 | 136 |
n = dijkstra_test.nextNode(); |
137 | 137 |
b = dijkstra_test.emptyQueue(); |
138 | 138 |
i = dijkstra_test.queueSize(); |
139 |
|
|
139 |
|
|
140 | 140 |
dijkstra_test.start(); |
141 | 141 |
dijkstra_test.start(t); |
142 | 142 |
dijkstra_test.start(nm); |
143 | 143 |
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 |
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 |
... | ... |
@@ -84,13 +84,13 @@ |
84 | 84 |
int main() |
85 | 85 |
{ |
86 | 86 |
typedef ListDigraph Digraph; |
87 | 87 |
typedef Undirector<Digraph> Graph; |
88 |
|
|
88 |
|
|
89 | 89 |
{ |
90 | 90 |
Digraph d; |
91 | 91 |
Graph g(d); |
92 |
|
|
92 |
|
|
93 | 93 |
checkDiEulerIt(d); |
94 | 94 |
checkDiEulerIt(g); |
95 | 95 |
checkEulerIt(g); |
96 | 96 |
|
... | ... |
@@ -127,9 +127,9 @@ |
127 | 127 |
Graph g(d); |
128 | 128 |
Digraph::Node n1 = d.addNode(); |
129 | 129 |
Digraph::Node n2 = d.addNode(); |
130 | 130 |
Digraph::Node n3 = d.addNode(); |
131 |
|
|
131 |
|
|
132 | 132 |
d.addArc(n1, n2); |
133 | 133 |
d.addArc(n2, n1); |
134 | 134 |
d.addArc(n2, n3); |
135 | 135 |
d.addArc(n3, n2); |
... | ... |
@@ -152,9 +152,9 @@ |
152 | 152 |
Digraph::Node n3 = d.addNode(); |
153 | 153 |
Digraph::Node n4 = d.addNode(); |
154 | 154 |
Digraph::Node n5 = d.addNode(); |
155 | 155 |
Digraph::Node n6 = d.addNode(); |
156 |
|
|
156 |
|
|
157 | 157 |
d.addArc(n1, n2); |
158 | 158 |
d.addArc(n2, n4); |
159 | 159 |
d.addArc(n1, n3); |
160 | 160 |
d.addArc(n3, n4); |
... | ... |
@@ -188,9 +188,9 @@ |
188 | 188 |
Digraph::Node n2 = d.addNode(); |
189 | 189 |
Digraph::Node n3 = d.addNode(); |
190 | 190 |
Digraph::Node n4 = d.addNode(); |
191 | 191 |
Digraph::Node n5 = d.addNode(); |
192 |
|
|
192 |
|
|
193 | 193 |
d.addArc(n1, n2); |
194 | 194 |
d.addArc(n2, n3); |
195 | 195 |
d.addArc(n3, n1); |
196 | 196 |
|
... | ... |
@@ -210,9 +210,9 @@ |
210 | 210 |
Graph g(d); |
211 | 211 |
Digraph::Node n1 = d.addNode(); |
212 | 212 |
Digraph::Node n2 = d.addNode(); |
213 | 213 |
Digraph::Node n3 = d.addNode(); |
214 |
|
|
214 |
|
|
215 | 215 |
d.addArc(n1, n2); |
216 | 216 |
d.addArc(n2, n3); |
217 | 217 |
|
218 | 218 |
check(!eulerian(d), "This graph is not Eulerian"); |
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-2011 |
|
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 |
|
|
1 | 19 |
#include <iostream> |
2 | 20 |
|
3 | 21 |
#include "test_tools.h" |
4 | 22 |
#include <lemon/smart_graph.h> |
... | ... |
@@ -32,9 +50,9 @@ |
32 | 50 |
"4 2 7 1\n" |
33 | 51 |
"@attributes\n" |
34 | 52 |
"source 0\n" |
35 | 53 |
"target 3\n"; |
36 |
|
|
54 |
|
|
37 | 55 |
void checkGomoryHuCompile() |
38 | 56 |
{ |
39 | 57 |
typedef int Value; |
40 | 58 |
typedef concepts::Graph Graph; |
... | ... |
@@ -68,9 +86,9 @@ |
68 | 86 |
typedef Graph::EdgeMap<int> IntEdgeMap; |
69 | 87 |
typedef Graph::NodeMap<bool> BoolNodeMap; |
70 | 88 |
|
71 | 89 |
int cutValue(const Graph& graph, const BoolNodeMap& cut, |
72 |
|
|
90 |
const IntEdgeMap& capacity) { |
|
73 | 91 |
|
74 | 92 |
int sum = 0; |
75 | 93 |
for (EdgeIt e(graph); e != INVALID; ++e) { |
76 | 94 |
Node s = graph.u(e); |
... | ... |
@@ -106,9 +124,9 @@ |
106 | 124 |
check(pf.flowValue() == cutValue(graph, cm, capacity), "Wrong cut 3"); |
107 | 125 |
|
108 | 126 |
int sum=0; |
109 | 127 |
for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a) |
110 |
sum+=capacity[a]; |
|
128 |
sum+=capacity[a]; |
|
111 | 129 |
check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt"); |
112 | 130 |
|
113 | 131 |
sum=0; |
114 | 132 |
for(GomoryHu<Graph>::MinCutNodeIt n(ght, u, v,true);n!=INVALID;++n) |
... | ... |
@@ -117,7 +135,7 @@ |
117 | 135 |
sum++; |
118 | 136 |
check(sum == countNodes(graph), "Problem with MinCutNodeIt"); |
119 | 137 |
} |
120 | 138 |
} |
121 |
|
|
139 |
|
|
122 | 140 |
return 0; |
123 | 141 |
} |
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 |
... | ... |
@@ -69,9 +69,9 @@ |
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) { |
... | ... |
@@ -97,9 +97,9 @@ |
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 |
|
... | ... |
@@ -199,9 +199,9 @@ |
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 |
} |
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 |
... | ... |
@@ -82,9 +82,9 @@ |
82 | 82 |
v = const_ho_test.minCutMap(cut); |
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
template <typename Graph, typename CapMap, typename CutMap> |
86 |
typename CapMap::Value |
|
86 |
typename CapMap::Value |
|
87 | 87 |
cutValue(const Graph& graph, const CapMap& cap, const CutMap& cut) |
88 | 88 |
{ |
89 | 89 |
typename CapMap::Value sum = 0; |
90 | 90 |
for (typename Graph::ArcIt a(graph); a != INVALID; ++a) { |
... | ... |
@@ -109,9 +109,9 @@ |
109 | 109 |
{ |
110 | 110 |
HaoOrlin<SmartDigraph> ho(graph, cap1); |
111 | 111 |
ho.run(); |
112 | 112 |
ho.minCutMap(cut); |
113 |
|
|
113 |
|
|
114 | 114 |
check(ho.minCutValue() == 1, "Wrong cut value"); |
115 | 115 |
check(ho.minCutValue() == cutValue(graph, cap1, cut), "Wrong cut value"); |
116 | 116 |
} |
117 | 117 |
{ |
... | ... |
@@ -125,37 +125,37 @@ |
125 | 125 |
{ |
126 | 126 |
HaoOrlin<SmartDigraph> ho(graph, cap3); |
127 | 127 |
ho.run(); |
128 | 128 |
ho.minCutMap(cut); |
129 |
|
|
129 |
|
|
130 | 130 |
check(ho.minCutValue() == 1, "Wrong cut value"); |
131 | 131 |
check(ho.minCutValue() == cutValue(graph, cap3, cut), "Wrong cut value"); |
132 | 132 |
} |
133 |
|
|
133 |
|
|
134 | 134 |
typedef Undirector<SmartDigraph> UGraph; |
135 | 135 |
UGraph ugraph(graph); |
136 |
|
|
136 |
|
|
137 | 137 |
{ |
138 | 138 |
HaoOrlin<UGraph, SmartDigraph::ArcMap<int> > ho(ugraph, cap1); |
139 | 139 |
ho.run(); |
140 | 140 |
ho.minCutMap(cut); |
141 |
|
|
141 |
|
|
142 | 142 |
check(ho.minCutValue() == 2, "Wrong cut value"); |
143 | 143 |
check(ho.minCutValue() == cutValue(ugraph, cap1, cut), "Wrong cut value"); |
144 | 144 |
} |
145 | 145 |
{ |
146 | 146 |
HaoOrlin<UGraph, SmartDigraph::ArcMap<int> > ho(ugraph, cap2); |
147 | 147 |
ho.run(); |
148 | 148 |
ho.minCutMap(cut); |
149 |
|
|
149 |
|
|
150 | 150 |
check(ho.minCutValue() == 5, "Wrong cut value"); |
151 | 151 |
check(ho.minCutValue() == cutValue(ugraph, cap2, cut), "Wrong cut value"); |
152 | 152 |
} |
153 | 153 |
{ |
154 | 154 |
HaoOrlin<UGraph, SmartDigraph::ArcMap<int> > ho(ugraph, cap3); |
155 | 155 |
ho.run(); |
156 | 156 |
ho.minCutMap(cut); |
157 |
|
|
157 |
|
|
158 | 158 |
check(ho.minCutValue() == 5, "Wrong cut value"); |
159 | 159 |
check(ho.minCutValue() == cutValue(ugraph, cap3, cut), "Wrong cut value"); |
160 | 160 |
} |
161 | 161 |
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 |
... | ... |
@@ -62,12 +62,12 @@ |
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). |
... | ... |
@@ -92,9 +92,9 @@ |
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"); |
... | ... |
@@ -109,16 +109,16 @@ |
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"); |
... | ... |
@@ -138,9 +138,9 @@ |
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). |
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 |
... | ... |
@@ -69,10 +69,12 @@ |
69 | 69 |
checkConcept<WriteMap<A,B>, WriteMap<A,B> >(); |
70 | 70 |
checkConcept<WriteMap<A,C>, WriteMap<A,C> >(); |
71 | 71 |
checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >(); |
72 | 72 |
checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >(); |
73 |
checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >(); |
|
74 |
checkConcept<ReferenceMap<A,C,C&,const C&>, ReferenceMap<A,C,C&,const C&> >(); |
|
73 |
checkConcept<ReferenceMap<A,B,B&,const B&>, |
|
74 |
ReferenceMap<A,B,B&,const B&> >(); |
|
75 |
checkConcept<ReferenceMap<A,C,C&,const C&>, |
|
76 |
ReferenceMap<A,C,C&,const C&> >(); |
|
75 | 77 |
|
76 | 78 |
// NullMap |
77 | 79 |
{ |
78 | 80 |
checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >(); |
... | ... |
@@ -199,9 +201,10 @@ |
199 | 201 |
FunctorToMap<F> map2 = FunctorToMap<F>(F()); |
200 | 202 |
B b = functorToMap(F())[A()]; |
201 | 203 |
|
202 | 204 |
checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >(); |
203 |
MapToFunctor<ReadMap<A,B> > map = |
|
205 |
MapToFunctor<ReadMap<A,B> > map = |
|
206 |
MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>()); |
|
204 | 207 |
|
205 | 208 |
check(functorToMap(&func)[A()] == 3, |
206 | 209 |
"Something is wrong with FunctorToMap"); |
207 | 210 |
check(mapToFunctor(constMap<A,int>(2))(A()) == 2, |
... | ... |
@@ -348,26 +351,26 @@ |
348 | 351 |
for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin(); |
349 | 352 |
it != map2.end(); ++it ) |
350 | 353 |
check(v1[i++] == *it, "Something is wrong with LoggerBoolMap"); |
351 | 354 |
} |
352 |
|
|
355 |
|
|
353 | 356 |
// CrossRefMap |
354 | 357 |
{ |
355 | 358 |
typedef ListDigraph Graph; |
356 | 359 |
DIGRAPH_TYPEDEFS(Graph); |
357 | 360 |
|
358 | 361 |
checkConcept<ReadWriteMap<Node, int>, |
359 | 362 |
CrossRefMap<Graph, Node, int> >(); |
360 |
|
|
363 |
|
|
361 | 364 |
Graph gr; |
362 | 365 |
typedef CrossRefMap<Graph, Node, char> CRMap; |
363 | 366 |
typedef CRMap::ValueIterator ValueIt; |
364 | 367 |
CRMap map(gr); |
365 |
|
|
368 |
|
|
366 | 369 |
Node n0 = gr.addNode(); |
367 | 370 |
Node n1 = gr.addNode(); |
368 | 371 |
Node n2 = gr.addNode(); |
369 |
|
|
372 |
|
|
370 | 373 |
map.set(n0, 'A'); |
371 | 374 |
map.set(n1, 'B'); |
372 | 375 |
map.set(n2, 'C'); |
373 | 376 |
map.set(n2, 'A'); |
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 |
... | ... |
@@ -133,18 +133,18 @@ |
133 | 133 |
mat_test.matchingInit(mat); |
134 | 134 |
mat_test.startSparse(); |
135 | 135 |
mat_test.startDense(); |
136 | 136 |
mat_test.run(); |
137 |
|
|
137 |
|
|
138 | 138 |
const_mat_test.matchingSize(); |
139 | 139 |
const_mat_test.matching(e); |
140 | 140 |
const_mat_test.matching(n); |
141 | 141 |
const MaxMatching<Graph>::MatchingMap& mmap = |
142 | 142 |
const_mat_test.matchingMap(); |
143 | 143 |
e = mmap[n]; |
144 | 144 |
const_mat_test.mate(n); |
145 | 145 |
|
146 |
MaxMatching<Graph>::Status stat = |
|
146 |
MaxMatching<Graph>::Status stat = |
|
147 | 147 |
const_mat_test.status(n); |
148 | 148 |
const MaxMatching<Graph>::StatusMap& smap = |
149 | 149 |
const_mat_test.statusMap(); |
150 | 150 |
stat = smap[n]; |
... | ... |
@@ -169,18 +169,18 @@ |
169 | 169 |
|
170 | 170 |
mat_test.init(); |
171 | 171 |
mat_test.start(); |
172 | 172 |
mat_test.run(); |
173 |
|
|
173 |
|
|
174 | 174 |
const_mat_test.matchingWeight(); |
175 | 175 |
const_mat_test.matchingSize(); |
176 | 176 |
const_mat_test.matching(e); |
177 | 177 |
const_mat_test.matching(n); |
178 | 178 |
const MaxWeightedMatching<Graph>::MatchingMap& mmap = |
179 | 179 |
const_mat_test.matchingMap(); |
180 | 180 |
e = mmap[n]; |
181 | 181 |
const_mat_test.mate(n); |
182 |
|
|
182 |
|
|
183 | 183 |
int k = 0; |
184 | 184 |
const_mat_test.dualValue(); |
185 | 185 |
const_mat_test.nodeValue(n); |
186 | 186 |
const_mat_test.blossomNum(); |
... | ... |
@@ -206,17 +206,17 @@ |
206 | 206 |
|
207 | 207 |
mat_test.init(); |
208 | 208 |
mat_test.start(); |
209 | 209 |
mat_test.run(); |
210 |
|
|
210 |
|
|
211 | 211 |
const_mat_test.matchingWeight(); |
212 | 212 |
const_mat_test.matching(e); |
213 | 213 |
const_mat_test.matching(n); |
214 | 214 |
const MaxWeightedPerfectMatching<Graph>::MatchingMap& mmap = |
215 | 215 |
const_mat_test.matchingMap(); |
216 | 216 |
e = mmap[n]; |
217 | 217 |
const_mat_test.mate(n); |
218 |
|
|
218 |
|
|
219 | 219 |
int k = 0; |
220 | 220 |
const_mat_test.dualValue(); |
221 | 221 |
const_mat_test.nodeValue(n); |
222 | 222 |
const_mat_test.blossomNum(); |
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 |
... | ... |
@@ -109,9 +109,9 @@ |
109 | 109 |
mcarb_test.start(); |
110 | 110 |
n = mcarb_test.processNextNode(); |
111 | 111 |
b = const_mcarb_test.emptyQueue(); |
112 | 112 |
i = const_mcarb_test.queueSize(); |
113 |
|
|
113 |
|
|
114 | 114 |
c = const_mcarb_test.arborescenceCost(); |
115 | 115 |
b = const_mcarb_test.arborescence(e); |
116 | 116 |
e = const_mcarb_test.pred(n); |
117 | 117 |
const MinCostArbType::ArborescenceMap &am = |
... | ... |
@@ -119,14 +119,14 @@ |
119 | 119 |
const MinCostArbType::PredMap &pm = |
120 | 120 |
const_mcarb_test.predMap(); |
121 | 121 |
b = const_mcarb_test.reached(n); |
122 | 122 |
b = const_mcarb_test.processed(n); |
123 |
|
|
123 |
|
|
124 | 124 |
i = const_mcarb_test.dualNum(); |
125 | 125 |
c = const_mcarb_test.dualValue(); |
126 | 126 |
i = const_mcarb_test.dualSize(i); |
127 | 127 |
c = const_mcarb_test.dualValue(i); |
128 |
|
|
128 |
|
|
129 | 129 |
ignore_unused_variable_warning(am); |
130 | 130 |
ignore_unused_variable_warning(pm); |
131 | 131 |
} |
132 | 132 |
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 |
... | ... |
@@ -46,9 +46,9 @@ |
46 | 46 |
" 9 3 0 0 0 0 0\n" |
47 | 47 |
" 10 -2 0 0 0 -7 -2\n" |
48 | 48 |
" 11 0 0 0 0 -10 0\n" |
49 | 49 |
" 12 -20 -27 0 -30 -30 -20\n" |
50 |
"\n" |
|
50 |
"\n" |
|
51 | 51 |
"@arcs\n" |
52 | 52 |
" cost cap low1 low2 low3\n" |
53 | 53 |
" 1 2 70 11 0 8 8\n" |
54 | 54 |
" 1 3 150 3 0 1 0\n" |
... | ... |
@@ -92,9 +92,9 @@ |
92 | 92 |
template <typename MCF> |
93 | 93 |
struct Constraints { |
94 | 94 |
void constraints() { |
95 | 95 |
checkConcept<concepts::Digraph, GR>(); |
96 |
|
|
96 |
|
|
97 | 97 |
const Constraints& me = *this; |
98 | 98 |
|
99 | 99 |
MCF mcf(me.g); |
100 | 100 |
const MCF& const_mcf = mcf; |
... | ... |
@@ -121,9 +121,9 @@ |
121 | 121 |
typedef concepts::ReadMap<Arc, Value> VAM; |
122 | 122 |
typedef concepts::ReadMap<Arc, Cost> CAM; |
123 | 123 |
typedef concepts::WriteMap<Arc, Value> FlowMap; |
124 | 124 |
typedef concepts::WriteMap<Node, Cost> PotMap; |
125 |
|
|
125 |
|
|
126 | 126 |
GR g; |
127 | 127 |
VAM lower; |
128 | 128 |
VAM upper; |
129 | 129 |
CAM cost; |
... | ... |
@@ -175,9 +175,9 @@ |
175 | 175 |
// using the "Complementary Slackness" optimality condition |
176 | 176 |
template < typename GR, typename LM, typename UM, |
177 | 177 |
typename CM, typename SM, typename FM, typename PM > |
178 | 178 |
bool checkPotential( const GR& gr, const LM& lower, const UM& upper, |
179 |
const CM& cost, const SM& supply, const FM& flow, |
|
179 |
const CM& cost, const SM& supply, const FM& flow, |
|
180 | 180 |
const PM& pi, SupplyType type ) |
181 | 181 |
{ |
182 | 182 |
TEMPLATE_DIGRAPH_TYPEDEFS(GR); |
183 | 183 |
|
... | ... |
@@ -188,9 +188,9 @@ |
188 | 188 |
opt = red_cost == 0 || |
189 | 189 |
(red_cost > 0 && flow[e] == lower[e]) || |
190 | 190 |
(red_cost < 0 && flow[e] == upper[e]); |
191 | 191 |
} |
192 |
|
|
192 |
|
|
193 | 193 |
for (NodeIt n(gr); opt && n != INVALID; ++n) { |
194 | 194 |
typename SM::Value sum = 0; |
195 | 195 |
for (OutArcIt e(gr, n); e != INVALID; ++e) |
196 | 196 |
sum += flow[e]; |
... | ... |
@@ -201,9 +201,9 @@ |
201 | 201 |
} else { |
202 | 202 |
opt = (pi[n] >= 0) && (sum == supply[n] || pi[n] == 0); |
203 | 203 |
} |
204 | 204 |
} |
205 |
|
|
205 |
|
|
206 | 206 |
return opt; |
207 | 207 |
} |
208 | 208 |
|
209 | 209 |
// Check whether the dual cost is equal to the primal cost |
... | ... |
@@ -226,18 +226,18 @@ |
226 | 226 |
red_supply[gr.source(a)] -= lower[a]; |
227 | 227 |
red_supply[gr.target(a)] += lower[a]; |
228 | 228 |
} |
229 | 229 |
} |
230 |
|
|
230 |
|
|
231 | 231 |
for (NodeIt n(gr); n != INVALID; ++n) { |
232 | 232 |
dual_cost -= red_supply[n] * pi[n]; |
233 | 233 |
} |
234 | 234 |
for (ArcIt a(gr); a != INVALID; ++a) { |
235 | 235 |
typename CM::Value red_cost = |
236 | 236 |
cost[a] + pi[gr.source(a)] - pi[gr.target(a)]; |
237 | 237 |
dual_cost -= (upper[a] - lower[a]) * std::max(-red_cost, 0); |
238 | 238 |
} |
239 |
|
|
239 |
|
|
240 | 240 |
return dual_cost == total; |
241 | 241 |
} |
242 | 242 |
|
243 | 243 |
// Run a minimum cost flow algorithm and check the results |
... | ... |
@@ -307,9 +307,9 @@ |
307 | 307 |
.nodeMap("sup6", s6) |
308 | 308 |
.node("source", v) |
309 | 309 |
.node("target", w) |
310 | 310 |
.run(); |
311 |
|
|
311 |
|
|
312 | 312 |
// Build test digraphs with negative costs |
313 | 313 |
Digraph neg_gr; |
314 | 314 |
Node n1 = neg_gr.addNode(); |
315 | 315 |
Node n2 = neg_gr.addNode(); |
... | ... |
@@ -317,9 +317,9 @@ |
317 | 317 |
Node n4 = neg_gr.addNode(); |
318 | 318 |
Node n5 = neg_gr.addNode(); |
319 | 319 |
Node n6 = neg_gr.addNode(); |
320 | 320 |
Node n7 = neg_gr.addNode(); |
321 |
|
|
321 |
|
|
322 | 322 |
Arc a1 = neg_gr.addArc(n1, n2); |
323 | 323 |
Arc a2 = neg_gr.addArc(n1, n3); |
324 | 324 |
Arc a3 = neg_gr.addArc(n2, n4); |
325 | 325 |
Arc a4 = neg_gr.addArc(n3, n4); |
... | ... |
@@ -327,19 +327,19 @@ |
327 | 327 |
Arc a6 = neg_gr.addArc(n5, n3); |
328 | 328 |
Arc a7 = neg_gr.addArc(n5, n6); |
329 | 329 |
Arc a8 = neg_gr.addArc(n6, n7); |
330 | 330 |
Arc a9 = neg_gr.addArc(n7, n5); |
331 |
|
|
331 |
|
|
332 | 332 |
Digraph::ArcMap<int> neg_c(neg_gr), neg_l1(neg_gr, 0), neg_l2(neg_gr, 0); |
333 | 333 |
ConstMap<Arc, int> neg_u1(std::numeric_limits<int>::max()), neg_u2(5000); |
334 | 334 |
Digraph::NodeMap<int> neg_s(neg_gr, 0); |
335 |
|
|
335 |
|
|
336 | 336 |
neg_l2[a7] = 1000; |
337 | 337 |
neg_l2[a8] = -1000; |
338 |
|
|
338 |
|
|
339 | 339 |
neg_s[n1] = 100; |
340 | 340 |
neg_s[n4] = -100; |
341 |
|
|
341 |
|
|
342 | 342 |
neg_c[a1] = 100; |
343 | 343 |
neg_c[a2] = 30; |
344 | 344 |
neg_c[a3] = 20; |
345 | 345 |
neg_c[a4] = 80; |
... | ... |
@@ -421,9 +421,9 @@ |
421 | 421 |
neg_c, neg_s, neg_mcf.OPTIMAL, true, -40000, "#A17"); |
422 | 422 |
neg_mcf.reset().lowerMap(neg_l2).costMap(neg_c).supplyMap(neg_s); |
423 | 423 |
checkMcf(neg_mcf, neg_mcf.run(), neg_gr, neg_l2, neg_u1, |
424 | 424 |
neg_c, neg_s, neg_mcf.UNBOUNDED, false, 0, "#A18"); |
425 |
|
|
425 |
|
|
426 | 426 |
NetworkSimplex<Digraph> negs_mcf(negs_gr); |
427 | 427 |
negs_mcf.costMap(negs_c).supplyMap(negs_s); |
428 | 428 |
checkMcf(negs_mcf, negs_mcf.run(), negs_gr, negs_l, negs_u, |
429 | 429 |
negs_c, negs_s, negs_mcf.OPTIMAL, true, -300, "#A19", GEQ); |
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 |
... | ... |
@@ -112,9 +112,9 @@ |
112 | 112 |
v = const_preflow_test.flow(e); |
113 | 113 |
const FlowMap& fm = const_preflow_test.flowMap(); |
114 | 114 |
b = const_preflow_test.minCut(n); |
115 | 115 |
const_preflow_test.minCutMap(cut); |
116 |
|
|
116 |
|
|
117 | 117 |
ignore_unused_variable_warning(fm); |
118 | 118 |
} |
119 | 119 |
|
120 | 120 |
int cutValue (const SmartDigraph& g, |
... | ... |
@@ -153,9 +153,9 @@ |
153 | 153 |
|
154 | 154 |
void initFlowTest() |
155 | 155 |
{ |
156 | 156 |
DIGRAPH_TYPEDEFS(SmartDigraph); |
157 |
|
|
157 |
|
|
158 | 158 |
SmartDigraph g; |
159 | 159 |
SmartDigraph::ArcMap<int> cap(g),iflow(g); |
160 | 160 |
Node s=g.addNode(); Node t=g.addNode(); |
161 | 161 |
Node n1=g.addNode(); Node n2=g.addNode(); |
... | ... |
@@ -265,7 +265,7 @@ |
265 | 265 |
check(preflow_test.flowValue() == min_cut_value, |
266 | 266 |
"The max flow value or the three min cut values are incorrect."); |
267 | 267 |
|
268 | 268 |
initFlowTest(); |
269 |
|
|
269 |
|
|
270 | 270 |
return 0; |
271 | 271 |
} |
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 |
... | ... |
@@ -79,9 +79,9 @@ |
79 | 79 |
|
80 | 80 |
typedef Digraph::Node Node; |
81 | 81 |
typedef Digraph::Arc Arc; |
82 | 82 |
typedef concepts::ReadMap<Arc, VType> LengthMap; |
83 |
|
|
83 |
|
|
84 | 84 |
typedef Suurballe<Digraph, LengthMap> SuurballeType; |
85 | 85 |
|
86 | 86 |
Digraph g; |
87 | 87 |
Node n; |
... | ... |
@@ -103,9 +103,9 @@ |
103 | 103 |
suurb_test.init(n); |
104 | 104 |
k = suurb_test.findFlow(n); |
105 | 105 |
k = suurb_test.findFlow(n, k); |
106 | 106 |
suurb_test.findPaths(); |
107 |
|
|
107 |
|
|
108 | 108 |
int f; |
109 | 109 |
VType c; |
110 | 110 |
c = const_suurb_test.totalLength(); |
111 | 111 |
f = const_suurb_test.flow(e); |
... | ... |
@@ -115,9 +115,9 @@ |
115 | 115 |
const SuurballeType::PotentialMap& pm = |
116 | 116 |
const_suurb_test.potentialMap(); |
117 | 117 |
k = const_suurb_test.pathNum(); |
118 | 118 |
Path<Digraph> p = const_suurb_test.path(k); |
119 |
|
|
119 |
|
|
120 | 120 |
ignore_unused_variable_warning(fm); |
121 | 121 |
ignore_unused_variable_warning(pm); |
122 | 122 |
} |
123 | 123 |
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 |
... | ... |
@@ -87,9 +87,9 @@ |
87 | 87 |
if(report) std::cerr << "Setup Preflow class: " << ti << '\n'; |
88 | 88 |
ti.restart(); |
89 | 89 |
pre.run(); |
90 | 90 |
if(report) std::cerr << "Run Preflow: " << ti << '\n'; |
91 |
if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; |
|
91 |
if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; |
|
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
template<class Value> |
95 | 95 |
void solve_min(ArgParser &ap, std::istream &is, std::ostream &, |
... | ... |
@@ -146,9 +146,9 @@ |
146 | 146 |
ti.restart(); |
147 | 147 |
mat.run(); |
148 | 148 |
if(report) std::cerr << "Run MaxMatching: " << ti << '\n'; |
149 | 149 |
if(report) std::cerr << "\nCardinality of max matching: " |
150 |
<< mat.matchingSize() << '\n'; |
|
150 |
<< mat.matchingSize() << '\n'; |
|
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
|
154 | 154 |
template<class Value> |
... | ... |
@@ -164,9 +164,9 @@ |
164 | 164 |
<< static_cast<std::string>(ap["infcap"]) << "' as infinite" |
165 | 165 |
<< std::endl; |
166 | 166 |
exit(1); |
167 | 167 |
} |
168 |
|
|
168 |
|
|
169 | 169 |
switch(desc.type) |
170 | 170 |
{ |
171 | 171 |
case DimacsDescriptor::MIN: |
172 | 172 |
solve_min<Value>(ap,is,os,infty,desc); |
... | ... |
@@ -236,9 +236,9 @@ |
236 | 236 |
std::istream& is = (ap.files().size()<1 ? std::cin : input); |
237 | 237 |
std::ostream& os = (ap.files().size()<2 ? std::cout : output); |
238 | 238 |
|
239 | 239 |
DimacsDescriptor desc = dimacsType(is); |
240 |
|
|
240 |
|
|
241 | 241 |
if(!ap.given("q")) |
242 | 242 |
{ |
243 | 243 |
std::cout << "Problem type: "; |
244 | 244 |
switch(desc.type) |
... | ... |
@@ -261,9 +261,9 @@ |
261 | 261 |
std::cout << "\nNum of nodes: " << desc.nodeNum; |
262 | 262 |
std::cout << "\nNum of arcs: " << desc.edgeNum; |
263 | 263 |
std::cout << "\n\n"; |
264 | 264 |
} |
265 |
|
|
265 |
|
|
266 | 266 |
if(ap.given("double")) |
267 | 267 |
solve<double>(ap,is,os,desc); |
268 | 268 |
else if(ap.given("ldouble")) |
269 | 269 |
solve<long double>(ap,is,os,desc); |
0 comments (0 inline)