IncidenceGraph.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 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>IncidenceGraph</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. <H1><A NAME="concept:IncidenceGraph"></A>
  16. IncidenceGraph
  17. </H1>
  18. The IncidenceGraph concept provides an interface for
  19. efficient access to the out-edges of each vertex in the graph.
  20. <H3>Refinement of</H3>
  21. <a href="./Graph.html">Graph</a>
  22. <h3>Notation</h3>
  23. <Table>
  24. <TR>
  25. <TD><tt>G</tt></TD>
  26. <TD>A type that is a model of IncidenceGraph.</TD>
  27. </TR>
  28. <TR>
  29. <TD><tt>g</tt></TD>
  30. <TD>An object of type <tt>G</tt>.</TD>
  31. </TR>
  32. <TR>
  33. <TD><tt>e</tt></TD>
  34. <TD>An object of type <tt>boost::graph_traits&lt;G&gt;::edge_descriptor</tt>.</TD>
  35. </TR>
  36. <TR>
  37. <TD><tt>u, v</tt></TD>
  38. <TD>Are objects of type <tt>boost::graph_traits&lt;G&gt;::vertex_descriptor</tt>.</TD>
  39. </TR>
  40. </table>
  41. <H3>Associated Types</H3>
  42. <Table border>
  43. <tr>
  44. <td><tt>boost::graph_traits&lt;G&gt;::traversal_category</tt><br><br>
  45. This tag type must be convertible to <tt>incidence_graph_tag</tt>.
  46. </td>
  47. </tr>
  48. <TR>
  49. <TD>
  50. <pre>boost::graph_traits&lt;G&gt;::out_edge_iterator</pre>
  51. An out-edge iterator for a vertex <i>v</i> provides access to the
  52. out-edges of the vertex. As such, the value type of an out-edge
  53. iterator is the edge descriptor type of its graph. An out-edge
  54. iterator must meet the requirements of <a
  55. href="../../utility/MultiPassInputIterator.html">MultiPassInputIterator</a>.
  56. </TD>
  57. </TR>
  58. <TR>
  59. <TD><pre>boost::graph_traits&lt;G&gt;::degree_size_type</pre>
  60. The unsigned integral type used for representing the number
  61. out-edges or incident edges of a vertex.
  62. </TD>
  63. </TR>
  64. </table>
  65. <h3>Valid Expressions</h3>
  66. <Table border>
  67. <tr>
  68. <td><a name="sec:source"><TT>source(e,&nbsp;g)</TT></a></TD>
  69. <TD>Returns the vertex descriptor for <i>u</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
  70. Return type: <TT>vertex_descriptor</TT>
  71. </TD>
  72. </TR>
  73. <tr>
  74. <td><a name="sec:target"><TT>target(e,&nbsp;g)</TT></a></TD>
  75. <TD>Returns the vertex descriptor for <i>v</i> of the edge <i>(u,v)</i> represented by <TT>e</TT>.<br>
  76. Return type: <TT>vertex_descriptor</TT>
  77. </td></tr>
  78. <tr>
  79. <td><a name="sec:out-edges"><TT>out_edges(u,&nbsp;g)</TT></a></TD>
  80. <TD>Returns an iterator-range providing access to the out-edges (for
  81. directed graphs) or incident edges (for undirected graphs) of vertex
  82. <TT>u</TT> in graph <TT>g</TT>. The source vertex of an edge obtained
  83. via an out edge iterator is guaranteed (for both directed and
  84. undirected graphs) to be the vertex <tt>u</tt> used in the call to
  85. <tt>out_edges(u, g)</tt> and the target vertex must be a vertex
  86. adjacent to <tt>u</tt>.<a href="#1">[1]</a>
  87. <br>
  88. Return type: <TT>std::pair&lt;out_edge_iterator, out_edge_iterator&gt;</TT>
  89. </TD>
  90. </tr>
  91. <tr>
  92. <TD><TT>out_degree(u,&nbsp;g)</TT></TD>
  93. <TD>Returns the number of out-edges (for directed graphs) or the
  94. number of incident edges (for undirected graphs) of vertex <TT>u</TT>
  95. in graph <TT>g</TT>.<br>
  96. Return type: <TT>degree_size_type</TT>
  97. </TD>
  98. </TR>
  99. </TABLE>
  100. <P>
  101. <H3>Complexity guarantees</H3>
  102. <P>
  103. The <TT>source()</TT>, <TT>target()</TT>, and <TT>out_edges()</TT>
  104. functions must all be constant time. The <tt>out_degree()</tt>
  105. function must be linear in the number of out-edges.
  106. <P>
  107. <H3>See Also</H3>
  108. <a href="./graph_concepts.html">Graph concepts</a>
  109. <H3>Notes</H3>
  110. <a name="1">[1]</a> For undirected graphs, the edge <tt>(u,v)</tt> is
  111. the same as edge <tt>(v,u)</tt>, so without some extra guarantee an
  112. implementation would be free use any ordering for the pair of vertices
  113. in an out-edge. For example, if you call <tt>out_edges(u, g)</tt>, and
  114. <tt>v</tt> is one of the vertices adjacent to <tt>u</tt>, then the
  115. implementation would be free to return <tt>(v,u)</tt> as an out-edge
  116. which would be non-intuitive and cause trouble for algorithms.
  117. Therefore, the extra requirement is added that the out-edge connecting
  118. <tt>u</tt> and <tt>v</tt> must be given as <tt>(u,v)</tt> and not
  119. <tt>(v,u)</tt>.
  120. <H3>Concept Checking Class</H3>
  121. <PRE>
  122. template &lt;class G&gt;
  123. struct IncidenceGraphConcept
  124. {
  125. typedef typename boost::graph_traits&lt;G&gt;::out_edge_iterator out_edge_iterator;
  126. void constraints() {
  127. BOOST_CONCEPT_ASSERT(( GraphConcept&lt;G&gt; ));
  128. BOOST_CONCEPT_ASSERT(( MultiPassInputIteratorConcept&lt;out_edge_iterator&gt; ));
  129. p = out_edges(u, g);
  130. e = *p.first;
  131. u = source(e, g);
  132. v = target(e, g);
  133. }
  134. void const_constraints(const G&amp; g) {
  135. p = out_edges(u, g);
  136. e = *p.first;
  137. u = source(e, g);
  138. v = target(e, g);
  139. }
  140. std::pair&lt;out_edge_iterator, out_edge_iterator&gt; p;
  141. typename boost::graph_traits&lt;G&gt;::vertex_descriptor u, v;
  142. typename boost::graph_traits&lt;G&gt;::edge_descriptor e;
  143. G g;
  144. };
  145. </PRE>
  146. <br>
  147. <HR>
  148. <TABLE>
  149. <TR valign=top>
  150. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  151. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
  152. Indiana University (<A
  153. HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
  154. <A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
  155. <A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>,
  156. Indiana University (<A
  157. HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
  158. </TD></TR></TABLE>
  159. </BODY>
  160. </HTML>