如果满足某些条件,请沿特定深度停止boost :: depth_first_search

Vik*_*kas 6 c++ boost graph depth-first-search boost-graph

我正在使用BGL来存储我的DAG.顶点有状态.给定一个顶点中的状态变化,我想更新依赖顶点.这我可以使用boost :: depth_first_search和自定义访问者.

现在的逻辑是,如果顶点处于特定状态,我不想更新搜索的顶点及其相关因素.基本上我想控制dfs或bfs中顶点的排队.在BGL中实现这一目标的最佳方法是什么.

谢谢.

Dan*_*ger 9

看起来boost :: depth_first_search不支持这个,但是底层的boost :: depth_first_visit通过它的第二个重载来实现"终结器函数"(TerminatorFunc).

所以你可以复制boost :: depth_first_search的实现,并用你自己的(非平凡的)终结器函数替换传递给boost :: depth_first_visit的detail :: nontruth2()参数.