1 | <HTML> |
---|
2 | <!-- |
---|
3 | -- Copyright (c) Jeremy Siek 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>Graph</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 | <H2><A NAME="concept:Graph"></A> |
---|
19 | Graph |
---|
20 | </H2> |
---|
21 | |
---|
22 | <P> |
---|
23 | The Graph concept contains a few requirements that are common to all |
---|
24 | the graph concepts. These include some associated types for |
---|
25 | <tt>vertex_descriptor</tt>, <tt>edge_descriptor</tt>, etc. One should |
---|
26 | note that a model of Graph is <B>not</B> required to be a model of <a |
---|
27 | href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, |
---|
28 | so algorithms should pass graph objects by reference. |
---|
29 | |
---|
30 | <P> |
---|
31 | |
---|
32 | <h3>Notation</h3> |
---|
33 | |
---|
34 | <Table> |
---|
35 | <TR> |
---|
36 | <TD><tt>G</tt></TD> |
---|
37 | <TD>A type that is a model of Graph.</TD> |
---|
38 | </TR> |
---|
39 | |
---|
40 | <TR> |
---|
41 | <TD><tt>g</tt></TD> |
---|
42 | <TD>An object of type <tt>G</tt>.</TD> |
---|
43 | </TR> |
---|
44 | </table> |
---|
45 | |
---|
46 | <H3>Associated Types</H3> |
---|
47 | |
---|
48 | <table border> |
---|
49 | <tr> |
---|
50 | <td><pre>boost::graph_traits<G>::vertex_descriptor</pre> |
---|
51 | A vertex descriptor corresponds to a unique vertex in an abstract |
---|
52 | graph instance. A vertex descriptor must be |
---|
53 | <a |
---|
54 | href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructible</a>, |
---|
55 | <a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, and |
---|
56 | <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a>. |
---|
57 | </td> |
---|
58 | </tr> |
---|
59 | |
---|
60 | <tr> |
---|
61 | <td><pre>boost::graph_traits<G>::edge_descriptor</pre> |
---|
62 | An edge descriptor corresponds to a unique edge <i>(u,v)</i> in a |
---|
63 | graph. An edge descriptor must be <a |
---|
64 | href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructible</I>, |
---|
65 | <a |
---|
66 | href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, |
---|
67 | and <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a>. |
---|
68 | </td> |
---|
69 | </tr> |
---|
70 | |
---|
71 | <tr> |
---|
72 | <td><pre>boost::graph_traits<G>::directed_category</pre> |
---|
73 | This type shall be convertible to <TT>directed_tag</TT> or <TT>undirected_tag</TT>. |
---|
74 | </td> |
---|
75 | </tr> |
---|
76 | |
---|
77 | <tr> |
---|
78 | <td><pre>boost::graph_traits<G>::edge_parallel_category</pre> |
---|
79 | This describes whether the graph class allows the insertion of |
---|
80 | parallel edges (edges with the same source and target). The two tags |
---|
81 | are <TT>allow_parallel_edge_tag</TT> and <TT>disallow_parallel_edge_tag</TT>. |
---|
82 | </td> |
---|
83 | </tr> |
---|
84 | |
---|
85 | <tr> |
---|
86 | <td><pre>boost::graph_traits<G>::traversal_category</pre> |
---|
87 | This describes the ways in which the vertices and edges of the |
---|
88 | graph can be visited. The choices are <TT>incidence_graph_tag</TT>, |
---|
89 | <TT>adjacency_graph_tag</TT>, <TT>bidirectional_graph_tag</TT>, |
---|
90 | <TT>vertex_list_graph_tag</TT>, <TT>edge_list_graph_tag</TT>, and |
---|
91 | <TT>adjacency_matrix_tag</TT>. |
---|
92 | </td> |
---|
93 | </tr> |
---|
94 | |
---|
95 | </table> |
---|
96 | |
---|
97 | <H3>Valid Expressions</H3> |
---|
98 | |
---|
99 | <table border> |
---|
100 | |
---|
101 | <tr> |
---|
102 | <td><pre>boost::graph_traits<G>::null_vertex()</pre></td></TD> |
---|
103 | <td> |
---|
104 | Returns a special <tt>boost::graph_traits<G>::vertex_descriptor</tt> object which does not refer to |
---|
105 | any vertex of graph object which type is <tt>G</tt>. |
---|
106 | <td> |
---|
107 | </tr> |
---|
108 | </table> |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | <H3>Concept Checking Class</H3> |
---|
113 | |
---|
114 | <PRE> |
---|
115 | template <class G> |
---|
116 | struct GraphConcept |
---|
117 | { |
---|
118 | typedef typename boost::graph_traits<G>::vertex_descriptor vertex_descriptor; |
---|
119 | typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor; |
---|
120 | typedef typename boost::graph_traits<G>::directed_category directed_category; |
---|
121 | typedef typename boost::graph_traits<G>::edge_parallel_category edge_parallel_category; |
---|
122 | typedef typename boost::graph_traits<G>::traversal_category traversal_category; |
---|
123 | |
---|
124 | void constraints() { |
---|
125 | function_requires< DefaultConstructibleConcept<vertex_descriptor> >(); |
---|
126 | function_requires< EqualityComparableConcept<vertex_descriptor> >(); |
---|
127 | function_requires< AssignableConcept<vertex_descriptor> >(); |
---|
128 | function_requires< DefaultConstructibleConcept<edge_descriptor> >(); |
---|
129 | function_requires< EqualityComparableConcept<edge_descriptor> >(); |
---|
130 | function_requires< AssignableConcept<edge_descriptor> >(); |
---|
131 | } |
---|
132 | G g; |
---|
133 | }; |
---|
134 | </PRE> |
---|
135 | |
---|
136 | <H3>See Also</H3> |
---|
137 | |
---|
138 | <a href="./graph_concepts.html">Graph concepts</a> |
---|
139 | |
---|
140 | <br> |
---|
141 | <HR> |
---|
142 | <TABLE> |
---|
143 | <TR valign=top> |
---|
144 | <TD nowrap>Copyright © 2000-2001</TD><TD> |
---|
145 | <A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>) |
---|
146 | </TD></TR></TABLE> |
---|
147 | |
---|
148 | </BODY> |
---|
149 | </HTML> |
---|