PropertyGraph.html 5.4 KB

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