Use iterator_property_map
(http://www.boost.org/doc/libs/1_41_0/libs/property_map/doc/iterator_property...)
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 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
class road;
typedef adjacency_list 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