VertexListGraph.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek 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>VertexListGraph</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. <H2><A NAME="concept:VertexListGraph">
  16. VertexListGraph
  17. </H2>
  18. The <I>VertexListGraph</I> concept refines the <a
  19. href="./Graph.html">Graph</a> concept, and adds the requirement for
  20. efficient traversal of all the vertices in the graph.
  21. <H3>Refinement of</H3>
  22. <a href="./Graph.html">Graph</a>
  23. <H3>Associated Types</H3>
  24. <Table border>
  25. <tr>
  26. <td><tt>boost::graph_traits&lt;G&gt;::traversal_category</tt><br><br>
  27. This tag type must be convertible to <tt>vertex_list_graph_tag</tt>.
  28. </td>
  29. </tr>
  30. <TR>
  31. <TD><tt>boost::graph_traits&lt;G&gt;::vertex_iterator</tt><br><br>
  32. A vertex iterator (obtained via <TT>vertices(g)</TT>) provides access
  33. to all of the vertices in a graph. A vertex iterator type must meet
  34. the requirements of <a
  35. href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>. The
  36. value type of the vertex iterator must be the vertex descriptor of the
  37. graph.
  38. </TD>
  39. </TR>
  40. <tr>
  41. <td><tt>boost::graph_traits&lt;G&gt;::vertices_size_type</tt><br><br>
  42. The unsigned integer type used to represent the number of vertices
  43. in the graph.
  44. </td>
  45. </tr>
  46. </table>
  47. <h3>Valid Expressions</h3>
  48. <table border>
  49. <tr>
  50. <th>Name</th><th>Expression</th><th>Return Type</th><th>Description</th>
  51. </tr>
  52. <tr>
  53. <td>Vertex Set of the Graph</td>
  54. <td><a name="sec:vertices"><TT>vertices(g)</TT></a></TD>
  55. <TD><TT>std::pair&lt;vertex_iterator,&nbsp;vertex_iterator&gt;</TT></TD>
  56. <TD>
  57. Returns an iterator-range providing access to all the vertices in the
  58. graph<TT>g</TT>.
  59. </TD>
  60. </TR>
  61. <tr>
  62. <td>Number of Vertices in the Graph </td>
  63. <td><TT>num_vertices(g)</TT></TD>
  64. <TD><TT>vertices_size_type</TT></TD>
  65. <TD>Returns the number of vertices in the graph <TT>g</TT>.</TD>
  66. </TR>
  67. </TABLE>
  68. <H3>Complexity guarantees</H3>
  69. <P>
  70. The <TT>vertices()</TT> function must return in constant time.
  71. <H3>See Also</H3>
  72. <a href="./graph_concepts.html">Graph concepts</a>
  73. <H3>Design Rationale</H3>
  74. One issue in the design of this concept is whether to include the
  75. refinement from the <a href="./IncidenceGraph.html">IncidenceGraph</a>
  76. and <a href="./AdjacencyGraph.html">AdjacencyGraph</a> concepts. The
  77. ability to traverse the vertices of a graph is orthogonal to
  78. traversing out-edges, so it would make sense to have a VertexListGraph
  79. concept that only includes vertex traversal. However, such a concept
  80. would no longer really be a graph, but would just be a set, and the
  81. STL already has concepts for dealing with such things. However, there
  82. are many BGL algorithms that need to traverse the vertices and
  83. out-edges of a graph, so for convenience a concept is needed that
  84. groups these requirements together, hence the VertexListGraph concept.
  85. <H3>Concept Checking Class</H3>
  86. <P>
  87. <PRE>
  88. template &lt;class G&gt;
  89. struct VertexListGraphConcept
  90. {
  91. typedef typename boost::graph_traits&lt;G&gt;::vertex_iterator
  92. vertex_iterator;
  93. void constraints() {
  94. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept&lt;G&gt; ));
  95. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept&lt;G&gt; ));
  96. BOOST_CONCEPT_ASSERT(( MultiPassInputIteratorConcept&lt;vertex_iterator&gt; ));
  97. p = vertices(g);
  98. V = num_vertices(g);
  99. v = *p.first;
  100. const_constraints(g);
  101. }
  102. void const_constraints(const G&amp; g) {
  103. p = vertices(g);
  104. V = num_vertices(g);
  105. v = *p.first;
  106. }
  107. std::pair&lt;vertex_iterator, vertex_iterator&gt; p;
  108. typename boost::graph_traits&lt;G&gt;::vertex_descriptor v;
  109. typename boost::graph_traits&lt;G&gt;::vertices_size_type V;
  110. G g;
  111. };
  112. </PRE>
  113. <br>
  114. <HR>
  115. <TABLE>
  116. <TR valign=top>
  117. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  118. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
  119. </TD></TR></TABLE>
  120. </BODY>
  121. </HTML>