2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-26 18:42:12 +00:00

Repaired copy_component() using suggestion from Christopher Alfeld; fixes #4793

[SVN r66203]
This commit is contained in:
Jeremiah Willcock
2010-10-26 18:24:01 +00:00
parent 822fc80494
commit a3786d7f7e

View File

@@ -350,15 +350,28 @@ namespace boost {
: 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 @@ namespace boost {
{
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