我正在做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
。但为什么?我怎样才能确保我使用单独的地图?