
Hi, I can't find how to do this pretty basic thing : having a function instead of a field to compute the cost of edges for various path finding algorithms. I couldn't find the answer in the documentation and Google was of no help. Did I miss something obvious ? Example : ------------------- #include <boost/graph/dijkstra_shortest_paths.hpp> #include <boost/graph/graph_traits.hpp> #include <boost/graph/adjacency_list.hpp> struct my_edge { double cost() const { return cost_ * 2; } double cost_; }; struct my_node { }; int main() { typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, my_node, my_edge > graph_t; typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t; graph_t graph; vertex_t v /*= ... */; using boost::weight_map; // Works : boost::dijkstra_shortest_paths(graph, v, weight_map(boost::get(&my_edge::cost_, graph))); // Doesn't compile : //boost::dijkstra_shortest_paths(graph, v, // weight_map(boost::get(&my_edge::cost, graph))); } ------------------- Thanks ! -- Maxime