AddEdgeVisitor.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <html>
  2. <head>
  3. <!-- Copyright 2007 Aaron Windsor
  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. <title>AddEdgeVisitor Concept</title>
  9. </head>
  10. <body alink="#ff0000"
  11. bgcolor="#ffffff"
  12. link="#0000ee"
  13. text="#000000"
  14. vlink="#551a8b">
  15. <img src="../../../boost.png" alt="C++ Boost" height="86" width="277">
  16. <br clear="">
  17. <h1>AddEdgeVisitor Concept</h1>
  18. The AddEdgeVisitor concept exists to allow for some indirection in algorithms
  19. that modify graphs by adding edges. In such algorithms, it may be convenient
  20. to perform additional operations (such as updating an edge index map) at
  21. points in the algorithm where an edge addition occurs. Replacing calls to
  22. to <tt>add_edge</tt> with calls to <tt>AddEdgeVisitor::visit_vertex_pair</tt>
  23. allows for such operations to be defined independently from the algorithm.
  24. <h3>Notation</h3>
  25. <table>
  26. <tbody>
  27. <tr>
  28. <td> <tt>Visitor</tt> </td>
  29. <td> is a type that models the AddEdgeVisitor concept </td>
  30. </tr>
  31. <tr>
  32. <td> <tt>vis</tt> </td>
  33. <td> is an object of type Visitor </td>
  34. </tr>
  35. <tr>
  36. <td> <tt>Graph</tt> </td>
  37. <td> is the type of a graph </td>
  38. </tr>
  39. <tr>
  40. <td> <tt>u,v</tt> </td>
  41. <td> are objects of type <tt>graph_traits&lt;Graph&gt;::vertex_descriptor</tt>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td> <tt>e</tt> </td>
  46. <td> is an object of type <tt>graph_traits&lt;Graph&gt;::edge_descriptor</tt>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td> <tt>v</tt> </td>
  51. <td> is an object of type <tt>graph_traits&lt;Graph&gt;::vertex_descriptor</tt>
  52. </td>
  53. </tr><tr>
  54. <td>
  55. </td></tr></tbody></table>
  56. <h3>Associated Types</h3>
  57. None
  58. <h3>Valid Expressions</h3>
  59. <p>
  60. <table border="1">
  61. <tbody><tr><th>Name</th><th>Expression</th><th>Return Type</th>
  62. <th>Description</th>
  63. </tr><tr>
  64. <td> Add an Edge </td>
  65. <td> <tt>vis.visit_vertex_pair(u, v, g)</tt> </td>
  66. <td> <tt>void</tt></td>
  67. <td> Invoked every time an edge between vertices <tt>u</tt> and <tt>v</tt>
  68. should be added to the graph <tt>g</tt>.
  69. </td></tr>
  70. </tbody></table>
  71. </p><h3>Models</h3>
  72. Two models of this concept are defined in the file
  73. <a href="../../../boost/graph/planar_detail/add_edge_visitors.hpp">
  74. <tt>add_edge_visitors.hpp</tt></a>:
  75. <ul>
  76. <li><tt>default_add_edge_visitor</tt>: The constructor of this class takes
  77. no arguments.<tt>visit_vertex_pair(u, v, g)</tt> is just a dispatch to
  78. <tt>add_edge(u, v, g)</tt>.
  79. <li><tt>edge_index_update_visitor</tt>: The constructor of this class takes
  80. two arguments: the first, an EdgeIndexMap,
  81. is a <a href="../../property_map/doc/ReadWritePropertyMap.html">
  82. ReadWritePropertyMap</a> that maps each edge in the associated graph
  83. <tt>g</tt> to a distinct integer in the range <tt>[0, num_edges(g))</tt>.
  84. The second argument is the number of edges in the underlying graph, which
  85. serves as the "next available index" counter within the visitor.
  86. For example, in the case the graph used has an initialized interior
  87. edge index, the <tt>edge_index_update_visitor</tt> constructor should be
  88. called with <tt>get(edge_index, g)</tt> as the edge index and
  89. <tt>num_edges(g)</tt> as the next available index. When
  90. <tt>visit_vertex_pair(u, v, g)</tt> is called, the
  91. <tt>edge_index_update_visitor</tt> will add the edge <i>(u,v)</i> to the graph
  92. and update the edge index for the newly created edge.
  93. </ul>
  94. <p>
  95. <br>
  96. </p><hr>
  97. Copyright © 2007 Aaron Windsor (<a href="mailto:aaron.windsor@gmail.com">
  98. aaron.windsor@gmail.com</a>)
  99. </body></html>