IteratorConstructibleGraph.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
  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>IteratorConstructibleGraph</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="concept:IteratorConstructibleGraph"></A>
  16. IteratorConstructibleGraph
  17. </H1>
  18. The IteratorConstructibleGraph concept describes the interface for
  19. graph types that can be constructed using a kind of edge iterator. The
  20. edge iterator can be any <a
  21. href="http://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>
  22. that dereferences to a pair of integers <i>(i,j)</i>, which represent
  23. an edge that should be in the graph. The two integers <i>i</i> and
  24. <i>j</i> represent vertices where <i>0 <= i < |V|</i> and <i>0 <= j <
  25. |V|</i>. The edge iterator's value type should be
  26. <tt>std::pair&lt;T,T&gt;</tt> (or at least be a structure that has
  27. members <tt>first</tt> and <tt>second</tt>) and the value type
  28. <tt>T</tt> of the pair must be convertible to the
  29. <tt>vertices_size_type</tt> of the graph (an integer).
  30. There are two valid expressions required by this concept, both of
  31. which are constructors. The first creates a graph object from a
  32. first/last iterator range. The second constructor also takes a
  33. first/last iterator range and in addition requires the number of
  34. vertices and number of edges. For some graph and edge iterator types
  35. the second constructor can be more efficient than the first.
  36. <h3>Example</h3>
  37. The following exampe creates two graph objects from an array of edges
  38. (vertex pairs). The type <tt>Edge*</tt> satisfies the requirements for
  39. an <a
  40. href="http://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>
  41. and can therefore be used to construct a graph.
  42. <pre>
  43. typedef ... IteratorConstructibleGraph;
  44. typedef boost::graph_traits<IteratorConstructibleGraph> Traits;
  45. typedef std::pair<Traits::vertices_size_type,
  46. Traits::vertices_size_type> Edge;
  47. Edge edge_array[] =
  48. { Edge(0,1), Edge(0,2), Edge(0,3), Edge(0,4), Edge(0,5),
  49. Edge(1, 2), Edge(1,5), Edge(1,3),
  50. Edge(2, 4), Edge(2,5),
  51. Edge(3, 2),
  52. Edge(4, 3), Edge(4,1),
  53. Edge(5, 4) };
  54. Edge* first = edge_array,
  55. last = edge_array + sizeof(edge_array)/sizeof(Edge);
  56. IteratorConstructibleGraph G1(first, last);
  57. // do something with G1 ...
  58. Traits::vertices_size_type size_V = 6;
  59. Traits::edges_size_type size_E = sizeof(edge_array)/sizeof(Edge);
  60. IteratorConstructibleGraph G2(first, last, size_V, size_E);
  61. // do something with G2 ...
  62. </pre>
  63. <h3>Refinement of</h3>
  64. <a href="Graph.html">Graph</a>
  65. <h3>Notation</h3>
  66. <Table>
  67. <tr>
  68. <td><tt>G</tt></td>
  69. <td>is a graph type that models IteratorConstructibleGraph.</td>
  70. <tr>
  71. <tr>
  72. <td><tt>g</tt></td>
  73. <td>is an object of type <tt>G</tt>.</td>
  74. </tr>
  75. <tr>
  76. <td><tt>first, last</tt></td>
  77. <td>are edge iterators (see above).</td>
  78. </tr>
  79. <tr>
  80. <td><tt>Tr</tt></td>
  81. <td>is an object of type <tt>graph_traits&lt;G&gt;</tt>.</td>
  82. </tr>
  83. <tr>
  84. <td><tt>n_vertices</tt></td>
  85. <td>is an object of type <tt>Tr::vertices_size_type</tt>.</td>
  86. </tr>
  87. <tr>
  88. <td><tt>n_edges</tt></td>
  89. <td>is an object of type <tt>Tr::edges_size_type</tt>.</td>
  90. </tr>
  91. </Table>
  92. <h3>Valid Expressions</h3>
  93. <Table border>
  94. <tr>
  95. <td>
  96. <pre>G g(first, last);</pre>
  97. Construct graph object <tt>g</tt> given an edge range <tt>[first,last)</tt>.
  98. </td>
  99. <tr>
  100. <tr>
  101. <td>
  102. <pre>G g(first, last, n_vertices, n_edges);</pre>
  103. Construct graph object <tt>g</tt> given an edge range
  104. <tt>[first,last)</tt>, the number of vertices, and the number of
  105. edges. Sometimes this constructor is more efficient than the
  106. constructor lacking the graph size information.
  107. </td>
  108. </tr>
  109. </Table>
  110. <!--
  111. <H3>Concept Checking Class</H3>
  112. <PRE>
  113. </PRE>
  114. -->
  115. <br>
  116. <HR>
  117. <TABLE>
  118. <TR valign=top>
  119. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  120. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
  121. Indiana University (<A
  122. HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
  123. <A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
  124. <A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>,
  125. Indiana University (<A
  126. HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
  127. </TD></TR></TABLE>
  128. </BODY>
  129. </HTML>