Bal*_*ise 6 c++ boost graph dijkstra boost-graph
我目前正在查看Boost Dijkstra的文档 - http://www.boost.org/doc/libs/1_52_0/libs/graph/doc/dijkstra_shortest_paths.html ; 我的目标是在计算距离时修改距离组合以获得"最大"而不是"加".医生说这个:
IN: distance_combine(CombineFunction cmb)
This function is used to combine distances to compute the distance of a path. The
CombineFunction type must be a model of Binary Function. The first argument typ
of the binary function must match the value type of the DistanceMap property map
and the second argument type must match the value type of the WeightMap property
map. The result type must be the same type as the distance value type.
Default: closed_plus<D> with D=typename property_traits<DistanceMap>::value_type
Run Code Online (Sandbox Code Playgroud)
定义这样一个Combine函数的语法是什么?我试过用std :: max摸索,但我的编译器似乎并不满意.
可能让它的参数是模板可能会让事情变得有点困难......
尝试(其中 T 是距离的类型)
T comb(T& a, T& b) { return std::max(a, b); }
Run Code Online (Sandbox Code Playgroud)
并通过梳子。