| [12] | 1 | <HTML> |
|---|
| 2 | <!-- |
|---|
| 3 | -- Copyright (c) Jeremy Siek 2000 |
|---|
| 4 | -- |
|---|
| 5 | -- Permission to use, copy, modify, distribute and sell this software |
|---|
| 6 | -- and its documentation for any purpose is hereby granted without fee, |
|---|
| 7 | -- provided that the above copyright notice appears in all copies and |
|---|
| 8 | -- that both that copyright notice and this permission notice appear |
|---|
| 9 | -- in supporting documentation. Silicon Graphics makes no |
|---|
| 10 | -- representations about the suitability of this software for any |
|---|
| 11 | -- purpose. It is provided "as is" without express or implied warranty. |
|---|
| 12 | --> |
|---|
| 13 | <Head> |
|---|
| 14 | <Title>PropertyGraph</Title> |
|---|
| 15 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" |
|---|
| 16 | ALINK="#ff0000"> |
|---|
| 17 | <IMG SRC="../../../boost.png" |
|---|
| 18 | ALT="C++ Boost" width="277" height="86"> |
|---|
| 19 | |
|---|
| 20 | <BR Clear> |
|---|
| 21 | |
|---|
| 22 | <H2><A NAME="concept:PropertyGraph"></A> |
|---|
| 23 | PropertyGraph |
|---|
| 24 | </H2> |
|---|
| 25 | |
|---|
| 26 | A PropertyGraph is a graph that has some property associated with each |
|---|
| 27 | of the vertices or edges in the graph. As a given graph may have |
|---|
| 28 | several properties associated with each vertex or edge, a tag is used |
|---|
| 29 | to identity which property is being accessed. The graph provides a |
|---|
| 30 | function which returns a property map object. |
|---|
| 31 | |
|---|
| 32 | <P> |
|---|
| 33 | |
|---|
| 34 | <H3>Refinement of</H3> |
|---|
| 35 | |
|---|
| 36 | <a href="./Graph.html">Graph</a> |
|---|
| 37 | |
|---|
| 38 | <h3>Notation</h3> |
|---|
| 39 | |
|---|
| 40 | <Table> |
|---|
| 41 | <TR> |
|---|
| 42 | <TD><tt>G</tt></TD> |
|---|
| 43 | <TD>A type that is a model of PropertyGraph.</TD> |
|---|
| 44 | </TR> |
|---|
| 45 | |
|---|
| 46 | <TR> |
|---|
| 47 | <TD><tt>g</tt></TD> |
|---|
| 48 | <TD>An object of type <tt>G</tt>.</TD> |
|---|
| 49 | </TR> |
|---|
| 50 | |
|---|
| 51 | <TR> |
|---|
| 52 | <TD><tt>X</tt></TD> |
|---|
| 53 | <TD>Either the vertex or edge descriptor type for <tt>G</tt>.</TD> |
|---|
| 54 | </TR> |
|---|
| 55 | |
|---|
| 56 | <TR> |
|---|
| 57 | <TD><tt>x</tt></TD> |
|---|
| 58 | <TD>An object of type <tt>X</tt>.</TD> |
|---|
| 59 | </TR> |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | <TR> |
|---|
| 63 | <TD><tt>Map</tt></TD> |
|---|
| 64 | <TD>The type <tt>boost::property_map<G, Property>::const_type</tt>.</TD> |
|---|
| 65 | </TR> |
|---|
| 66 | |
|---|
| 67 | <TR> |
|---|
| 68 | <TD><tt>v</tt></TD> |
|---|
| 69 | <TD>An object of type <tt>boost::property_traits<Map>::value_type</tt>.</TD> |
|---|
| 70 | </TR> |
|---|
| 71 | |
|---|
| 72 | <TR> |
|---|
| 73 | <TD><tt>PropertyTag</tt></TD> |
|---|
| 74 | <TD>A type that models the <a href="./PropertyTag.html">PropertyTag</a> concept.</TD> |
|---|
| 75 | </TR> |
|---|
| 76 | |
|---|
| 77 | <TR> |
|---|
| 78 | <TD><tt>p</tt></TD> |
|---|
| 79 | <TD>An object of type <tt>PropertyTag</tt>.</td> |
|---|
| 80 | </TR> |
|---|
| 81 | |
|---|
| 82 | <TR> |
|---|
| 83 | <TD><tt>pmap</tt></TD> |
|---|
| 84 | <TD>An object of type <tt>Map</tt>.</td> |
|---|
| 85 | </TR> |
|---|
| 86 | |
|---|
| 87 | </table> |
|---|
| 88 | |
|---|
| 89 | <H3>Associated types</H3> |
|---|
| 90 | |
|---|
| 91 | <table border> |
|---|
| 92 | |
|---|
| 93 | <tr> |
|---|
| 94 | <td><pre>boost::property_map<G, PropertyTag>::type</pre> |
|---|
| 95 | The type of the property map for the property specified by |
|---|
| 96 | <TT>PropertyTag</TT>. This type must be a model of <a |
|---|
| 97 | href="../../property_map/ReadWritePropertyMap.html">ReadWritePropertyMap</a> |
|---|
| 98 | with a key type the same as the graph's vertex or edge descriptor type. |
|---|
| 99 | </td> |
|---|
| 100 | </tr> |
|---|
| 101 | |
|---|
| 102 | <tr> |
|---|
| 103 | <td><pre>boost::property_map<G, PropertyTag>::const_type</pre> |
|---|
| 104 | The type of the const property map for the property specified by |
|---|
| 105 | <TT>PropertyTag</TT>. This type must be a model of <a |
|---|
| 106 | href="../../property_map/ReadablePropertyMap.html">ReadablePropertyMap</a> |
|---|
| 107 | with a key type the same as the graph's vertex or edge descriptor type. |
|---|
| 108 | </td> |
|---|
| 109 | </tr> |
|---|
| 110 | |
|---|
| 111 | </table> |
|---|
| 112 | |
|---|
| 113 | <h3>Valid Expressions</h3> |
|---|
| 114 | |
|---|
| 115 | <table border> |
|---|
| 116 | |
|---|
| 117 | <tr> |
|---|
| 118 | <td> <TT>get(p, g)</TT> </td> |
|---|
| 119 | <td> |
|---|
| 120 | Returns the property map for the property specified by the |
|---|
| 121 | <tt>PropertyTag</tt> type. The object <tt>p</tt> is only used to |
|---|
| 122 | carry the type.<br> |
|---|
| 123 | 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. |
|---|
| 124 | </td> |
|---|
| 125 | </TR> |
|---|
| 126 | |
|---|
| 127 | <tr> |
|---|
| 128 | <td> <TT>get(p, g, x)</TT> </td> |
|---|
| 129 | <td> |
|---|
| 130 | Returns the property value (specified by the <tt>PropertyTag</tt> type) |
|---|
| 131 | associated with object <tt>x</tt> (a vertex or edge). |
|---|
| 132 | The object <tt>p</tt> is only used to carry the type. |
|---|
| 133 | This function is equivalent to:<br> |
|---|
| 134 | <tt>get(get(p, g), x)</tt><br> |
|---|
| 135 | Return type: <tt>boost::property_traits<Map>::value_type</tt> |
|---|
| 136 | </td> |
|---|
| 137 | </TR> |
|---|
| 138 | |
|---|
| 139 | <tr> |
|---|
| 140 | <td> <TT>put(p, g, x, v)</TT> </td> |
|---|
| 141 | <td> |
|---|
| 142 | Set the property (specified by the <tt>PropertyTag</tt> type) |
|---|
| 143 | associated with object <tt>x</tt> (a vertex or edge) to |
|---|
| 144 | the value <tt>v</tt>. The object <tt>p</tt> is only used to carry the type. |
|---|
| 145 | This function is equivalent to:<br> |
|---|
| 146 | <tt> |
|---|
| 147 | pmap = get(p, g);<br> |
|---|
| 148 | put(pmap, x, v) |
|---|
| 149 | </tt><br> |
|---|
| 150 | Return type: <TT>void</TT> |
|---|
| 151 | </td> |
|---|
| 152 | </TR> |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | </TABLE> |
|---|
| 156 | |
|---|
| 157 | <H3>Complexity</H3> |
|---|
| 158 | |
|---|
| 159 | The <tt>get()</tt> property map function must be constant time. |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | <H3>Models</H3> |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | <UL> |
|---|
| 166 | <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> |
|---|
| 167 | <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> |
|---|
| 168 | </UL> |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | <H3>Concept Checking Class</H3> |
|---|
| 172 | |
|---|
| 173 | <PRE> |
|---|
| 174 | template <class Graph, class X, class PropertyTag> |
|---|
| 175 | struct PropertyGraphConcept |
|---|
| 176 | { |
|---|
| 177 | typedef typename property_map<G, PropertyTag>::type Map; |
|---|
| 178 | typedef typename property_map<G, PropertyTag>::const_type const_Map; |
|---|
| 179 | void constraints() { |
|---|
| 180 | function_requires< GraphConcept<G> >(); |
|---|
| 181 | function_requires< ReadWritePropertyMapConcept<Map, X> >(); |
|---|
| 182 | function_requires< ReadablePropertyMapConcept<const_Map, X> >(); |
|---|
| 183 | |
|---|
| 184 | Map pmap = get(PropertyTag(), g); |
|---|
| 185 | pval = get(PropertyTag(), g, x); |
|---|
| 186 | put(PropertyTag(), g, x, pval); |
|---|
| 187 | ignore_unused_variable_warning(pmap); |
|---|
| 188 | } |
|---|
| 189 | void const_constraints(const G& g) { |
|---|
| 190 | const_Map pmap = get(PropertyTag(), g); |
|---|
| 191 | pval = get(PropertyTag(), g, x); |
|---|
| 192 | ignore_unused_variable_warning(pmap); |
|---|
| 193 | } |
|---|
| 194 | G g; |
|---|
| 195 | X x; |
|---|
| 196 | typename property_traits<Map>::value_type pval; |
|---|
| 197 | }; |
|---|
| 198 | </PRE> |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | <h3>See Also</h3> |
|---|
| 202 | |
|---|
| 203 | <a href="./property_map.html"><tt>property_map</tt></a> |
|---|
| 204 | |
|---|
| 205 | <br> |
|---|
| 206 | <HR> |
|---|
| 207 | <TABLE> |
|---|
| 208 | <TR valign=top> |
|---|
| 209 | <TD nowrap>Copyright © 2000-2001</TD><TD> |
|---|
| 210 | <A HREF="../../../people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>) |
|---|
| 211 | </TD></TR></TABLE> |
|---|
| 212 | |
|---|
| 213 | </BODY> |
|---|
| 214 | </HTML> |
|---|