1 | // TestBGL.cpp : Defines the entry point for the console application.
|
---|
2 | //
|
---|
3 |
|
---|
4 | #include <boost\graph\adjacency_list.hpp>
|
---|
5 | #include <boost\graph\prim_minimum_spanning_tree.hpp>
|
---|
6 |
|
---|
7 | #include <boost\graph\graphviz.hpp>
|
---|
8 |
|
---|
9 | using namespace std;
|
---|
10 |
|
---|
11 | using namespace boost;
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 | int _main(int argc, char* argv[])
|
---|
16 | {
|
---|
17 |
|
---|
18 | typedef boost::property<vertex_distance_t, int> VertexProperty;
|
---|
19 | typedef boost::property<edge_weight_t, int> EdgeProperty;
|
---|
20 |
|
---|
21 | typedef adjacency_list<vecS, vecS, undirectedS, VertexProperty, EdgeProperty> Graph;
|
---|
22 |
|
---|
23 | typedef pair<int, int> Edge;
|
---|
24 |
|
---|
25 | Edge edges[] = {Edge(0, 1), Edge(1, 2)};
|
---|
26 | int weights[] = {2, 1}; // this works: int weights[] = {1, 2};
|
---|
27 |
|
---|
28 | Graph g(edges, edges + sizeof(edges)/sizeof(Edge), weights, 3);
|
---|
29 | std::vector<Graph::vertex_descriptor> predecessors(num_vertices(g));
|
---|
30 | prim_minimum_spanning_tree(g, &predecessors[0]);
|
---|
31 | }
|
---|
32 |
|
---|