I want to copy edges with their vertices and properties from dataG.front(), and add it to testg , I tried what I found in "Accessing bundled properties" section http://www.boost.org/doc/libs/1_57_0/libs/graph/doc/bundles.html but it isn't working for me. PS: dataG is a vector of graphs.
typedef std::pair<edge_iter, edge_iter> edge_pair;
Graph testg;
if (!dataG.empty())
{
auto const& gr = dataG.front();
for (edge_pair ep = edges(gr); ep.first != ep.second; ++ep.first) //ep edge number
{
auto ep = edges(gr).first; // ep edge number
vertex_t from = source(*ep.first, gr);
vertex_t to = target(*ep.first, gr);
boost::add_vertex(gr[from], testg);
boost::add_vertex(gr[to], testg);
boost::add_edge(from, to, gr[*ep.first], testg);
}
}
edges properties works but there is a problem in source and target. (vertex_t and add_vertex part), How to add directly the vertices properties to the added one because there is a duplication here.
PS: for more information here is the full code http://pastebin.com/2iztGAa6
As you noticed, the vertices might be duplicated, and this is especially true if you "merge" multiple of the source graphs into one graph.
If you don't mind to re-write the vertex properties (and keeping the value last assigned in case the values aren't identical all the time) you can just use a property map:
Then again, there's also the equivalent access like so:
You can even addres individual bundled members:
All the samples based on this documentation page