| 1 | <HTML> |
|---|
| 2 | <!-- |
|---|
| 3 | -- Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000 |
|---|
| 4 | -- |
|---|
| 5 | -- Distributed under the Boost Software License, Version 1.0. |
|---|
| 6 | -- (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 7 | -- http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 8 | --> |
|---|
| 9 | <Head> |
|---|
| 10 | <Title>Boost Graph Library: Graph Traits</Title> |
|---|
| 11 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" |
|---|
| 12 | ALINK="#ff0000"> |
|---|
| 13 | <IMG SRC="../../../boost.png" |
|---|
| 14 | ALT="C++ Boost" width="277" height="86"> |
|---|
| 15 | |
|---|
| 16 | <BR Clear> |
|---|
| 17 | |
|---|
| 18 | <H1><A NAME=""></A> |
|---|
| 19 | <pre> |
|---|
| 20 | graph_traits<<a href="./Graph.html">Graph</a>> |
|---|
| 21 | </pre> |
|---|
| 22 | </H1> |
|---|
| 23 | |
|---|
| 24 | Just like the <a |
|---|
| 25 | href="http://www.sgi.com/tech/stl/iterator_traits.html"> |
|---|
| 26 | iterators</a> of STL, graphs have <b>associated types</b>. As stated |
|---|
| 27 | in the various <a href="./graph_concepts.html">graph concepts</a>, a |
|---|
| 28 | graph has quite a few associated types: <tt>vertex_descriptor</tt>, |
|---|
| 29 | <tt>edge_descriptor</tt>, <tt>out_edge_iterator</tt>, etc.. Any |
|---|
| 30 | particular graph concepts will not require that all of the following |
|---|
| 31 | associated types be defined. When implementing a graph class that |
|---|
| 32 | fullfils one or more graph concepts, for associated types that are not |
|---|
| 33 | required by the concepts, it is ok to use <tt>void</tt> as the type |
|---|
| 34 | (when using nested typedefs inside the graph class), or to leave the |
|---|
| 35 | typedef out of the <tt>graph_traits</tt> specialization for the graph |
|---|
| 36 | class. |
|---|
| 37 | |
|---|
| 38 | <pre> |
|---|
| 39 | template <typename Graph> |
|---|
| 40 | struct graph_traits { |
|---|
| 41 | typedef typename Graph::vertex_descriptor vertex_descriptor; |
|---|
| 42 | typedef typename Graph::edge_descriptor edge_descriptor; |
|---|
| 43 | typedef typename Graph::adjacency_iterator adjacency_iterator; |
|---|
| 44 | typedef typename Graph::out_edge_iterator out_edge_iterator; |
|---|
| 45 | typedef typename Graph::in_edge_iterator in_edge_iterator; |
|---|
| 46 | typedef typename Graph::vertex_iterator vertex_iterator; |
|---|
| 47 | typedef typename Graph::edge_iterator edge_iterator; |
|---|
| 48 | |
|---|
| 49 | typedef typename Graph::directed_category directed_category; |
|---|
| 50 | typedef typename Graph::edge_parallel_category edge_parallel_category; |
|---|
| 51 | typedef typename Graph::traversal_category traversal_category; |
|---|
| 52 | |
|---|
| 53 | typedef typename Graph::vertices_size_type vertices_size_type; |
|---|
| 54 | typedef typename Graph::edges_size_type edges_size_type; |
|---|
| 55 | typedef typename Graph::degree_size_type degree_size_type; |
|---|
| 56 | }; |
|---|
| 57 | </pre> |
|---|
| 58 | |
|---|
| 59 | <h3>Where Defined</h3> |
|---|
| 60 | |
|---|
| 61 | <a href="../../../boost/graph/graph_traits.hpp"><tt>boost/graph/graph_traits.hpp</tt></a> |
|---|
| 62 | |
|---|
| 63 | <H3>Template Parameters</H3> |
|---|
| 64 | |
|---|
| 65 | <P> |
|---|
| 66 | <TABLE border> |
|---|
| 67 | <TR> |
|---|
| 68 | <th>Parameter</th><th>Description</th> |
|---|
| 69 | </tr> |
|---|
| 70 | |
|---|
| 71 | <TR><TD><TT>Graph</TT></TD> |
|---|
| 72 | <TD> |
|---|
| 73 | The graph type whose associated types are being accessed. |
|---|
| 74 | </TD> |
|---|
| 75 | </TR> |
|---|
| 76 | |
|---|
| 77 | </table> |
|---|
| 78 | |
|---|
| 79 | <h3>Model of</h3> |
|---|
| 80 | |
|---|
| 81 | <a |
|---|
| 82 | href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a> and |
|---|
| 83 | <a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a> |
|---|
| 84 | |
|---|
| 85 | <h3>Type Requirements</h3> |
|---|
| 86 | |
|---|
| 87 | <ul> |
|---|
| 88 | <li><tt>Graph</tt> is a model of one of the <a |
|---|
| 89 | href="./graph_concepts.html">graph concepts</a>. |
|---|
| 90 | </ul> |
|---|
| 91 | |
|---|
| 92 | <H2>Members</H2> |
|---|
| 93 | |
|---|
| 94 | <p> |
|---|
| 95 | |
|---|
| 96 | <table border> |
|---|
| 97 | <tr> |
|---|
| 98 | <th>Member</th><th>Description</th> |
|---|
| 99 | </tr> |
|---|
| 100 | |
|---|
| 101 | <tr> |
|---|
| 102 | <td><tt> |
|---|
| 103 | vertex_descriptor |
|---|
| 104 | </tt></td> |
|---|
| 105 | <td> |
|---|
| 106 | The type for the objects used to identity vertices in the graph. |
|---|
| 107 | </td> |
|---|
| 108 | </tr> |
|---|
| 109 | |
|---|
| 110 | <tr> |
|---|
| 111 | <td><tt> |
|---|
| 112 | edge_descriptor |
|---|
| 113 | </tt></td> |
|---|
| 114 | <td> |
|---|
| 115 | The type for the objects used to identity edges in the graph. |
|---|
| 116 | </td> |
|---|
| 117 | </tr> |
|---|
| 118 | |
|---|
| 119 | <tr> |
|---|
| 120 | <td><tt> |
|---|
| 121 | adjacency_iterator |
|---|
| 122 | </tt></td> |
|---|
| 123 | <td> |
|---|
| 124 | The type for the iterators that traverse the vertices adjacent |
|---|
| 125 | to a vertex. |
|---|
| 126 | </td> |
|---|
| 127 | </tr> |
|---|
| 128 | |
|---|
| 129 | <tr> |
|---|
| 130 | <td><tt> |
|---|
| 131 | out_edge_iterator |
|---|
| 132 | </tt></td> |
|---|
| 133 | <td> |
|---|
| 134 | The type for the iterators that traverse through the out-edges |
|---|
| 135 | of a vertex. |
|---|
| 136 | </td> |
|---|
| 137 | </tr> |
|---|
| 138 | |
|---|
| 139 | <tr> |
|---|
| 140 | <td><tt> |
|---|
| 141 | in_edge_iterator |
|---|
| 142 | </tt></td> |
|---|
| 143 | <td> |
|---|
| 144 | The type for the iterators that traverse through the in-edges |
|---|
| 145 | of a vertex. |
|---|
| 146 | </td> |
|---|
| 147 | </tr> |
|---|
| 148 | |
|---|
| 149 | <tr> |
|---|
| 150 | <td><tt> |
|---|
| 151 | vertex_iterator |
|---|
| 152 | </tt></td> |
|---|
| 153 | <td> |
|---|
| 154 | The type for the iterators that traverse through the complete vertex |
|---|
| 155 | set of the graph. |
|---|
| 156 | </td> |
|---|
| 157 | </tr> |
|---|
| 158 | |
|---|
| 159 | <tr> |
|---|
| 160 | <td><tt> |
|---|
| 161 | edge_iterator |
|---|
| 162 | </tt></td> |
|---|
| 163 | <td> |
|---|
| 164 | The type for the iterators that traverse through the complete edge |
|---|
| 165 | set of the graph. |
|---|
| 166 | </td> |
|---|
| 167 | </tr> |
|---|
| 168 | |
|---|
| 169 | <tr> |
|---|
| 170 | <td><tt> |
|---|
| 171 | directed_category |
|---|
| 172 | </tt></td> |
|---|
| 173 | <td> |
|---|
| 174 | This says whether the graph is undirected (<tt>undirected_tag</tt>) |
|---|
| 175 | or directed (<tt>directed_tag</tt>). |
|---|
| 176 | </td> |
|---|
| 177 | </tr> |
|---|
| 178 | |
|---|
| 179 | <tr> |
|---|
| 180 | <td><tt> |
|---|
| 181 | edge_parallel_category |
|---|
| 182 | </tt></td> |
|---|
| 183 | <td> |
|---|
| 184 | This says whether the graph allows parallel edges to be inserted |
|---|
| 185 | (<tt>allow_parallel_edge_tag</tt>) or if it automatically removes |
|---|
| 186 | parallel edges (<tt>disallow_parallel_edge_tag</tt>). |
|---|
| 187 | </td> |
|---|
| 188 | </tr> |
|---|
| 189 | |
|---|
| 190 | <tr> |
|---|
| 191 | <td><tt> |
|---|
| 192 | traversal_category |
|---|
| 193 | </tt></td> |
|---|
| 194 | <td> |
|---|
| 195 | The ways in which the vertices in the graph can be traversed. |
|---|
| 196 | The traversal category tags are: |
|---|
| 197 | <tt>incidence_graph_tag, adjacency_graph_tag, |
|---|
| 198 | bidirectional_graph_tag, vertex_list_graph_tag, |
|---|
| 199 | edge_list_graph_tag, vertex_and_edge_list_graph_tag, |
|---|
| 200 | adjacency_matrix_tag</tt>. You can also create your own |
|---|
| 201 | tag which should inherit from one of the above. |
|---|
| 202 | </td> |
|---|
| 203 | </tr> |
|---|
| 204 | |
|---|
| 205 | <tr> |
|---|
| 206 | <td><tt> |
|---|
| 207 | vertices_size_type |
|---|
| 208 | </tt></td> |
|---|
| 209 | <td> |
|---|
| 210 | The unsigned integer type used for representing the number of |
|---|
| 211 | vertices in the graph. |
|---|
| 212 | </td> |
|---|
| 213 | </tr> |
|---|
| 214 | |
|---|
| 215 | <tr> |
|---|
| 216 | <td><tt> |
|---|
| 217 | edge_size_type |
|---|
| 218 | </tt></td> |
|---|
| 219 | <td> |
|---|
| 220 | The unsigned integer type used for representing the number of |
|---|
| 221 | edge in the graph. |
|---|
| 222 | </td> |
|---|
| 223 | </tr> |
|---|
| 224 | |
|---|
| 225 | <tr> |
|---|
| 226 | <td><tt> |
|---|
| 227 | degree_size_type |
|---|
| 228 | </tt></td> |
|---|
| 229 | <td> |
|---|
| 230 | The unsigned integer type used for representing the degree |
|---|
| 231 | of vertices in the graph. |
|---|
| 232 | </td> |
|---|
| 233 | </tr> |
|---|
| 234 | |
|---|
| 235 | </table> |
|---|
| 236 | |
|---|
| 237 | <br> |
|---|
| 238 | <HR> |
|---|
| 239 | <TABLE> |
|---|
| 240 | <TR valign=top> |
|---|
| 241 | <TD nowrap>Copyright © 2000-2001</TD><TD> |
|---|
| 242 | <A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, |
|---|
| 243 | Indiana University (<A |
|---|
| 244 | HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br> |
|---|
| 245 | <A HREF="../../../people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br> |
|---|
| 246 | <A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>, |
|---|
| 247 | Indiana University (<A |
|---|
| 248 | HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>) |
|---|
| 249 | </TD></TR></TABLE> |
|---|
| 250 | |
|---|
| 251 | </BODY> |
|---|
| 252 | </HTML> |
|---|