56 /// - Edge capacities and costs should be \e non-negative \e integers. |
56 /// - Edge capacities and costs should be \e non-negative \e integers. |
57 /// - \c CapacityMap::Value must be convertible to \c CostMap::Value. |
57 /// - \c CapacityMap::Value must be convertible to \c CostMap::Value. |
58 /// - \c CostMap::Value must be signed type. |
58 /// - \c CostMap::Value must be signed type. |
59 /// |
59 /// |
60 /// \author Peter Kovacs |
60 /// \author Peter Kovacs |
61 |
|
62 template < typename Graph, |
61 template < typename Graph, |
63 typename CapacityMap = typename Graph::template EdgeMap<int>, |
62 typename CapacityMap = typename Graph::template EdgeMap<int>, |
64 typename CostMap = typename Graph::template EdgeMap<int> > |
63 typename CostMap = typename Graph::template EdgeMap<int> > |
65 class MinCostMaxFlow |
64 class MinCostMaxFlow |
66 { |
65 { |
184 } |
181 } |
185 |
182 |
186 /// @} |
183 /// @} |
187 |
184 |
188 /// \name Query Functions |
185 /// \name Query Functions |
189 /// The result of the algorithm can be obtained using these |
186 /// The results of the algorithm can be obtained using these |
190 /// functions. |
187 /// functions.\n |
191 /// \n run() must be called before using them. |
188 /// \ref lemon::MinCostMaxFlow::run() "run()" must be called before |
|
189 /// using them. |
192 |
190 |
193 /// @{ |
191 /// @{ |
194 |
192 |
195 /// \brief Returns a const reference to the edge map storing the |
193 /// \brief Return a const reference to the edge map storing the |
196 /// found flow. |
194 /// found flow. |
197 /// |
195 /// |
198 /// Returns a const reference to the edge map storing the found flow. |
196 /// Return a const reference to the edge map storing the found flow. |
199 /// |
197 /// |
200 /// \pre \ref run() must be called before using this function. |
198 /// \pre \ref run() must be called before using this function. |
201 const FlowMap& flowMap() const { |
199 const FlowMap& flowMap() const { |
202 return *_flow; |
200 return *_flow; |
203 } |
201 } |
204 |
202 |
205 /// \brief Returns a const reference to the node map storing the |
203 /// \brief Return a const reference to the node map storing the |
206 /// found potentials (the dual solution). |
204 /// found potentials (the dual solution). |
207 /// |
205 /// |
208 /// Returns a const reference to the node map storing the found |
206 /// Return a const reference to the node map storing the found |
209 /// potentials (the dual solution). |
207 /// potentials (the dual solution). |
210 /// |
208 /// |
211 /// \pre \ref run() must be called before using this function. |
209 /// \pre \ref run() must be called before using this function. |
212 const PotentialMap& potentialMap() const { |
210 const PotentialMap& potentialMap() const { |
213 return *_potential; |
211 return *_potential; |
214 } |
212 } |
215 |
213 |
216 /// \brief Returns the flow on the given edge. |
214 /// \brief Return the flow on the given edge. |
217 /// |
215 /// |
218 /// Returns the flow on the given edge. |
216 /// Return the flow on the given edge. |
219 /// |
217 /// |
220 /// \pre \ref run() must be called before using this function. |
218 /// \pre \ref run() must be called before using this function. |
221 Capacity flow(const Edge& edge) const { |
219 Capacity flow(const Edge& edge) const { |
222 return (*_flow)[edge]; |
220 return (*_flow)[edge]; |
223 } |
221 } |
224 |
222 |
225 /// \brief Returns the potential of the given node. |
223 /// \brief Return the potential of the given node. |
226 /// |
224 /// |
227 /// Returns the potential of the given node. |
225 /// Return the potential of the given node. |
228 /// |
226 /// |
229 /// \pre \ref run() must be called before using this function. |
227 /// \pre \ref run() must be called before using this function. |
230 Cost potential(const Node& node) const { |
228 Cost potential(const Node& node) const { |
231 return (*_potential)[node]; |
229 return (*_potential)[node]; |
232 } |
230 } |
233 |
231 |
234 /// \brief Returns the total cost of the found flow. |
232 /// \brief Return the total cost of the found flow. |
235 /// |
233 /// |
236 /// Returns the total cost of the found flow. The complexity of the |
234 /// Return the total cost of the found flow. The complexity of the |
237 /// function is \f$ O(e) \f$. |
235 /// function is \f$ O(e) \f$. |
238 /// |
236 /// |
239 /// \pre \ref run() must be called before using this function. |
237 /// \pre \ref run() must be called before using this function. |
240 Cost totalCost() const { |
238 Cost totalCost() const { |
241 Cost c = 0; |
239 Cost c = 0; |