Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost Graph] newbie - dijkstra & external weightmap
From: Fergal Dalton (fergalish_at_[hidden])
Date: 2009-12-15 06:11:31


> Use iterator_property_map
> (http://www.boost.org/doc/libs/1_41_0/libs/property_map/doc/iterator_property_map.html)
> using syntax such as the following (replacing
> "weight_map(agent_weightmap)" in the code just above):
>
> weight_map(
> make_iterator_property_map(
> agent_weightmap.begin(),
> get(vertex_index, g)))
>
> You will need to include <boost/property_map/property_map.hpp> to get
> iterator_property_map.
>
> -- Jeremiah Willcock
>

Thanks Jeremiah,

But I'm talking about edge weights - why would you put in
"get(vertex_index,g)" and not "get(edge_index,g)" or
similar (I've tried this simple substitution and it doesn't
work; so it's obviously more complex than that)? In any
case I've tried more or less exactly what you suggested as
follows but the compiler spits out a long error, reported
below (libboost1.40):

--------
#include <boost/property_map/property_map.hpp>
class road;
typedef adjacency_list<setS,vecS,undirectedS,no_property,road> Graph;
typedef boost::vertex_descriptor vdest;
vdest shortest_path(Graph& g, vdest src, vdest dst)
   {
   vector<vdest> parent(num_vertices(g));
   vector<double> agent_weightmap(num_edges(g));

   dijkstra_shortest_paths(g,src,
     //weight_map(get(&road::transit_time,g)) // ---> this weight_map works
     weight_map(make_iterator_property_map(agent_weightmap.begin(), get(vertex_index, g)))
     .predecessor_map(make_iterator_property_map(parent.begin(), get(vertex_index, g))));

   vdest vd;
   for (vd=dst ; parent[vd]!=src ; vd=parent[vd]);
   return(vd);
   }
--------

Compiler error:
-------
/usr/include/boost/property_map/property_map.hpp: In function ‘Reference boost::get(...
[lots of instantiated froms] ...
instantiated from [dijkstra_shortest_paths(...)]
/usr/include/boost/property_map/property_map.hpp:317: error: no match for ‘operator[]’ in ‘(const boost::iterator_property_map<__gnu_cxx::__normal_iterator<double*, ....
/usr/include/boost/property_map/property_map.hpp:354: note: candidates are: R boost::iterator_property_map<RandomAccessIterator, IndexMap, .......
-------

I'm getting a backward warning on hash_set included from
boost/graph/adjacency_list.hpp - could this be an issue?

Thanks again,
Fergal.


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