[英]Boost graph libraries: setting edge weight values
我正在研究提升圖庫的使用,以便將它們應用於我想到的各種網絡問題。
在示例中,我一直在查看圖形的邊緣值(“權重”)始終初始化為整數,例如在這些Bellman-Ford和Kruskal算法中,例如:
int weights[] = { 1, 1, 2, 7, 3, 1, 1, 1 };
我的問題是,如果我嘗試將權重更改為兩倍,則會收到大量有關轉換等的警告消息,到目前為止,我仍然無法弄清楚如何克服。
有誰看到解決方法?
這是由於boosts圖/算法的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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.