2012-05-17 114 views
0

我在做什么错了?Boost Graph Library - 从外部矢量权重属性

#include <vector> 

#include <boost/graph/adjacency_list.hpp> 
#include <boost/graph/dijkstra_shortest_paths.hpp> 

using namespace std; 

typedef boost::adjacency_list<> Graph; 

void dijkstra(Graph &g, vector<double> &edge_weights, int source, vector<double> &dist, vector<int> &prev) { 
boost::dijkstra_shortest_paths(g, source, 
           boost::weight_map(boost::make_iterator_property_map(edge_weights.begin(), get(boost::edge_index, g)))); 

} 

(编译具有:G ++ main.cc -L在/ usr /本地/升压/

错误:

/usr/include/boost/graph/detail/adjacency_list.hpp:2665: error: invalid initialization of non-const reference of type ‘boost::detail::error_property_not_found&’ from a temporary of type ‘boost::detail::error_property_not_found’

我认为这个问题可能是没有默认从边到整数的映射。如果是这样,我如何定义一个?

+0

请给出一个最小的完整文件和编译行来重现此问题。 – robert

+0

我已将完整文件添加为编辑。 – zoo

+0

看看这个:http://www.boost.org/doc/libs/1_38_0/libs/graph/example/dijkstra-example.cpp – JohnTortugo

回答

相关问题