166 const LowerMap &lower, |
166 const LowerMap &lower, |
167 const CapacityMap &capacity, |
167 const CapacityMap &capacity, |
168 const CostMap &cost, |
168 const CostMap &cost, |
169 const SupplyMap &supply ) : |
169 const SupplyMap &supply ) : |
170 _graph(graph), _lower(&lower), _capacity(graph), _cost(cost), |
170 _graph(graph), _lower(&lower), _capacity(graph), _cost(cost), |
171 _supply(graph), _flow(0), _local_flow(false), |
171 _supply(graph), _flow(NULL), _local_flow(false), |
172 _potential(0), _local_potential(false), _res_cost(_cost) |
172 _potential(NULL), _local_potential(false), _res_graph(NULL), |
|
173 _res_cost(_cost) |
173 { |
174 { |
174 // Removing non-zero lower bounds |
175 // Removing non-zero lower bounds |
175 _capacity = subMap(capacity, lower); |
176 _capacity = subMap(capacity, lower); |
176 Supply sum = 0; |
177 Supply sum = 0; |
177 for (NodeIt n(_graph); n != INVALID; ++n) { |
178 for (NodeIt n(_graph); n != INVALID; ++n) { |
196 CycleCanceling( const Graph &graph, |
197 CycleCanceling( const Graph &graph, |
197 const CapacityMap &capacity, |
198 const CapacityMap &capacity, |
198 const CostMap &cost, |
199 const CostMap &cost, |
199 const SupplyMap &supply ) : |
200 const SupplyMap &supply ) : |
200 _graph(graph), _lower(NULL), _capacity(capacity), _cost(cost), |
201 _graph(graph), _lower(NULL), _capacity(capacity), _cost(cost), |
201 _supply(supply), _flow(0), _local_flow(false), |
202 _supply(supply), _flow(NULL), _local_flow(false), |
202 _potential(0), _local_potential(false), _res_cost(_cost) |
203 _potential(NULL), _local_potential(false), _res_graph(NULL), |
|
204 _res_cost(_cost) |
203 { |
205 { |
204 // Checking the sum of supply values |
206 // Checking the sum of supply values |
205 Supply sum = 0; |
207 Supply sum = 0; |
206 for (NodeIt n(_graph); n != INVALID; ++n) sum += _supply[n]; |
208 for (NodeIt n(_graph); n != INVALID; ++n) sum += _supply[n]; |
207 _valid_supply = sum == 0; |
209 _valid_supply = sum == 0; |
224 const CapacityMap &capacity, |
226 const CapacityMap &capacity, |
225 const CostMap &cost, |
227 const CostMap &cost, |
226 Node s, Node t, |
228 Node s, Node t, |
227 Supply flow_value ) : |
229 Supply flow_value ) : |
228 _graph(graph), _lower(&lower), _capacity(graph), _cost(cost), |
230 _graph(graph), _lower(&lower), _capacity(graph), _cost(cost), |
229 _supply(graph), _flow(0), _local_flow(false), |
231 _supply(graph), _flow(NULL), _local_flow(false), |
230 _potential(0), _local_potential(false), _res_cost(_cost) |
232 _potential(NULL), _local_potential(false), _res_graph(NULL), |
|
233 _res_cost(_cost) |
231 { |
234 { |
232 // Removing non-zero lower bounds |
235 // Removing non-zero lower bounds |
233 _capacity = subMap(capacity, lower); |
236 _capacity = subMap(capacity, lower); |
234 for (NodeIt n(_graph); n != INVALID; ++n) { |
237 for (NodeIt n(_graph); n != INVALID; ++n) { |
235 Supply sum = 0; |
238 Supply sum = 0; |
259 const CapacityMap &capacity, |
262 const CapacityMap &capacity, |
260 const CostMap &cost, |
263 const CostMap &cost, |
261 Node s, Node t, |
264 Node s, Node t, |
262 Supply flow_value ) : |
265 Supply flow_value ) : |
263 _graph(graph), _lower(NULL), _capacity(capacity), _cost(cost), |
266 _graph(graph), _lower(NULL), _capacity(capacity), _cost(cost), |
264 _supply(graph, 0), _flow(0), _local_flow(false), |
267 _supply(graph, 0), _flow(NULL), _local_flow(false), |
265 _potential(0), _local_potential(false), _res_cost(_cost) |
268 _potential(NULL), _local_potential(false), _res_graph(NULL), |
|
269 _res_cost(_cost) |
266 { |
270 { |
267 _supply[s] = flow_value; |
271 _supply[s] = flow_value; |
268 _supply[t] = -flow_value; |
272 _supply[t] = -flow_value; |
269 _valid_supply = true; |
273 _valid_supply = true; |
270 } |
274 } |