迭代不带访问者的提升图

时间:2014-05-20 09:09:49

标签: c++ boost graph boost-graph

我需要迭代图形(DFS),但不使用标准的DFS访问者回调技术。

有没有办法以这种方式迭代遍历图形?

for(each edge in my graph visited in dfs) {
    do some complicated stuff;
}

1 个答案:

答案 0 :(得分:0)

是的,根据具体的图表类型,你可以做到

auto e = edges(g);
for (auto it = e.first; it != e.second; ++it)
{
}

如果图表模拟了不同的概念,您可能需要in_edges(g)out_edges(g)http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/graph_concepts.html

修改更新评论:

你必须自己包装它。你可以使用Boost Coroutine强制拉动界面。或者您可以使用访问者填充DFS完成后使用的队列。