Have you tried copy_graph ?
It is difficult to find out what the problem is without seeing errors, but if I were to guess, I would first make sure that you provide a map vertex_indexfor copy_graph, since it is not available by default when used setSto store vertices. Based on the previous question , it looks like you already realized that we only need to collect all this.
typedef adjacency_list<setS, setS, undirectedS, NodeDataStruct, EdgeDataStruct> MyGraph;
typedef MyGraph::vertex_descriptor NodeID;
typedef map<NodeID, size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
MyGraph g1, g2;
int i=0;
BGL_FORALL_VERTICES(v, g2, MyGraph)
{
put(propmapIndex, v, i++);
}
g1.clear();
copy_graph( g2, g1, vertex_index_map( propmapIndex ) );
g2.clear();
source
share