Boost logo

Boost Users :

Subject: Re: [Boost-users] <BGL>Filter vertices/edges by vertex/edge attributes?
From: Daniel Hofmann (daniel_at_[hidden])
Date: 2015-12-11 07:39:53


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<Graph, EdgePredicate, VertexPredicate>
>
> 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_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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