Boost图库:设置边权重值
我正在研究 boost 图形库的使用,以便将它们应用于我想到的各种网络问题。
在示例中,我一直在查看图形边缘值(“权重”)始终初始化为整数,例如在这些 贝尔曼-福特 和 Kruskal 算法 例如:
int weights[] = { 1, 1, 2, 7, 3, 1, 1, 1 };
我的问题是,如果我尝试将权重更改为双倍,我会收到一堆有关转换等的警告消息,到目前为止我一直不知道如何克服。
有人看到解决这个问题的方法吗?
I am investigating the use of the boost graph libraries in order to apply them to various network problems I have in mind.
In the examples I have been looking at the graph edge values ("weights") are always initialized as integers, such as in these Bellman-Ford and Kruskal algorithms eg:
int weights[] = { 1, 1, 2, 7, 3, 1, 1, 1 };
My problem is if I try and change the weights to double, I get a heap of warning messages about conversions etc, which so far I have not been able to figure out how to overcome.
Does anyone see a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是由于
weights[]
数组与 boost 图/算法用于边权重的类型不匹配造成的。例如,在第一个链接的示例中,您还应该更改
为
在第二个
示例中
It's caused by a mismatch between the
weights[]
array and the type used for edge weights by your boost graph/algorithm.In the first linked sample, eg, you should also change
to
In the second
to