| ... | ... |
@@ -1024,50 +1024,50 @@ |
| 1024 | 1024 |
/// The \c Cost type of the algorithm must be convertible to the |
| 1025 | 1025 |
/// \c Value type of the map. |
| 1026 | 1026 |
/// |
| 1027 | 1027 |
/// \pre \ref run() must be called before using this function. |
| 1028 | 1028 |
template <typename PotentialMap> |
| 1029 | 1029 |
void potentialMap(PotentialMap &map) const {
|
| 1030 | 1030 |
for (NodeIt n(_graph); n != INVALID; ++n) {
|
| 1031 | 1031 |
map.set(n, _pi[_node_id[n]]); |
| 1032 | 1032 |
} |
| 1033 | 1033 |
} |
| 1034 | 1034 |
|
| 1035 | 1035 |
/// @} |
| 1036 | 1036 |
|
| 1037 | 1037 |
private: |
| 1038 | 1038 |
|
| 1039 | 1039 |
// Initialize internal data structures |
| 1040 | 1040 |
bool init() {
|
| 1041 | 1041 |
if (_node_num == 0) return false; |
| 1042 | 1042 |
|
| 1043 | 1043 |
// Check the sum of supply values |
| 1044 | 1044 |
_sum_supply = 0; |
| 1045 | 1045 |
for (int i = 0; i != _node_num; ++i) {
|
| 1046 | 1046 |
_sum_supply += _supply[i]; |
| 1047 | 1047 |
} |
| 1048 |
if ( !(_stype == GEQ && _sum_supply <= 0 || |
|
| 1049 |
_stype == LEQ && _sum_supply >= 0) ) return false; |
|
| 1048 |
if ( !((_stype == GEQ && _sum_supply <= 0) || |
|
| 1049 |
(_stype == LEQ && _sum_supply >= 0)) ) return false; |
|
| 1050 | 1050 |
|
| 1051 | 1051 |
// Remove non-zero lower bounds |
| 1052 | 1052 |
if (_have_lower) {
|
| 1053 | 1053 |
for (int i = 0; i != _arc_num; ++i) {
|
| 1054 | 1054 |
Value c = _lower[i]; |
| 1055 | 1055 |
if (c >= 0) {
|
| 1056 | 1056 |
_cap[i] = _upper[i] < INF ? _upper[i] - c : INF; |
| 1057 | 1057 |
} else {
|
| 1058 | 1058 |
_cap[i] = _upper[i] < INF + c ? _upper[i] - c : INF; |
| 1059 | 1059 |
} |
| 1060 | 1060 |
_supply[_source[i]] -= c; |
| 1061 | 1061 |
_supply[_target[i]] += c; |
| 1062 | 1062 |
} |
| 1063 | 1063 |
} else {
|
| 1064 | 1064 |
for (int i = 0; i != _arc_num; ++i) {
|
| 1065 | 1065 |
_cap[i] = _upper[i]; |
| 1066 | 1066 |
} |
| 1067 | 1067 |
} |
| 1068 | 1068 |
|
| 1069 | 1069 |
// Initialize artifical cost |
| 1070 | 1070 |
Cost ART_COST; |
| 1071 | 1071 |
if (std::numeric_limits<Cost>::is_exact) {
|
| 1072 | 1072 |
ART_COST = std::numeric_limits<Cost>::max() / 4 + 1; |
| 1073 | 1073 |
} else {
|
0 comments (0 inline)