find_flow_cost.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <HTML>
  2. <!--
  3. Copyright (c) Piotr Wygocki 2013
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Boost Graph Library: Find Flow Cost</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H1><A NAME="sec:find_flow_cost">
  16. <TT>find_flow_cost</TT>
  17. </H1>
  18. <PRE>
  19. <i>// named parameter version</i>
  20. template &lt;class <a href="./Graph.html">Graph</a>&gt;
  21. typename property_traits&lt;typename property_map &lt; Graph, edge_capacity_t &gt;::type&gt;::value_type
  22. find_flow_cost(const Graph &amp; g,
  23. const bgl_named_params&lt;P, T, R&gt; &amp; params = <i>all defaults</i>)
  24. <i>// non-named parameter version</i>
  25. template&lt;class <a href="./Graph.html">Graph</a>, class Capacity, class ResidualCapacity, class Weight&gt;
  26. typename property_traits&lt;typename property_map &lt; Graph, edge_capacity_t &gt;::type&gt;::value_type
  27. find_flow_cost(const Graph &amp; g, Capacity capacity, ResidualCapacity residual_capacity, Weight weight)
  28. </PRE>
  29. <P>
  30. The <tt>find_flow_cost()</tt> function calculates the minimum cost maximum flow value of a network and given flow. See Section <a
  31. href="./graph_theory_review.html#sec:network-flow-algorithms">Network
  32. Flow Algorithms</a> for a description of maximum flow.
  33. The function calculates the cost from the flow values <i>f(u,v)</i> for <i>(u,v)</i> in
  34. <i>E</i>, which are passed in the form of the residual capacity
  35. <i>r(u,v) = c(u,v) - f(u,v)</i>.
  36. <p>
  37. In order to compute the min cost max flow use :
  38. <a href="./successive_shortest_path_nonnegative_weights.html"><tt>successive_shortest_path_nonnegative_weights()</tt></a> or
  39. <a href="./cycle_canceling.html"><tt>cycle_canceling()</tt></a>.
  40. <H3>Where Defined</H3>
  41. <P>
  42. <a href="../../../boost/graph/successive_shortest_path_nonnegative_weights.hpp"><TT>boost/graph/successive_shortest_path_nonnegative_weights.hpp</TT></a>
  43. <P>
  44. <h3>Parameters</h3>
  45. IN: <tt>const Graph&amp; g</tt>
  46. <blockquote>
  47. A directed graph. The
  48. graph's type must be a model of <a
  49. href="./VertexListGraph.html">VertexListGraph</a> and <a href="./IncidenceGraph.html">IncidenceGraph</a> For each edge
  50. <i>(u,v)</i> in the graph, the reverse edge <i>(v,u)</i> must also
  51. be in the graph.
  52. </blockquote>
  53. <h3>Named Parameters</h3>
  54. IN: <tt>capacity_map(CapacityEdgeMap cap)</tt>
  55. <blockquote>
  56. The edge capacity property map. The type must be a model of a
  57. constant <a
  58. href="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property Map</a>. The
  59. key type of the map must be the graph's edge descriptor type.<br>
  60. <b>Default:</b> <tt>get(edge_capacity, g)</tt>
  61. </blockquote>
  62. IN: <tt>residual_capacity_map(ResidualCapacityEdgeMap res)</tt>
  63. <blockquote>
  64. This maps edges to their residual capacity. The type must be a model
  65. of a mutable <a
  66. href="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
  67. Map</a>. The key type of the map must be the graph's edge descriptor
  68. type.<br>
  69. <b>Default:</b> <tt>get(edge_residual_capacity, g)</tt>
  70. </blockquote>
  71. IN: <tt>weight_map(WeightMap w_map)</tt>
  72. <blockquote>
  73. The weight or ``cost'' of each edge in the graph.
  74. The type <tt>WeightMap</tt> must be a model of
  75. <a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map</a>. The edge descriptor type of
  76. the graph needs to be usable as the key type for the weight
  77. map. The value type for this map must be
  78. the same as the value type of the distance map.<br>
  79. <b>Default:</b> <tt>get(edge_weight, g)</tt><br>
  80. </blockquote>
  81. <h3>Complexity</h3>
  82. The complexity is <i> O(|E|)</i>,
  83. <h3>Example</h3>
  84. The function is used in the successive_shortest_path_nonnegative_weights example. The program in <a
  85. href="../example/successive_shortest_path_nonnegative_weights_example.cpp"><tt>example/successive_shortest_path_nonnegative_weights_example.cpp</tt></a>.
  86. <h3>See Also</h3>
  87. <a href="./cycle_canceling.html"><tt>cycle_canceling()</tt></a><br>
  88. <a href="./successive_shortest_path_nonnegative_weights.html"><tt>successive_shortest_path_nonnegative_weights()</tt></a>.
  89. <br>
  90. <HR>
  91. <TABLE>
  92. <TR valign=top>
  93. <TD nowrap>Copyright &copy; 2013</TD><TD>
  94. Piotr Wygocki, University of Warsaw (<A HREF="mailto:wygos@mimuw.edu.pl">wygos at mimuw.edu.pl</A>)
  95. </TD></TR></TABLE>
  96. </BODY>
  97. </HTML>
  98. <!-- LocalWords: HTML Siek Edmonds BGCOLOR ffffff ee VLINK ALINK ff IMG SRC
  99. -->
  100. <!-- LocalWords: gif ALT BR sec edmonds karp TT DIV CELLPADDING TR TD PRE lt
  101. -->
  102. <!-- LocalWords: typename VertexListGraph CapacityEdgeMap ReverseEdgeMap gt
  103. -->
  104. <!-- LocalWords: ResidualCapacityEdgeMap VertexIndexMap src rev ColorMap pred
  105. -->
  106. <!-- LocalWords: PredEdgeMap tt href html hpp ul li nbsp br LvaluePropertyMap
  107. -->
  108. <!-- LocalWords: num ColorValue DIMACS cpp pre config iostream dimacs int std
  109. -->
  110. <!-- LocalWords: namespace vecS directedS cout endl iter ei HR valign nowrap
  111. -->
  112. <!-- LocalWords: jeremy siek htm Univ mailto jsiek lsc edu
  113. p -->