C++ Boost图形库-来自外部向量的权重属性
我做错了什么C++ Boost图形库-来自外部向量的权重属性,c++,templates,boost,boost-graph,C++,Templates,Boost,Boost Graph,我做错了什么 #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
#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))));
}
#包括
#包括
#包括
使用名称空间std;
typedef boost::邻接列表图;
void dijkstra(图形和g、向量和边权重、int源、向量和距离、向量和上一个){
dijkstra_最短路径(g,源,
boost::weight_map(boost::make_iterator_property_map(edge_weights.begin(),get(boost::edge_index,g)));
}
(编译时使用:g++main.cc-L/usr/local/boost/)
错误:
/usr/include/boost/graph/detail/adjacency_list.hpp:2665:错误:初始化类型为'boost::detail::error_property_not_found&'的临时类型'boost::detail::error_property_not_found'的非常量引用无效
我认为问题可能是没有从边到整数的默认映射。如果是这样,我如何定义一个属性?您的图形没有
edge\u index
属性,您正在创建iterator\u属性映射时使用该属性。您需要将这样一个属性添加到图形中并进行填充。有关需要执行的操作,请参阅和。请提供一个复制此问题的最小完整文件和编译行。我已将完整文件添加为编辑。请看以下内容:该示例使用内部权重。我要外用的。