我正在根据boost中的geometry/07_a_graph_route_example
示例建模我的图表。
我的Graph看起来像这样:
typedef boost::adjacency_list<
boost::listS,
boost::vecS,
boost::directedS,
gG_vertex_property<string, double, pointClass>,
gG_edge_property<listClass, pointClass>
> graph_type;
graph_type Graph;
使用gG_vertex_property
和gG_edge_property
作为自定义属性。
现在每次我尝试调用dijkstra_shortest_path
时
boost::dijkstra_shortest_paths(Graph, endVert, // Graph Object, End of Search Object
&predecessors[0], &costs[0], // Vectors to store predecessors and costs
boost::get(boost::edge_weight, Graph),
boost::get(boost::vertex_index, Graph), // Vertex Index Map
std::less<double>(), std::plus<double>(), // Cost calculating operators
(std::numeric_limits<double>::max)(), double(), // limits
boost::dijkstra_visitor<boost::null_visitor>()); // Visitior, does nothing at the moment
作为WeightMap
,我得到:
错误:没有匹配的函数用于调用'get' boost::get(boost::edge_weight,Graph)
还有很多不适合我的用例的add模板。我是如何阅读文档的,这是标准的方法。我的财产是不是少了什么?
我做错了什么?
谢谢你的帮助
1条答案
按热度按时间x4shl7ld1#
我猜
gG_vertex_property
和gG_edge_property
是“捆绑”属性(没有自定义属性这样的东西)。如果是这样,你应该传递这些而不是“boost::get(boost::edge_weight,Graph)”,它试图访问“内部”属性,完全独立的事情。参见https://www.boost.org/doc/libs/1_77_0/libs/graph/doc/bundles.html。我猜如果属性是结构体,边权重保留在gG_edge_property::weight
中,正确的代码应该是这样的: