#include #include #include #include #include using namespace std; using namespace boost; typedef adjacency_list > Graph; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; typedef property_map::type weightMap; int main() { bool success; Graph g(3); weightMap weights = get(edge_weight, g); Edge e; tie(e, success) = add_edge(0, 1, g); assert (success); weights[e] = 2; tie(e, success) = add_edge(0, 2, g); assert (success); weights[e] = 3; tie(e, success) = add_edge(1, 2, g); assert (success); weights[e] = 4; std::vector predecessors(num_vertices(g)); std::vector distances(num_vertices(g)); prim_minimum_spanning_tree(g, &predecessors[0], root_vertex(1).distance_map(&distances[0])); for (int i = 0; i < 3; ++ i) { cout << distances[i] << endl; } //Expected output 2,0,5, but is 2,0,3 return 0; }