]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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>PropertyGraph</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:PropertyGraph"></A> | |
19 | PropertyGraph | |
20 | </H2> | |
21 | ||
22 | A PropertyGraph is a graph that has some property associated with each | |
23 | of the vertices or edges in the graph. As a given graph may have | |
24 | several properties associated with each vertex or edge, a tag is used | |
25 | to identify which property is being accessed. The graph provides a | |
26 | function which returns a property map object. | |
27 | ||
28 | <P> | |
29 | ||
30 | <H3>Refinement of</H3> | |
31 | ||
32 | <a href="./Graph.html">Graph</a> | |
33 | ||
34 | <h3>Notation</h3> | |
35 | ||
36 | <Table> | |
37 | <TR> | |
38 | <TD><tt>G</tt></TD> | |
39 | <TD>A type that is a model of PropertyGraph.</TD> | |
40 | </TR> | |
41 | ||
42 | <TR> | |
43 | <TD><tt>g</tt></TD> | |
44 | <TD>An object of type <tt>G</tt>.</TD> | |
45 | </TR> | |
46 | ||
47 | <TR> | |
48 | <TD><tt>X</tt></TD> | |
49 | <TD>Either the vertex or edge descriptor type for <tt>G</tt>.</TD> | |
50 | </TR> | |
51 | ||
52 | <TR> | |
53 | <TD><tt>x</tt></TD> | |
54 | <TD>An object of type <tt>X</tt>.</TD> | |
55 | </TR> | |
56 | ||
57 | ||
58 | <TR> | |
59 | <TD><tt>Map</tt></TD> | |
60 | <TD>The type <tt>boost::property_map<G, Property>::const_type</tt>.</TD> | |
61 | </TR> | |
62 | ||
63 | <TR> | |
64 | <TD><tt>v</tt></TD> | |
65 | <TD>An object of type <tt>boost::property_traits<Map>::value_type</tt>.</TD> | |
66 | </TR> | |
67 | ||
68 | <TR> | |
69 | <TD><tt>PropertyTag</tt></TD> | |
70 | <TD>A type that models the <a href="./PropertyTag.html">PropertyTag</a> concept.</TD> | |
71 | </TR> | |
72 | ||
73 | <TR> | |
74 | <TD><tt>p</tt></TD> | |
75 | <TD>An object of type <tt>PropertyTag</tt>.</td> | |
76 | </TR> | |
77 | ||
78 | <TR> | |
79 | <TD><tt>pmap</tt></TD> | |
80 | <TD>An object of type <tt>Map</tt>.</td> | |
81 | </TR> | |
82 | ||
83 | </table> | |
84 | ||
85 | <H3>Associated types</H3> | |
86 | ||
87 | <table border> | |
88 | ||
89 | <tr> | |
90 | <td><pre>boost::property_map<G, PropertyTag>::type</pre> | |
91 | The type of the property map for the property specified by | |
92 | <TT>PropertyTag</TT>. This type must be a model of <a | |
93 | href="../../property_map/doc/ReadWritePropertyMap.html">ReadWritePropertyMap</a> | |
94 | with a key type the same as the graph's vertex or edge descriptor type. | |
95 | </td> | |
96 | </tr> | |
97 | ||
98 | <tr> | |
99 | <td><pre>boost::property_map<G, PropertyTag>::const_type</pre> | |
100 | The type of the const property map for the property specified by | |
101 | <TT>PropertyTag</TT>. This type must be a model of <a | |
102 | href="../../property_map/doc/ReadablePropertyMap.html">ReadablePropertyMap</a> | |
103 | with a key type the same as the graph's vertex or edge descriptor type. | |
104 | </td> | |
105 | </tr> | |
106 | ||
107 | </table> | |
108 | ||
109 | <h3>Valid Expressions</h3> | |
110 | ||
111 | <table border> | |
112 | ||
113 | <tr> | |
114 | <td> <TT>get(p, g)</TT> </td> | |
115 | <td> | |
116 | Returns the property map for the property specified by the | |
117 | <tt>PropertyTag</tt> type. The object <tt>p</tt> is only used to | |
118 | carry the type.<br> | |
119 | Return type: <TT>boost::property_map<G, PropertyTag>::type</TT> if <TT>g</TT> is mutable and <br><TT>boost::property_map<G, PropertyTag>::const_type</TT> otherwise. | |
120 | </td> | |
121 | </TR> | |
122 | ||
123 | <tr> | |
124 | <td> <TT>get(p, g, x)</TT> </td> | |
125 | <td> | |
126 | Returns the property value (specified by the <tt>PropertyTag</tt> type) | |
127 | associated with object <tt>x</tt> (a vertex or edge). | |
128 | The object <tt>p</tt> is only used to carry the type. | |
129 | This function is equivalent to:<br> | |
130 | <tt>get(get(p, g), x)</tt><br> | |
131 | Return type: <tt>boost::property_traits<Map>::value_type</tt> | |
132 | </td> | |
133 | </TR> | |
134 | ||
135 | <tr> | |
136 | <td> <TT>put(p, g, x, v)</TT> </td> | |
137 | <td> | |
138 | Set the property (specified by the <tt>PropertyTag</tt> type) | |
139 | associated with object <tt>x</tt> (a vertex or edge) to | |
140 | the value <tt>v</tt>. The object <tt>p</tt> is only used to carry the type. | |
141 | This function is equivalent to:<br> | |
142 | <tt> | |
143 | pmap = get(p, g);<br> | |
144 | put(pmap, x, v) | |
145 | </tt><br> | |
146 | Return type: <TT>void</TT> | |
147 | </td> | |
148 | </TR> | |
149 | ||
150 | ||
151 | </TABLE> | |
152 | ||
153 | <H3>Complexity</H3> | |
154 | ||
155 | The <tt>get()</tt> property map function must be constant time. | |
156 | ||
157 | ||
158 | <H3>Models</H3> | |
159 | ||
160 | ||
161 | <UL> | |
162 | <LI><tt>adjacency_list</tt> with <tt>VertexProperty=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></tt> and <tt>PropertyTag=vertex_distance_t</tt>.</li> | |
163 | <li><tt>adjacency_list</tt> with <tt>VertexPropertyTag=property<vertex_distance_t,int,property<vertex_in_degree_t,int> ></TT> and <tt>PropertyTag=vertex_in_degree_t</tt>.</li> | |
164 | </UL> | |
165 | ||
166 | ||
167 | <H3>Concept Checking Class</H3> | |
168 | ||
169 | <PRE> | |
170 | template <class Graph, class X, class PropertyTag> | |
171 | struct PropertyGraphConcept | |
172 | { | |
173 | typedef typename property_map<G, PropertyTag>::type Map; | |
174 | typedef typename property_map<G, PropertyTag>::const_type const_Map; | |
175 | void constraints() { | |
176 | BOOST_CONCEPT_ASSERT(( GraphConcept<G> )); | |
177 | BOOST_CONCEPT_ASSERT(( ReadWritePropertyMapConcept<Map, X> )); | |
178 | BOOST_CONCEPT_ASSERT(( ReadablePropertyMapConcept<const_Map, X> )); | |
179 | ||
180 | Map pmap = get(PropertyTag(), g); | |
181 | pval = get(PropertyTag(), g, x); | |
182 | put(PropertyTag(), g, x, pval); | |
183 | ignore_unused_variable_warning(pmap); | |
184 | } | |
185 | void const_constraints(const G& g) { | |
186 | const_Map pmap = get(PropertyTag(), g); | |
187 | pval = get(PropertyTag(), g, x); | |
188 | ignore_unused_variable_warning(pmap); | |
189 | } | |
190 | G g; | |
191 | X x; | |
192 | typename property_traits<Map>::value_type pval; | |
193 | }; | |
194 | </PRE> | |
195 | ||
196 | ||
197 | <h3>See Also</h3> | |
198 | ||
199 | <a href="./property_map.html"><tt>property_map</tt></a> | |
200 | ||
201 | <br> | |
202 | <HR> | |
203 | <TABLE> | |
204 | <TR valign=top> | |
205 | <TD nowrap>Copyright © 2000-2001</TD><TD> | |
206 | <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>) | |
207 | </TD></TR></TABLE> | |
208 | ||
209 | </BODY> | |
210 | </HTML> |