如果满足某些标准,请沿特定深度停止boost :: depth_first_search [英] Stop boost::depth_first_search along a particular depth if certain criteria is met

查看:196
本文介绍了如果满足某些标准,请沿特定深度停止boost :: depth_first_search的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using BGL to store my DAG. Vertices have states. Given a change in state in one of the vertices i want to update dependent vertices. This i'm able to do using boost::depth_first_search and a custom visitor.

现在的逻辑是,我不想更新一个搜索的顶点及其依赖如果顶点处于特定状态。基本上我想控制dfs或bfs中顶点的排队。

Now the logic is that i dont want to update a searched vertex and its dependent if the vertex is in a particular state. Basically i want to control over en-queuing of vertices in either dfs or bfs. What is the best way to achieve this in BGL.

谢谢。

推荐答案

看起来boost :: depth_first_search不支持这个,但底层的boost :: depth_first_visit通过它的第二个重载允许一个终止函数(TerminatorFunc)。

It seems that boost::depth_first_search does not support this, but the underlying boost::depth_first_visit does, through its 2nd overload allowing for a "terminator function" (TerminatorFunc).

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

So you could copy the implementation of boost::depth_first_search and substitute the detail::nontruth2() parameter passed to boost::depth_first_visit with your own (non-trivial) terminator function.

这篇关于如果满足某些标准,请沿特定深度停止boost :: depth_first_search的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆