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