Example Program
Prims Algorithm
Prim's algorithm for computing a minimum spanning tree.
File "graph_algo_tree_prim.cpp"
A tutorial about prim's algorithm.
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |
Graph creation: 14 undirected edges {0,1}, {0,6}, ...
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 |
Two external property maps: Weight and vertex names
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 |
Out-parameter: Predecessor map to recover the tree
| 22 |
Prim's algorithm
| 23 |
Console Output
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 |
See
SeqAn - Sequence Analysis Library - www.seqan.de