|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66203 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2010-10-26 14:24:01
Author: jewillco
Date: 2010-10-26 14:24:01 EDT (Tue, 26 Oct 2010)
New Revision: 66203
URL: http://svn.boost.org/trac/boost/changeset/66203
Log:
Repaired copy_component() using suggestion from Christopher Alfeld; fixes #4793
Text files modified:
trunk/boost/graph/copy.hpp | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
Modified: trunk/boost/graph/copy.hpp
==============================================================================
--- trunk/boost/graph/copy.hpp (original)
+++ trunk/boost/graph/copy.hpp 2010-10-26 14:24:01 EDT (Tue, 26 Oct 2010)
@@ -350,15 +350,28 @@
: g_out(graph), orig2copy(c), copy_vertex(cv), copy_edge(ce) { }
template <class Vertex, class Graph>
- void examine_vertex(Vertex u, const Graph& g_in) const {
+ typename graph_traits<NewGraph>::vertex_descriptor copy_one_vertex(Vertex u, const Graph& g_in) const {
typename graph_traits<NewGraph>::vertex_descriptor
new_u = add_vertex(g_out);
put(orig2copy, u, new_u);
copy_vertex(u, new_u);
+ return new_u;
}
template <class Edge, class Graph>
- void examine_edge(Edge e, const Graph& g_in) const {
+ void tree_edge(Edge e, const Graph& g_in) const {
+ // For a tree edge, the target vertex has not been copied yet.
+ typename graph_traits<NewGraph>::edge_descriptor new_e;
+ bool inserted;
+ boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(e, g_in)),
+ this->copy_one_vertex(target(e, g_in), g_in),
+ g_out);
+ copy_edge(e, new_e);
+ }
+
+ template <class Edge, class Graph>
+ void non_tree_edge(Edge e, const Graph& g_in) const {
+ // For a non-tree edge, the target vertex has already been copied.
typename graph_traits<NewGraph>::edge_descriptor new_e;
bool inserted;
boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(e, g_in)),
@@ -387,8 +400,10 @@
{
graph_copy_visitor<MutableGraph, Orig2CopyVertexIndexMap,
CopyVertex, CopyEdge> vis(g_out, orig2copy, copy_vertex, copy_edge);
+ typename graph_traits<MutableGraph>::vertex_descriptor src_copy
+ = vis.copy_one_vertex(src);
breadth_first_search(g_in, src, params.visitor(vis));
- return get(orig2copy, src);
+ return src_copy;
}
} // namespace detail
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk