2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-19 04:12:11 +00:00

Qualified calls to tie in documentation; fixes #9184

[SVN r86126]
This commit is contained in:
Jeremiah Willcock
2013-10-01 18:12:50 +00:00
parent f0f1251da7
commit bed19d5c25
14 changed files with 34 additions and 34 deletions

View File

@@ -214,12 +214,12 @@ example, the following code will result in undefined (bad) behavior:
<b>// Attempt to remove all the vertices. Wrong!</b>
graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end;
for (tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)
for (boost::tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)
remove_vertex(*vi, G);
<b>// Remove all the vertices. This is still wrong!</b>
graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end, next;
tie(vi, vi_end) = vertices(G);
boost::tie(vi, vi_end) = vertices(G);
for (next = vi; vi != vi_end; vi = next) {
++next;
remove_vertex(*vi, G);
@@ -247,12 +247,12 @@ actual vertex that was removed. The following code demonstrates this.
<b>// Attempt to remove all the vertices. Wrong!</b>
graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end;
for (tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)
for (boost::tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)
remove_vertex(*vi, G);
<b>// Remove all the vertices. This is OK.</b>
graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end, next;
tie(vi, vi_end) = vertices(G);
boost::tie(vi, vi_end) = vertices(G);
for (next = vi; vi != vi_end; vi = next) {
++next;
remove_vertex(*vi, G);
@@ -281,7 +281,7 @@ vertex descriptors have become invalid, the result is incorrect.
remove_vertex(s, G); <b>// Bad idea! Invalidates vertex descriptors in parent vector.</b>
<b>// The following will produce incorrect results</b>
for(tie(vi, vend) = vertices(G); vi != vend; ++vi)
for(boost::tie(vi, vend) = vertices(G); vi != vend; ++vi)
std::cout << p[*vi] << " is the parent of " << *vi << std::endl;
</pre>

View File

@@ -338,8 +338,8 @@ main()
std::cout &lt;&lt; "c flow values:" &lt;&lt; std::endl;
graph_traits &lt; Graph &gt;::vertex_iterator u_iter, u_end;
graph_traits &lt; Graph &gt;::out_edge_iterator ei, e_end;
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
if (capacity[*ei] &gt; 0)
std::cout &lt;&lt; "f " &lt;&lt; *u_iter &lt;&lt; " " &lt;&lt; target(*ei, g) &lt;&lt; " "
&lt;&lt; (capacity[*ei] - residual_capacity[*ei]) &lt;&lt; std::endl;

View File

@@ -134,7 +134,7 @@ namespace boost {
mark(V, numeric_limits_max(max_color));
typename GraphTraits::vertex_iterator v, vend;
for (tie(v, vend) = vertices(G); v != vend; ++v)
for (boost::tie(v, vend) = vertices(G); v != vend; ++v)
color[*v] = V - 1; // which means "not colored"
for (size_type i = 0; i &lt; V; i++) {
@@ -142,7 +142,7 @@ namespace boost {
// mark all the colors of the adjacent vertices
typename GraphTraits::adjacency_iterator ai, aend;
for (tie(ai, aend) = adjacent_vertices(current, G); ai != aend; ++ai)
for (boost::tie(ai, aend) = adjacent_vertices(current, G); ai != aend; ++ai)
mark[color[*ai]] = i;
// find the smallest color unused by the adjacent vertices

View File

@@ -115,7 +115,7 @@ library. OO was hip in the 80s and 90s, but its time we moved beyond!
// initialize the vertex_index property values
graph_traits&lt;graph_t&gt;::vertex_iterator vi, vend;
graph_traits&lt;graph_t&gt;::vertices_size_type cnt = 0;
for(tie(vi,vend) = vertices(G); vi != vend; ++vi)
for(boost::tie(vi,vend) = vertices(G); vi != vend; ++vi)
put(index, *vi, cnt++);
</pre>
</li>

View File

@@ -233,7 +233,7 @@ it depends on.
if (in_degree (*i, g) &gt; 0) {
Graph::in_edge_iterator j, j_end;
int maxdist = 0;
for (tie(j, j_end) = in_edges(*i, g); j != j_end; ++j)
for (boost::tie(j, j_end) = in_edges(*i, g); j != j_end; ++j)
maxdist = std::max(time[source(*j, g)], maxdist);
time[*i]=maxdist+1;
}

View File

@@ -127,7 +127,7 @@ namespace boost {
const size_type num = num_vertices(G);
typename GraphTraits::vertex_iterator v, vend;
for (tie(v, vend) = vertices(G); v != vend; ++v) {
for (boost::tie(v, vend) = vertices(G); v != vend; ++v) {
put(marker, *v, num);
put(degree, *v, out_degree(*v, G));
degree_buckets.push(*v);
@@ -152,7 +152,7 @@ namespace boost {
put(marker, node, 0); //node has been ordered.
typename GraphTraits::adjacency_iterator v, vend;
for (tie(v,vend) = adjacent_vertices(node, G); v != vend; ++v)
for (boost::tie(v,vend) = adjacent_vertices(node, G); v != vend; ++v)
if ( get(marker, *v) &gt; current_order ) { //*v is unordered vertex
put(marker, *v, current_order); //mark the columns adjacent to node

View File

@@ -408,7 +408,7 @@ href="../example/undirected_adjacency_list.cpp"><TT>example/undirected_adjacency
boost::graph_traits&lt;UndirectedGraph&gt;::out_edge_iterator e, e_end;
boost::graph_traits&lt;UndirectedGraph&gt;::vertex_descriptor
s = vertex(0, undigraph);
for (tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e)
for (boost::tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e)
std::cout &lt;&lt; "(" &lt;&lt; source(*e, undigraph)
&lt;&lt; "," &lt;&lt; target(*e, undigraph) &lt;&lt; ")" &lt;&lt; endl;
</PRE>
@@ -447,8 +447,8 @@ of <i>(v,u)</i> since they are the same edge.
add_edge(digraph, v, u, Weight(2.4));
boost::graph_traits&lt;DirectedGraph&gt;::edge_descriptor e1, e2;
bool found;
tie(e1, found) = edge(u, v, digraph);
tie(e2, found) = edge(v, u, digraph);
boost::tie(e1, found) = edge(u, v, digraph);
boost::tie(e2, found) = edge(v, u, digraph);
std::cout &lt;&lt; "in a directed graph is ";
std::cout &lt;&lt; "(u,v) == (v,u) ? " &lt;&lt; (e1 == e2) &lt;&lt; std::endl;
@@ -464,8 +464,8 @@ of <i>(v,u)</i> since they are the same edge.
add_edge(undigraph, u, v, Weight(3.1));
boost::graph_traits&lt;UndirectedGraph&gt;::edge_descriptor e1, e2;
bool found;
tie(e1, found) = edge(u, v, undigraph);
tie(e2, found) = edge(v, u, undigraph);
boost::tie(e1, found) = edge(u, v, undigraph);
boost::tie(e2, found) = edge(v, u, undigraph);
std::cout &lt;&lt; "in an undirected graph is ";
std::cout &lt;&lt; "(u,v) == (v,u) ? " &lt;&lt; (e1 == e2) &lt;&lt; std::endl;

View File

@@ -57,7 +57,7 @@ is the target. This function is equivalent to the expression
edge_descriptor e;
vertex_descriptor u, v;
...
tie(u, v) = incident(e, g);
boost::tie(u, v) = incident(e, g);
</pre>

View File

@@ -156,7 +156,7 @@ descriptor from the map's <TT>pos</TT> iterator.
tokenizer&lt;&gt;::iterator i = line_toks.begin();
std::string actors_name = *i++;
tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));
boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));
if (inserted) {
u = add_vertex(g);
actor_name[u] = actors_name;
@@ -174,7 +174,7 @@ actor into the graph.
<PRE>
std::string movie_name = *i++;
tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex()));
boost::tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex()));
if (inserted) {
v = add_vertex(g);
actor_name[v] = *i;
@@ -190,7 +190,7 @@ the name of the connecting movie.
<P>
<PRE>
graph_traits&lt;Graph&gt;::edge_descriptor e;
tie(e, inserted) = add_edge(u, v, g);
boost::tie(e, inserted) = add_edge(u, v, g);
if (inserted)
connecting_movie[e] = movie_name;
</PRE>

View File

@@ -56,7 +56,7 @@ target, then this function returns the source vertex.
edge_descriptor e;
...
vertex_descriptor u, v;
tie(u, v) = incident(e, g);
boost::tie(u, v) = incident(e, g);
assert(v == opposite(e, u, g));
assert(u == opposite(e, v, g));
</pre>

View File

@@ -196,8 +196,8 @@ main()
std::cout &lt;&lt; "c flow values:" &lt;&lt; std::endl;
graph_traits&lt;Graph&gt;::vertex_iterator u_iter, u_end;
graph_traits&lt;Graph&gt;::out_edge_iterator ei, e_end;
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
if (capacity[*ei] &gt; 0)
std::cout &lt;&lt; "f " &lt;&lt; *u_iter &lt;&lt; " " &lt;&lt; target(*ei, g) &lt;&lt; " "
&lt;&lt; (capacity[*ei] - residual_capacity[*ei]) &lt;&lt; std::endl;

View File

@@ -187,7 +187,7 @@ but in this case the iterators are <i>edge iterators</i>. Dereferencing an edge
iterator gives an edge object. The <tt>source()</tt> and <tt>target()</tt>
functions return the two vertices that are connected by the edge. Instead of
explicitly creating a <tt>std::pair</tt> for the iterators, this time we will
use the <a href="../../tuple/doc/tuple_users_guide.html#tiers"><tt>tie()</tt></a> helper function.
use the <a href="../../tuple/doc/tuple_users_guide.html#tiers"><tt>boost::tie()</tt></a> helper function.
This handy function can be used to assign the parts of a <tt>std::pair</tt> into
two separate variables, in this case <tt>ei</tt> and <tt>ei_end</tt>. This is
usually more convenient than creating a <tt>std::pair</tt> and is our method of
@@ -200,7 +200,7 @@ choice for the BGL.
// ...
std::cout &lt;&lt; &quot;edges(g) = &quot;;
graph_traits&lt;Graph&gt;::edge_iterator ei, ei_end;
for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
std::cout &lt;&lt; &quot;(&quot; &lt;&lt; index[source(*ei, g)]
&lt;&lt; &quot;,&quot; &lt;&lt; index[target(*ei, g)] &lt;&lt; &quot;) &quot;;
std::cout &lt;&lt; std::endl;
@@ -303,7 +303,7 @@ out-edge of vertex <tt>v</tt>.
std::cout &lt;&lt; &quot;out-edges: &quot;;
typename GraphTraits::out_edge_iterator out_i, out_end;
typename GraphTraits::edge_descriptor e;
for (tie(out_i, out_end) = out_edges(v, g);
for (boost::tie(out_i, out_end) = out_edges(v, g);
out_i != out_end; ++out_i) {
e = *out_i;
Vertex src = source(e, g), targ = target(e, g);
@@ -337,7 +337,7 @@ specified instead of <tt>directedS</tt>.
std::cout &lt;&lt; &quot;in-edges: &quot;;
typedef typename graph_traits&lt;Graph&gt; GraphTraits;
typename GraphTraits::in_edge_iterator in_i, in_end;
for (tie(in_i, in_end) = in_edges(v,g);
for (boost::tie(in_i, in_end) = in_edges(v,g);
in_i != in_end; ++in_i) {
e = *in_i;
Vertex src = source(e, g), targ = target(e, g);
@@ -373,7 +373,7 @@ descriptor for an adjacent vertex.
std::cout &lt;&lt; &quot;adjacent vertices: &quot;;
typename graph_traits&lt;Graph&gt;::adjacency_iterator ai;
typename graph_traits&lt;Graph&gt;::adjacency_iterator ai_end;
for (tie(ai, ai_end) = adjacent_vertices(v, g);
for (boost::tie(ai, ai_end) = adjacent_vertices(v, g);
ai != ai_end; ++ai)
std::cout &lt;&lt; index[*ai] &lt;&lt; &quot; &quot;;
std::cout &lt;&lt; std::endl;

View File

@@ -143,7 +143,7 @@ namespace boost {
rcm_queue&lt;Vertex, Degree&gt; Q(degree);
typename boost::graph_traits&lt;Graph&gt;::vertex_iterator ui, ui_end;
for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
put(color, *ui, white(c));
breadth_first_search(G, u, Q, bfs_visitor&lt;&gt;(), color);
@@ -214,7 +214,7 @@ from BGL can be reused.
CMVisitor cm_visitor(inverse_permutation);
typename boost::graph_traits&lt;Graph&gt;::vertex_iterator ui, ui_end;
for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
put(color, *ui, white(c));
breadth_first_search(G, s, Q, cm_visitor, color);
}

View File

@@ -116,11 +116,11 @@ int main(int,char*[])
Graph g(used_by, used_by + nedges, N);
graph_traits&lt;Graph&gt;::vertex_iterator v, v_end;
for (tie(v,v_end) = vertices(g); v != v_end; ++v)
for (boost::tie(v,v_end) = vertices(g); v != v_end; ++v)
put(vertex_color_t(), g, *v, name[*v]);
graph_traits&lt;Graph&gt;::edge_iterator e, e_end;
for (tie(e,e_end) = edges(g); e != e_end; ++e)
for (boost::tie(e,e_end) = edges(g); e != e_end; ++e)
put(edge_weight_t(), g, *e, 3);
dynamic_properties dp;