Boost logo

Boost Users :

Subject: [Boost-users] Iterating "root" vertices with boost::graph
From: Isaac Lascasas (isaaclascasas_at_[hidden])
Date: 2015-11-24 19:13:10


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.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net