<BGL>Filter vertices/edges by vertex/edge attributes?
Hi, In a boost graph, how can I filter vertices or edges by some attribute of Vertex/Edge Property? I tried taking a look at FilteredGraph, but the operator function would also need to be able to call boost::get(boost::vertex_bundle, graph_instance)[vertex] while only vertex is passed to the operator.
You can use filtered_graph to filter both edges and vertexes:
filtered_graph
Hi,
In a boost graph, how can I filter vertices or edges by some attribute of Vertex/Edge Property?
I tried taking a look at FilteredGraph, but the operator function would also need to be able to call
boost::get(boost::vertex_bundle, graph_instance)[vertex] while only vertex is passed to the operator.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
The documentation does not mention this, but if you take a look at the filtered graph implementation, you will find make_filtered_graph type-inference helper function overloads:
http://www.boost.org/doc/libs/master/boost/graph/filtered_graph.hpp
Works nicely with lambdas: make_filtered_graph(g, [](const auto edge){ return false; }); Makes writing user-code far more pleasant; this should be documented. Filtering by bundled property can then be done via a lambda similar to: [&g](const auto edge){ return g[edge].myFlag; } Hope that helps, Daniel J H On 12/11/2015 08:17 AM, Ireneusz Szcześniak wrote:
You can use filtered_graph to filter both edges and vertexes:
filtered_graph
You just have to pass to function objects, as in here:
https://svn.boost.org/trac/boost/attachment/ticket/11838
https://svn.boost.org/trac/boost/attachment/ticket/11838/yen_ksp.hpp
If your function objects need more information, you can pass it to the constructors of the function objects.
Best, Irek
On 11.12.2015 08:09, Amit Prakash Ambasta wrote:
Hi,
In a boost graph, how can I filter vertices or edges by some attribute of Vertex/Edge Property?
I tried taking a look at FilteredGraph, but the operator function would also need to be able to call
boost::get(boost::vertex_bundle, graph_instance)[vertex] while only vertex is passed to the operator.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Amit Prakash Ambasta
-
Daniel Hofmann
-
Ireneusz Szcześniak