Boost logo

Boost Users :

From: Douglas Gregor (dgregor_at_[hidden])
Date: 2004-12-22 09:25:19


Please post in plain text in the future. HTML-formatted messages are
hard to read in some e-mail readers.

On Dec 22, 2004, at 5:35 AM, Matthias Linkenheil wrote:
> template <typename EdgeCapacityMap>
> struct positive_edge_capacity {
>   positive_edge_capacity() { }
>   positive_edge_capacity(EdgeCapacityMap capacity) :
> m_capacity(capacity) { }
>   template <typename Edge>
>   bool operator()(const Edge& e) const {
>     return 0 < boost::get(m_capacity, e);
>   }
>   EdgeCapacityMap m_capacity;
> };
> ...
>
>   typedef adjacency_list_traits<vecS, vecS, directedS> Traits;
>   typedef property<vertex_index_t, int> VertexProperties;
>   typedef property<edge_capacity_t, double,
>           property<edge_residual_capacity_t, double,
>           property<edge_reverse_t, Traits::edge_descriptor> > >
> EdgeProperties;
>   typedef adjacency_list<vecS, vecS, directedS, VertexProperties,
> EdgeProperties > Graph;
>
>   typedef graph_traits<Graph>::edge_descriptor edge_descriptor;
>   typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor;
>   const int V = x_size*y_size;
>   Graph g(V);
>  
>   property_map<Graph, vertex_index_t>::type vid = get(vertex_index,
> g);
>   property_map<Graph, edge_capacity_t>::type cap = get(edge_capacity,
> g);
>   property_map<Graph, edge_reverse_t>::type rev_edge =
> get(edge_reverse, g);
>   property_map<Graph, edge_residual_capacity_t >::type res_cap =
> get(edge_residual_capacity, g);
> ...
>  edmunds_karp_max_flow(g, s, t);
> ...

Probably okay so far...

>   positive_edge_capacity<cap> filter(get(edge_capacity, g));
>   filtered_graph<Graph, positive_edge_capacity<cap> > fg(g, filter);

I'm assuming you get an error here? That's because "cap" is an object,
not a type, so you can't use it in a template. You'll need to get the
type of it first:

   typedef property_map<Graph, edge_capacity_t>::type CapacityMap;
   positive_edge_capacity<CapacityMap> filter(get(edge_capacity, g));
   filtered_graph<Graph, positive_edge_capacity<CapacityMap> > fg(g,
filter);

        Doug


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