62 /// other minimum cost flow algorithms. |
62 /// other minimum cost flow algorithms. |
63 /// If it is available, <tt>long long int</tt> type is used instead of |
63 /// If it is available, <tt>long long int</tt> type is used instead of |
64 /// <tt>long int</tt> in the inside computations. |
64 /// <tt>long int</tt> in the inside computations. |
65 /// |
65 /// |
66 /// \author Peter Kovacs |
66 /// \author Peter Kovacs |
67 |
|
68 template < typename Graph, |
67 template < typename Graph, |
69 typename LowerMap = typename Graph::template EdgeMap<int>, |
68 typename LowerMap = typename Graph::template EdgeMap<int>, |
70 typename CapacityMap = typename Graph::template EdgeMap<int>, |
69 typename CapacityMap = typename Graph::template EdgeMap<int>, |
71 typename CostMap = typename Graph::template EdgeMap<int>, |
70 typename CostMap = typename Graph::template EdgeMap<int>, |
72 typename SupplyMap = typename Graph::template NodeMap<int> > |
71 typename SupplyMap = typename Graph::template NodeMap<int> > |
353 _potential = ↦ |
350 _potential = ↦ |
354 return *this; |
351 return *this; |
355 } |
352 } |
356 |
353 |
357 /// \name Execution control |
354 /// \name Execution control |
358 /// The only way to execute the algorithm is to call the run() |
|
359 /// function. |
|
360 |
355 |
361 /// @{ |
356 /// @{ |
362 |
357 |
363 /// \brief Runs the algorithm. |
358 /// \brief Run the algorithm. |
364 /// |
359 /// |
365 /// Runs the algorithm. |
360 /// Run the algorithm. |
366 /// |
361 /// |
367 /// \return \c true if a feasible flow can be found. |
362 /// \return \c true if a feasible flow can be found. |
368 bool run() { |
363 bool run() { |
369 return init() && start(); |
364 return init() && start(); |
370 } |
365 } |
371 |
366 |
372 /// @} |
367 /// @} |
373 |
368 |
374 /// \name Query Functions |
369 /// \name Query Functions |
375 /// The result of the algorithm can be obtained using these |
370 /// The result of the algorithm can be obtained using these |
376 /// functions. |
371 /// functions.\n |
377 /// \n run() must be called before using them. |
372 /// \ref lemon::CostScaling::run() "run()" must be called before |
|
373 /// using them. |
378 |
374 |
379 /// @{ |
375 /// @{ |
380 |
376 |
381 /// \brief Returns a const reference to the edge map storing the |
377 /// \brief Return a const reference to the edge map storing the |
382 /// found flow. |
378 /// found flow. |
383 /// |
379 /// |
384 /// Returns a const reference to the edge map storing the found flow. |
380 /// Return a const reference to the edge map storing the found flow. |
385 /// |
381 /// |
386 /// \pre \ref run() must be called before using this function. |
382 /// \pre \ref run() must be called before using this function. |
387 const FlowMap& flowMap() const { |
383 const FlowMap& flowMap() const { |
388 return *_flow; |
384 return *_flow; |
389 } |
385 } |
390 |
386 |
391 /// \brief Returns a const reference to the node map storing the |
387 /// \brief Return a const reference to the node map storing the |
392 /// found potentials (the dual solution). |
388 /// found potentials (the dual solution). |
393 /// |
389 /// |
394 /// Returns a const reference to the node map storing the found |
390 /// Return a const reference to the node map storing the found |
395 /// potentials (the dual solution). |
391 /// potentials (the dual solution). |
396 /// |
392 /// |
397 /// \pre \ref run() must be called before using this function. |
393 /// \pre \ref run() must be called before using this function. |
398 const PotentialMap& potentialMap() const { |
394 const PotentialMap& potentialMap() const { |
399 return *_potential; |
395 return *_potential; |
400 } |
396 } |
401 |
397 |
402 /// \brief Returns the flow on the given edge. |
398 /// \brief Return the flow on the given edge. |
403 /// |
399 /// |
404 /// Returns the flow on the given edge. |
400 /// Return the flow on the given edge. |
405 /// |
401 /// |
406 /// \pre \ref run() must be called before using this function. |
402 /// \pre \ref run() must be called before using this function. |
407 Capacity flow(const Edge& edge) const { |
403 Capacity flow(const Edge& edge) const { |
408 return (*_flow)[edge]; |
404 return (*_flow)[edge]; |
409 } |
405 } |
410 |
406 |
411 /// \brief Returns the potential of the given node. |
407 /// \brief Return the potential of the given node. |
412 /// |
408 /// |
413 /// Returns the potential of the given node. |
409 /// Return the potential of the given node. |
414 /// |
410 /// |
415 /// \pre \ref run() must be called before using this function. |
411 /// \pre \ref run() must be called before using this function. |
416 Cost potential(const Node& node) const { |
412 Cost potential(const Node& node) const { |
417 return (*_potential)[node]; |
413 return (*_potential)[node]; |
418 } |
414 } |
419 |
415 |
420 /// \brief Returns the total cost of the found flow. |
416 /// \brief Return the total cost of the found flow. |
421 /// |
417 /// |
422 /// Returns the total cost of the found flow. The complexity of the |
418 /// Return the total cost of the found flow. The complexity of the |
423 /// function is \f$ O(e) \f$. |
419 /// function is \f$ O(e) \f$. |
424 /// |
420 /// |
425 /// \pre \ref run() must be called before using this function. |
421 /// \pre \ref run() must be called before using this function. |
426 Cost totalCost() const { |
422 Cost totalCost() const { |
427 Cost c = 0; |
423 Cost c = 0; |