5

我正在研究 boost 图形库的使用,以便将它们应用于我想到的各种网络问题。

在示例中,我一直在查看图形边缘值(“权重”)始终初始化为整数,例如在这些Bellman-FordKruskal算法中,例如:

int weights[] = { 1, 1, 2, 7, 3, 1, 1, 1 };

我的问题是,如果我尝试将权重更改为两倍,我会收到一堆关于转换等的警告消息,到目前为止我还无法弄清楚如何克服。

有没有人看到解决这个问题的方法?

4

1 回答 1

6

weights[]这是由于数组与提升图/算法用于边缘权重的类型不匹配造成的。

例如,在第一个链接示例中,您还应该更改

struct EdgeProperties {
  int weight;
};
[...]
property_map<Graph, int EdgeProperties::*>::type 

struct EdgeProperties {
  double weight;
};
[...]
property_map<Graph, double EdgeProperties::*>::type 

在第二

typedef adjacency_list < vecS, vecS, undirectedS,
    no_property, property < edge_weight_t, int > > Graph;

typedef adjacency_list < vecS, vecS, undirectedS,
    no_property, property < edge_weight_t, double > > Graph;
于 2010-04-09T14:59:02.393 回答