Graph.html 4.4 KB

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