我正在做Boost :: Graph的第一步,遇到一些(對我)意想不到的行爲。助推圖的外部屬性表現怪異?
我想要的是具有一系列edge_weight
屬性(該數字僅在運行時已知),並使用滿足某些約束條件的所有權重中的最小值。首先,typedef
聲明:
typedef adjacency_list<vecS, vecS, undirectedS, property<vertex_distance_t, int>, property<edge_weight_t, int> > Graph;
typedef graph_traits<Graph>::edge_descriptor Edge;
typedef property_map<Graph, edge_weight_t>::type WeightMap;
typedef property_map<Graph, vertex_distance_t>::type DistanceMap;
我初始化圖形如下:
void testcase() {
int t, e, s, a, b;
cin >> t >> e >> s >> a >> b;
Graph g(t);
WeightMap fastestLinkWeight = get(edge_weight, g);
vector<WeightMap> weightMaps(s);
for (int i=0;i<e;i++) {
int u, v;
cin >> u >> v;
Edge edge; bool worked;
tie(edge, worked) = add_edge(u, v, g);
for (int j=0;j<s;j++) {
cin >> weightMaps[j][edge];
}
fastestLinkWeight[edge] = INT_MAX;
cout << weightMaps[0][edge] << "\n";
}
}
它反覆輸出INT_MAX
。看起來像(外部)weightMaps[j]
都是相同的,等於內部屬性fastestLinkWeight
。但爲什麼?我怎樣才能確保我使用單獨的地圖?