graph_traits.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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>Boost Graph Library: Graph Traits</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=""></A>
  16. <pre>
  17. graph_traits&lt;<a href="./Graph.html">Graph</a>&gt;
  18. </pre>
  19. </H1>
  20. Just like the <a
  21. href="http://www.boost.org/sgi/stl/iterator_traits.html">
  22. iterators</a> of STL, graphs have <b>associated types</b>. As stated
  23. in the various <a href="./graph_concepts.html">graph concepts</a>, a
  24. graph has quite a few associated types: <tt>vertex_descriptor</tt>,
  25. <tt>edge_descriptor</tt>, <tt>out_edge_iterator</tt>, etc.. Any
  26. particular graph concepts will not require that all of the following
  27. associated types be defined. When implementing a graph class that
  28. fullfils one or more graph concepts, for associated types that are not
  29. required by the concepts, it is ok to use <tt>void</tt> as the type
  30. (when using nested typedefs inside the graph class), or to leave the
  31. typedef out of the <tt>graph_traits</tt> specialization for the graph
  32. class.
  33. Note that because of the use of traits classes rather than member
  34. types, it is not safe (and often will not work) to define subclasses of BGL
  35. graph types; those types may be missing important traits and properties that
  36. were defined externally to the class definition.
  37. <pre>
  38. template &lt;typename Graph&gt;
  39. struct graph_traits {
  40. typedef typename Graph::vertex_descriptor vertex_descriptor;
  41. typedef typename Graph::edge_descriptor edge_descriptor;
  42. typedef typename Graph::adjacency_iterator adjacency_iterator;
  43. typedef typename Graph::out_edge_iterator out_edge_iterator;
  44. typedef typename Graph::in_edge_iterator in_edge_iterator;
  45. typedef typename Graph::vertex_iterator vertex_iterator;
  46. typedef typename Graph::edge_iterator edge_iterator;
  47. typedef typename Graph::directed_category directed_category;
  48. typedef typename Graph::edge_parallel_category edge_parallel_category;
  49. typedef typename Graph::traversal_category traversal_category;
  50. typedef typename Graph::vertices_size_type vertices_size_type;
  51. typedef typename Graph::edges_size_type edges_size_type;
  52. typedef typename Graph::degree_size_type degree_size_type;
  53. };
  54. </pre>
  55. <h3>Where Defined</h3>
  56. <a href="../../../boost/graph/graph_traits.hpp"><tt>boost/graph/graph_traits.hpp</tt></a>
  57. <H3>Template Parameters</H3>
  58. <P>
  59. <TABLE border>
  60. <TR>
  61. <th>Parameter</th><th>Description</th>
  62. </tr>
  63. <TR><TD><TT>Graph</TT></TD>
  64. <TD>
  65. The graph type whose associated types are being accessed.
  66. </TD>
  67. </TR>
  68. </table>
  69. <h3>Model of</h3>
  70. <a
  71. href="http://www.boost.org/sgi/stl/DefaultConstructible.html">DefaultConstructible</a> and
  72. <a href="http://www.boost.org/sgi/stl/Assignable.html">Assignable</a>
  73. <h3>Type Requirements</h3>
  74. <ul>
  75. <li><tt>Graph</tt> is a model of one of the <a
  76. href="./graph_concepts.html">graph concepts</a>.
  77. </ul>
  78. <H2>Members</H2>
  79. <p>
  80. <table border>
  81. <tr>
  82. <th>Member</th><th>Description</th>
  83. </tr>
  84. <tr>
  85. <td><tt>
  86. vertex_descriptor
  87. </tt></td>
  88. <td>
  89. The type for the objects used to identity vertices in the graph.
  90. </td>
  91. </tr>
  92. <tr>
  93. <td><tt>
  94. edge_descriptor
  95. </tt></td>
  96. <td>
  97. The type for the objects used to identity edges in the graph.
  98. </td>
  99. </tr>
  100. <tr>
  101. <td><tt>
  102. adjacency_iterator
  103. </tt></td>
  104. <td>
  105. The type for the iterators that traverse the vertices adjacent
  106. to a vertex.
  107. </td>
  108. </tr>
  109. <tr>
  110. <td><tt>
  111. out_edge_iterator
  112. </tt></td>
  113. <td>
  114. The type for the iterators that traverse through the out-edges
  115. of a vertex.
  116. </td>
  117. </tr>
  118. <tr>
  119. <td><tt>
  120. in_edge_iterator
  121. </tt></td>
  122. <td>
  123. The type for the iterators that traverse through the in-edges
  124. of a vertex.
  125. </td>
  126. </tr>
  127. <tr>
  128. <td><tt>
  129. vertex_iterator
  130. </tt></td>
  131. <td>
  132. The type for the iterators that traverse through the complete vertex
  133. set of the graph.
  134. </td>
  135. </tr>
  136. <tr>
  137. <td><tt>
  138. edge_iterator
  139. </tt></td>
  140. <td>
  141. The type for the iterators that traverse through the complete edge
  142. set of the graph.
  143. </td>
  144. </tr>
  145. <tr>
  146. <td><tt>
  147. directed_category
  148. </tt></td>
  149. <td>
  150. This says whether the graph is undirected (<tt>undirected_tag</tt>)
  151. or directed (<tt>directed_tag</tt>).
  152. </td>
  153. </tr>
  154. <tr>
  155. <td><tt>
  156. edge_parallel_category
  157. </tt></td>
  158. <td>
  159. This says whether the graph allows parallel edges to be inserted
  160. (<tt>allow_parallel_edge_tag</tt>) or if it automatically removes
  161. parallel edges (<tt>disallow_parallel_edge_tag</tt>).
  162. </td>
  163. </tr>
  164. <tr>
  165. <td><tt>
  166. traversal_category
  167. </tt></td>
  168. <td>
  169. The ways in which the vertices in the graph can be traversed.
  170. The traversal category tags are:
  171. <tt>incidence_graph_tag, adjacency_graph_tag,
  172. bidirectional_graph_tag, vertex_list_graph_tag,
  173. edge_list_graph_tag, vertex_and_edge_list_graph_tag,
  174. adjacency_matrix_tag</tt>. You can also create your own
  175. tag which should inherit from one of the above.
  176. </td>
  177. </tr>
  178. <tr>
  179. <td><tt>
  180. vertices_size_type
  181. </tt></td>
  182. <td>
  183. The unsigned integer type used for representing the number of
  184. vertices in the graph.
  185. </td>
  186. </tr>
  187. <tr>
  188. <td><tt>
  189. edges_size_type
  190. </tt></td>
  191. <td>
  192. The unsigned integer type used for representing the number of
  193. edge in the graph.
  194. </td>
  195. </tr>
  196. <tr>
  197. <td><tt>
  198. degree_size_type
  199. </tt></td>
  200. <td>
  201. The unsigned integer type used for representing the degree
  202. of vertices in the graph.
  203. </td>
  204. </tr>
  205. </table>
  206. <br>
  207. <HR>
  208. <TABLE>
  209. <TR valign=top>
  210. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  211. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
  212. Indiana University (<A
  213. HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
  214. <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>
  215. <A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>,
  216. Indiana University (<A
  217. HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
  218. </TD></TR></TABLE>
  219. </BODY>
  220. </HTML>