|
Boost Users : |
Subject: Re: [Boost-users] predicate for bundled properties in filtered graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-11-18 15:02:23
On Thu, 17 Nov 2011, giridhar wrote:
> Hello All,
>
> I am getting little confused in defining the predicate for filtered graph since my properties are bundled. I
> need to compare two bundled property inside the predicate, I am not getting any idea of how to access this property
> there.
>
> Bundled property is declared as:
>
> struct Edgep
> {
> int edge_index;
> int edge_w;
> std::string edge_name;
> int capacity;
> int residual_capcity;
> int bandwidth_used;
> };
>
> typedef subgraph< adjacency_list<vecS, vecS, undirectedS,
> Vertexp, property< edge_index_t, unsigned int, Edgep > > > Graph;
>
> I am creating the edge bundled property map as typedef bundle_property_map<Graph, Graph::edge_descriptor, Edgep,
> int> EM;
>
> I need to filter those edges whose bandwidth_used < residual_capacity.
>
> According to my understanding, I need to create a map to bandwidth_used and residual_capacity and pass this to
> predicate function. But can I define a predicate to take 2 different input maps or what is the better way to do
> this? I need some help at this part.
Yes, or just take the graph itself:
struct my_pred {
const Graph& g;
my_pred(const Graph& g): g(g) {}
bool operator()(const Edgep& e) const {
return g[e].bandwidth_used < g[e].residual_capacity;
}
};
-- Jeremiah Willcock
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