Stop boost::depth_first_search along a particular

2019-04-28 14:02发布

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.

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.

Thanks.

2条回答
做自己的国王
2楼-- · 2019-04-28 14:51

Lack of termination in depth-first-search - is the most stupid thing in graph library I ever seen.

May be, this may be the way out: depth_first_search on filtered_graph. You may mark the stop-vertex somehow, and in filter-edges function of filtered_graph just hide the incident edges

查看更多
你好瞎i
3楼-- · 2019-04-28 14:52

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).

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.

查看更多
登录 后发表回答