複製邊緣及其頂點和屬性我想從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