25 Nov
2015
25 Nov
'15
12:13 a.m.
Hello I want to enumerate all vertices with zero input edge count in a graph, I am using DFS right now: struct vertex_visitor : public boost::default_dfs_visitor { std::vector<vertex_t> Output; void discover_vertex(vertex_t v, graph_t const& g) { graph_t::in_edge_iterator edgeIt, edgeEnd; tie(edgeIt, edgeEnd) = boost::in_edges(v, g); if (edgeIt==edgeEnd) Output.push_back(v); } }; vertex_visitor vis; boost::depth_first_search(g, boost::visitor(v)); However I don't know how to cleanly stop execution after depth 0 inside my visitor and I can't figure out a better way to archieve this. Since I am fairly new to boost graph I supose that I'm missing something. Thanks.