Следующий код выдает "отрицательный вес ребра" в prim_minimum_spanning_tree
call, хотя я использую только положительные числа. Что нужно изменить, чтобы все заработало?
typedef boost::property<vertex_distance_t, int> VertexProperty;
typedef boost::property<edge_weight_t, int> EdgeProperty;
typedef adjacency_list<vecS, vecS, undirectedS, VertexProperty, EdgeProperty> Graph;
typedef pair<int, int> Edge;
Edge edges[] = {Edge(0, 1), Edge(1, 2)};
int weights[] = {2, 1}; // this works: int weights[] = {1, 2};
Graph g(edges, edges + sizeof(edges)/sizeof(Edge), weights, 3);
std::vector<Graph::vertex_descriptor> predecessors(num_vertices(g));
boost::prim_minimum_spanning_tree(g, &predecessors[0]);
Примечание. Я могу добиться успеха, изменив значения веса.
Компилятор: MS Visual Studio 2010 C++ Boost версии: 1.54