Stop boost :: depth_first_search at a specific depth if certain criteria are met

I use BGL to store my DAG. Vertices have states. Given the state change in one of the vertices, I want to update the dependent vertices. I can do this using boost :: depth_first_search and a user visitor.

Now the logic is that I do not want to update the desired vertex and its dependent one if the vertex is in a certain state. Basically I want to control the en-queueing of vertices in dfs or bfs. What is the best way to achieve this in BGL.

Thanks.

+6
c ++ boost graph depth-first-search boost-graph
source share
2 answers

It seems that boost :: depth_first_search does not support this, but the basic boost :: depth_first_visit does through its second overload, which allows a โ€œterminator functionโ€ (TerminatorFunc).

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

+9
source share

The lack of completion in depth-first search is the stupidest thing in a graph library I've ever seen.

Perhaps this could be the output: depth_first_search on filter_graph. You can somehow mark the stop vertex, and in the filter-filter function filter_graph just hide the edges of the incident

0
source share

All Articles