read_dimacs.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <HTML>
  2. <!--
  3. // Copyright (c) 2006, Stephan Diederich
  4. // Copyright (c) 2010, Trustees of Indiana University
  5. //
  6. // This code may be used under either of the following two licences:
  7. //
  8. // Permission is hereby granted, free of charge, to any person
  9. // obtaining a copy of this software and associated documentation
  10. // files (the "Software"), to deal in the Software without
  11. // restriction, including without limitation the rights to use,
  12. // copy, modify, merge, publish, distribute, sublicense, and/or
  13. // sell copies of the Software, and to permit persons to whom the
  14. // Software is furnished to do so, subject to the following
  15. // conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  22. // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  24. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  25. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  27. // OTHER DEALINGS IN THE SOFTWARE. OF SUCH DAMAGE.
  28. //
  29. // Or:
  30. //
  31. // Distributed under the Boost Software License, Version 1.0.
  32. // (See accompanying file LICENSE_1_0.txt or copy at
  33. // http://www.boost.org/LICENSE_1_0.txt)
  34. -->
  35. <Head>
  36. <Title>Boost Graph Library: read_dimacs_max_flow and read_dimacs_min_cut</Title>
  37. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  38. ALINK="#ff0000">
  39. <IMG SRC="../../../boost.png"
  40. ALT="C++ Boost" width="277" height="86">
  41. <BR Clear>
  42. <H1><A NAME="sec:read_dimacs_max_flow">
  43. <TT>read_dimacs_max_flow</TT>
  44. </H1>
  45. <pre>
  46. //reads a graph with attached edge_capacity properties from an std::istream
  47. template &lt;class Graph, class CapacityMap, class ReverseEdgeMap&gt;
  48. int read_dimacs_max_flow(Graph&amp; g,
  49. CapacityMap capacity,
  50. ReverseEdgeMap reverse_edge,
  51. typename graph_traits<Graph>::vertex_descriptor&amp; src,
  52. typename graph_traits<Graph>::vertex_descriptor&amp; sink,
  53. std::istream&amp; in=std::cin)
  54. //reads a graph with attached edge_capacity properties from an std::istream
  55. template &lt;class Graph, class CapacityMap, class ReverseEdgeMap&gt;
  56. int read_dimacs_min_cut(Graph&amp; g,
  57. CapacityMap capacity,
  58. ReverseEdgeMap reverse_edge,
  59. std::istream&amp; in=std::cin)
  60. </pre>
  61. <p>
  62. These functions read a BGL graph object from a max-flow or min-cut problem description in extended dimacs format. (see <a href="https://web.archive.org/web/20120102213028/http://www.avglab.com/andrew/CATS/maxflow_formats.htm"><TT>Goldberg's site</TT></a> for more information). For each edge found in the
  63. file an additional reverse_edge is added and set in the reverse_edge map. For
  64. max-flow problems, source and sink vertex descriptors are set according to the
  65. dimacs file.
  66. <H3>Where Defined</H3>
  67. <P>
  68. <a href="../../../boost/graph/read_dimacs.hpp"><TT>boost/graph/read_dimacs.hpp</TT></a>
  69. <h3>Parameters</h3>
  70. IN: <tt>Graph&amp; g</tt>
  71. <blockquote>
  72. A directed or undirected graph. The graph's type must be a model of <a href="./IncidenceGraph.html">IncidenceGraph</a>.
  73. </blockquote>
  74. OUT: <tt>CapacityMap capacity</tt>
  75. <blockquote>
  76. A property map that models <a href="../../property_map/doc/LvaluePropertyMap.html">mutable Lvalue Property Map</a> whose key type is the edge descriptor of the graph. <br>
  77. </blockquote>
  78. OUT: <tt>ReverseEdgeMap reverse_edge</tt>
  79. <blockquote>
  80. A property map that models <a href="../../property_map/doc/LvaluePropertyMap.html">mutable Lvalue Property Map</a> whose key and value type is the edge descriptor of the graph. This map stores the corresponding reverse edge for each each in Graph g.<br>
  81. </blockquote>
  82. OUT: <tt>vertex_descriptor&amp; src</tt>
  83. <blockquote>
  84. A graph vertex that will be set to the source of a max-flow problem.
  85. </blockquote>
  86. OUT: <tt>vertex_descriptor&amp; sink</tt>
  87. <blockquote>
  88. A graph vertex that will be set to the sink of a max-flow problem.
  89. </blockquote>
  90. IN: <tt>std::istream&amp; in</tt>
  91. <blockquote>
  92. A standard <tt>std::istream</tt> object. <br>
  93. <b>Default</b>: <tt>std::cin (for backward compatibility)</tt>
  94. </blockquote>
  95. <H3>
  96. Example
  97. </H3>
  98. A short <a href="../example/read_write_dimacs-eg.cpp">example</a> which uses read_dimacs and write_dimacs is located in the examples directory.
  99. <h3>See Also</h3>
  100. <a href="./write_dimacs.html"><tt>write_dimacs</tt></a>
  101. </BODY>
  102. </HTML>