a00088.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  5. <title>GTL - Graph Template Library: maxflow_sap.h Source File</title>
  6. <link href="doxygen.css" rel="stylesheet" type="text/css">
  7. </head>
  8. <body>
  9. <p class="links">
  10. <a href="../index.html">Home</a> |
  11. Documentation |
  12. <a href="../register.html">Download</a> |
  13. <a href="../platforms.html">Platforms</a> |
  14. <a href="../refer.html">Projects</a> |
  15. <a href="../lists.html">Mailing Lists</a> |
  16. <a href="../history.html">Version History</a>
  17. </p>
  18. <!-- Generated by Doxygen 1.5.3 -->
  19. <div class="tabs">
  20. <ul>
  21. <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
  22. <li><a href="classes.html"><span>Classes</span></a></li>
  23. <li class="current"><a href="files.html"><span>Files</span></a></li>
  24. <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  25. </ul>
  26. </div>
  27. <h1>maxflow_sap.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==========================================================================</span>
  28. <a name="l00002"></a>00002 <span class="comment">//</span>
  29. <a name="l00003"></a>00003 <span class="comment">// maxflow_sap.h</span>
  30. <a name="l00004"></a>00004 <span class="comment">//</span>
  31. <a name="l00005"></a>00005 <span class="comment">//==========================================================================</span>
  32. <a name="l00006"></a>00006 <span class="comment">// $Id: maxflow_sap.h,v 1.4 2003/01/31 08:15:05 chris Exp $</span>
  33. <a name="l00007"></a>00007
  34. <a name="l00008"></a>00008 <span class="preprocessor">#ifndef GTL_MAXFLOW_SAP_H</span>
  35. <a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define GTL_MAXFLOW_SAP_H</span>
  36. <a name="l00010"></a>00010 <span class="preprocessor"></span>
  37. <a name="l00011"></a>00011 <span class="preprocessor">#include &lt;GTL/GTL.h&gt;</span>
  38. <a name="l00012"></a>00012 <span class="preprocessor">#include &lt;GTL/graph.h&gt;</span>
  39. <a name="l00013"></a>00013 <span class="preprocessor">#include &lt;GTL/node_map.h&gt;</span>
  40. <a name="l00014"></a>00014 <span class="preprocessor">#include &lt;GTL/edge_map.h&gt;</span>
  41. <a name="l00015"></a>00015 <span class="preprocessor">#include &lt;GTL/algorithm.h&gt;</span>
  42. <a name="l00016"></a>00016
  43. <a name="l00017"></a>00017 <span class="preprocessor">#include &lt;queue&gt;</span>
  44. <a name="l00018"></a>00018
  45. <a name="l00019"></a>00019 __GTL_BEGIN_NAMESPACE
  46. <a name="l00020"></a>00020
  47. <a name="l00033"></a><a class="code" href="a00017.html">00033</a> <span class="keyword">class </span>GTL_EXTERN <a class="code" href="a00017.html" title="Maximum flow algorithm with shortest augmenting paths.">maxflow_sap</a> : <span class="keyword">public</span> <a class="code" href="a00001.html" title="Abstract baseclass for all algoritm-classes.">algorithm</a>
  48. <a name="l00034"></a>00034 {
  49. <a name="l00035"></a>00035 <span class="keyword">public</span>:
  50. <a name="l00042"></a>00042 <a class="code" href="a00017.html" title="Maximum flow algorithm with shortest augmenting paths.">maxflow_sap</a>();
  51. <a name="l00043"></a>00043
  52. <a name="l00049"></a>00049 <span class="keyword">virtual</span> ~<a class="code" href="a00017.html" title="Maximum flow algorithm with shortest augmenting paths.">maxflow_sap</a>();
  53. <a name="l00050"></a>00050
  54. <a name="l00058"></a>00058 <span class="keywordtype">void</span> set_vars(<span class="keyword">const</span> <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;double&gt;</a>&amp; edge_capacity);
  55. <a name="l00059"></a>00059
  56. <a name="l00067"></a>00067 <span class="keywordtype">void</span> set_vars(<span class="keyword">const</span> <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;double&gt;</a>&amp; edge_capacity,
  57. <a name="l00068"></a>00068 <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>&amp; net_source,
  58. <a name="l00069"></a>00069 <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>&amp; net_target);
  59. <a name="l00070"></a>00070
  60. <a name="l00088"></a>00088 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="a00001.html#76361fb03ad1cf643affc51821e43bed" title="Checks whether all preconditions are satisfied.">check</a>(<a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G);
  61. <a name="l00089"></a>00089
  62. <a name="l00098"></a>00098 <span class="keywordtype">int</span> <a class="code" href="a00001.html#734b189509a8d6b56b65f8ff772d43ca" title="Applies algorithm to graph g.">run</a>(<a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G);
  63. <a name="l00099"></a>00099
  64. <a name="l00106"></a>00106 <span class="keywordtype">double</span> get_max_flow(<span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>&amp; e) <span class="keyword">const</span>;
  65. <a name="l00107"></a>00107
  66. <a name="l00113"></a>00113 <span class="keywordtype">double</span> get_max_flow() <span class="keyword">const</span>;
  67. <a name="l00114"></a>00114
  68. <a name="l00121"></a>00121 <span class="keywordtype">double</span> get_rem_cap(<span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>&amp; e) <span class="keyword">const</span>;
  69. <a name="l00122"></a>00122
  70. <a name="l00129"></a>00129 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00001.html#21aba63d066ae7897de6ca7d8425c408" title="Resets algorithm.">reset</a>();
  71. <a name="l00130"></a>00130 <span class="keyword">protected</span>:
  72. <a name="l00134"></a>00134 <span class="keyword">enum</span> {AP_FOUND = 2, NO_AP_FOUND = 3};
  73. <a name="l00135"></a>00135
  74. <a name="l00139"></a>00139 <span class="keywordtype">bool</span> artif_source_target;
  75. <a name="l00140"></a>00140
  76. <a name="l00144"></a>00144 <span class="keywordtype">bool</span> set_vars_executed;
  77. <a name="l00145"></a>00145
  78. <a name="l00149"></a>00149 <span class="keywordtype">double</span> max_graph_flow;
  79. <a name="l00150"></a>00150
  80. <a name="l00154"></a>00154 <a class="code" href="a00020.html" title="A node in a graph.">node</a> net_source;
  81. <a name="l00155"></a>00155
  82. <a name="l00159"></a>00159 <a class="code" href="a00020.html" title="A node in a graph.">node</a> net_target;
  83. <a name="l00160"></a>00160
  84. <a name="l00164"></a>00164 list&lt;edge&gt; edges_not_org;
  85. <a name="l00165"></a>00165
  86. <a name="l00169"></a>00169 <a class="code" href="a00021.html" title="A specialized map with nodes as keys.">node_map&lt;int&gt;</a> dist_label;
  87. <a name="l00170"></a>00170
  88. <a name="l00174"></a>00174 <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;bool&gt;</a> edge_org;
  89. <a name="l00175"></a>00175
  90. <a name="l00179"></a>00179 <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;bool&gt;</a> back_edge_exists;
  91. <a name="l00180"></a>00180
  92. <a name="l00184"></a>00184 <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;edge&gt;</a> back_edge;
  93. <a name="l00185"></a>00185
  94. <a name="l00189"></a>00189 <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;double&gt;</a> edge_capacity;
  95. <a name="l00190"></a>00190
  96. <a name="l00194"></a>00194 <a class="code" href="a00011.html" title="A specialized map with edges as keys.">edge_map&lt;double&gt;</a> edge_max_flow;
  97. <a name="l00195"></a>00195
  98. <a name="l00199"></a>00199 <span class="keywordtype">void</span> create_artif_source_target(<a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G);
  99. <a name="l00200"></a>00200
  100. <a name="l00204"></a>00204 <span class="keywordtype">void</span> prepare_run(<span class="keyword">const</span> <a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G);
  101. <a name="l00205"></a>00205
  102. <a name="l00209"></a>00209 <span class="keywordtype">void</span> comp_dist_labels(<span class="keyword">const</span> <a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G, vector&lt;int&gt;&amp; numb);
  103. <a name="l00210"></a>00210
  104. <a name="l00214"></a>00214 <span class="keywordtype">bool</span> has_an_admissible_arc(<span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a> cur_node);
  105. <a name="l00215"></a>00215
  106. <a name="l00219"></a>00219 <span class="keywordtype">void</span> advance(<a class="code" href="a00020.html" title="A node in a graph.">node</a>&amp; cur_node, <a class="code" href="a00021.html" title="A specialized map with nodes as keys.">node_map&lt;edge&gt;</a>&amp; last_edge);
  107. <a name="l00220"></a>00220
  108. <a name="l00224"></a>00224 <span class="keywordtype">void</span> augment(<a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G, <span class="keyword">const</span> <a class="code" href="a00021.html" title="A specialized map with nodes as keys.">node_map&lt;edge&gt;</a>&amp; last_edge);
  109. <a name="l00225"></a>00225
  110. <a name="l00229"></a>00229 <span class="keywordtype">bool</span> retreat(<span class="keyword">const</span> <span class="keywordtype">int</span> number_of_nodes,
  111. <a name="l00230"></a>00230 <a class="code" href="a00020.html" title="A node in a graph.">node</a>&amp; cur_node,
  112. <a name="l00231"></a>00231 <span class="keyword">const</span> <a class="code" href="a00021.html" title="A specialized map with nodes as keys.">node_map&lt;edge&gt;</a>&amp; last_edge,
  113. <a name="l00232"></a>00232 vector&lt;int&gt;&amp; numb);
  114. <a name="l00233"></a>00233
  115. <a name="l00237"></a>00237 <span class="keywordtype">int</span> min_neighbour_label(<span class="keyword">const</span> <span class="keywordtype">int</span> number_of_nodes,
  116. <a name="l00238"></a>00238 <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a> cur_node) <span class="keyword">const</span>;
  117. <a name="l00239"></a>00239
  118. <a name="l00243"></a>00243 <span class="keywordtype">double</span> free_capacity(<span class="keyword">const</span> <a class="code" href="a00021.html" title="A specialized map with nodes as keys.">node_map&lt;edge&gt;</a>&amp; last_edge) <span class="keyword">const</span>;
  119. <a name="l00244"></a>00244
  120. <a name="l00248"></a>00248 <span class="keywordtype">void</span> create_back_edge(<a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G, <span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>&amp; org_edge);
  121. <a name="l00249"></a>00249
  122. <a name="l00253"></a>00253 <span class="keywordtype">void</span> comp_max_flow(<span class="keyword">const</span> <a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G);
  123. <a name="l00254"></a>00254
  124. <a name="l00258"></a>00258 <span class="keywordtype">void</span> restore_graph(<a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>&amp; G);
  125. <a name="l00259"></a>00259 };
  126. <a name="l00260"></a>00260
  127. <a name="l00261"></a>00261 __GTL_END_NAMESPACE
  128. <a name="l00262"></a>00262
  129. <a name="l00263"></a>00263 <span class="preprocessor">#endif // GTL_MAXFLOW_SAP_H</span>
  130. <a name="l00264"></a>00264 <span class="preprocessor"></span>
  131. <a name="l00265"></a>00265 <span class="comment">//--------------------------------------------------------------------------</span>
  132. <a name="l00266"></a>00266 <span class="comment">// end of file</span>
  133. <a name="l00267"></a>00267 <span class="comment">//--------------------------------------------------------------------------</span>
  134. </pre></div> <p class="links">
  135. <a href="http://www.uni-passau.de/">University of Passau</a>
  136. &nbsp;-&nbsp;
  137. <a href="http://www.fmi.uni-passau.de/">FMI</a>
  138. &nbsp;-&nbsp;
  139. <a href="http://www.fmi.uni-passau.de/fmi/lehrstuehle/brandenburg/">Theoretical
  140. Computer Science</a>
  141. </p>
  142. <div class="copyright">
  143. Design &copy; 2002, 2003 <a href="mailto:raitner@fmi.uni-passau.de">Marcus Raitner</a>, University of Passau
  144. </div>
  145. </body>
  146. </html>