Hi Andrea,
On Jun 13, 2005, at 7:07 AM, Andrea Olgiati wrote:
I've encountered a problem whilst compiling the following
program, and I can't quite figure out why it shouldn't work. Whilst
compiling usign boost 1.32.0 and gcc 3.3.4, I get
cannot convert
`boost::detail::edge_desc_impl<' to
`int'
for argument `2' to `const T& get(const T*, int) [with T = int]'
I believe this is saying that edge descriptors cannot be used as
indices into a property map (that is, "wm"). Why is this different
from vertex descriptors, which are accepted as indices into "p" and
"dist"?
The problem here is that std::vectors really only work as property
maps when the descriptors are integers and, unfortunately, that only
works with vertex descriptors (in some limited cases). The easiest way
to solve the problem is to make "wm" an internal property map, by
putting the edge weight into the graph itself.
There's an updated version of your code below, where I've done three
things:
(1) I added an "edge_weight" property to each edge, by changing the
Graph typedef.
(2) I changed the definition of "wm" so that it is a property map
accessing the weights of each edge (that are stored inside the graph
itself).
(3) The call to bellman_ford_shortest_paths just passes the property
map "wm", instead of &wm[0].
Doug
#include <
#include <
#include <
int
main ()
{
typedef boost::adjacency_list< >
Graph;
Graph G;
boost::property_map<::type wm =
boost::get(boost::edge_weight, G);
std::vector << boost::graph_traits << Graph >::vertex_descriptor > p;
std::vector << int > dist;
boost::bellman_ford_shortest_paths (G, boost::num_vertices(G),
wm, &p[0], &dist[0],
boost::closed_plus << int >(),
std::less << int >(),
boost::default_bellman_visitor
());
return 0;
}