c++ - 图中没有匹配的函数调用 boost::get
问题描述
我在 boost 中的示例 geometry/07_a_graph_route_example 之后对我的图进行建模。
我的图表如下所示:
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 模板。我如何阅读文档,这是执行此操作的标准方法。我的属性是否缺少某些内容?
我究竟做错了什么?
谢谢你的帮助。
解决方案
我猜是“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
,正确的代码将是这样的:
boost::dijkstra_shortest_paths(Graph, endVert, // Graph Object, End of Search Object
&predecessors[0], &costs[0], // Vectors to store predecessors and costs
get(&gG_edge_property::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
推荐阅读
- python - Python __hash__:同一性与等价性
- sql-server - 使用“NT AUTHORITY\ANONYMOUS LOGON”而不是 Windows 帐户在 New-PSSession 中调用 SqlCmd2(无远程处理)
- mysql - Galera 集群高 Ping
- python - 观察计数和预期计数之间的差异表
- .net - 使用 AngularJS 迁移到 Angular 8 的 Asp.Net MVC Razor 应用程序
- reactjs - 处理任意 JSON 树中的子状态
- http - 如何向 Unix 套接字发送 http 请求?
- android-recyclerview - 不兼容的类型:Int 和 Article
- swift - 如何在启动时使用 swiftUI 视图将 Google 地图相机聚焦在用户的当前位置
- c++ - std::atomic_ref 如何为非原子类型实现?