Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Searching for a convenient way to combine predicates for filtered_graph
From: Cedric Laczny (cedric.laczny_at_[hidden])
Date: 2010-11-30 11:28:22


On Tuesday, 30. November 2010 16:57:17 Jeremiah Willcock wrote:
> On Mon, 29 Nov 2010, Cedric Laczny wrote:
> > Hi,
> >
> > I was wondering if there is a convenient (and to some extent intuitive)
> > way to combine several predicates used in filtering a graph?
> > The idea is to have some predicates defined and arbitrarily combine them
> > so that the filtered_graph will check for compliance of each individual
> > predicate and either make this vertex/edge visible or not.
> > Of course, the predicates should be specific to vertices or edges,
> > respectively, when being combined.
> > When using std::vector or such, they would need to be all of the same
> > type which does not seem very nice/feasible IMHO.
> > Also defining a "big" predicate having a multitude of "smaller"
> > predicates as members is not really an option as this is very
> > restricted.
> > Something like
> > big_predicate = predicate1 || predicate2 || predicate3
> > (syntax should just illustrate the idea) maybe?
>
> If you don't want to use Boost.Lambda, Boost.Bind also has some operators
> overloaded
> (<URL:http://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html#operators>)
> to provide the syntax you wanted.
>

Thanks for the hint. Unfortunately, I'm still hanging at the point where the
type of the specified predicate(s) comes into play.
Let's look at an example:

struct VPred1{
        VPred1() {};
        // etc....
        template< V >
        bool operator( const V& v)
        {return true;}
}
struct Vpred2{
// s. Vpred1 but operator() returns false
}

Vpred1 pred1;
Vpred2 pred2;
typedef adjacency_list<> Graph;
Graph g;
// fill graph g
filtered_graph< Graph, keep_all, ??? > fg( g, keep_all(), ???);

In the example above I would like to provide both vpred-structs to the
filtered_graph like so:
filtered_graph< Graph, keep_all, ??? > fg( g, keep_all(), pred1 && pred2);

This is not supposed to work out-of-the-box, it should just demonstrate the
idea a bit more into detail.

Concerning the "???" in the template-specification, I have no idea how this
should be specifed. All the examples I have found so far, either for phoenix
or bind, are direct applications and do not involve the specification of
templates. Therefore I have nowhere to start learning how to do this.

> -- Jeremiah Willcock
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

Best,

Cedric


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