#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() { Graph g(3); WeightMap m = get(edge_weight, g); bool success; Edge e; tie(e, success) = add_edge(0, 1, g); m[e] = 2; tie(e, success) = add_edge(0, 2, g); m[e] = 3; tie(e, success) = add_edge(1, 2, g); m[e] = 4; int startPoint = 2; vector p(3); dijkstra_shortest_paths(g, startPoint, predecessor_map(&p[0])); cout << "Dijkstra:" << endl; cout << p[0] << " " << p[1] << " " << p[2] << endl; prim_minimum_spanning_tree(g, &p[0], root_vertex(startPoint)); cout << "Prim:" << endl; cout << p[0] << " " << p[1] << " " << p[2] << endl; }