复制边缘及其顶点和属性我想从dataG.front()的顶点和属性复制边缘,并将其添加到testg,我尝试了在“访问捆绑属性”部分中找到的内容http://www.boost.org/doc/libs/1_57_0/libs/graph/doc/bundles.html,但它不适合我。 PS:dataG是一个图的向量。使用BOOST
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);
}
}
边缘属性有效,但源和目标中存在问题。 (vertex_t和add_vertex部分),如何直接将顶点属性添加到添加的顶点,因为这里有重复。
PS:了解更多信息这里是完整的代码http://pastebin.com/2iztGAa6
[可能使用BOOST复制具有相邻顶点及其属性的边的边](http://stackoverflow.com/questions/28827006/copying-edges-with-adjacent-vertices-和他们的属性使用提升) – TylerH 2017-02-07 02:47:22