1 .. Copyright (C) 2004-2008 The Trustees of Indiana University.
2 Use, modification and distribution is subject to the Boost Software
3 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 http://www.boost.org/LICENSE_1_0.txt)
6 ============================
7 |Logo| Minimum Spanning Tree
8 ============================
10 The Parallel BGL contains four `minimum spanning tree`_ (MST)
11 algorithms [DG98]_ for use on undirected, weighted, distributed
12 graphs. The graphs need not be connected: each algorithm will compute
13 a minimum spanning forest (MSF) when provided with a disconnected
16 The interface to each of the four algorithms is similar to the
17 implementation of 'Kruskal's algorithm'_ in the sequential BGL. Each
18 accepts, at a minimum, a graph, a weight map, and an output
19 iterator. The edges of the MST (or MSF) will be output via the output
20 iterator on process 0: other processes may receive edges on their
21 output iterators, but the set may not be complete, depending on the
22 algorithm. The algorithm parameters are documented together, because
23 they do not vary greatly. See the section `Selecting an MST
24 algorithm`_ for advice on algorithm selection.
26 The graph itself must model the `Vertex List Graph`_ concept and the
27 Distributed Edge List Graph concept. Since the most common
28 distributed graph structure, the `distributed adjacency list`_, only
29 models the Distributed Vertex List Graph concept, it may only be used
30 with these algorithms when wrapped in a suitable adaptor, such as the
31 `vertex_list_adaptor`_.
37 <``boost/graph/distributed/dehne_gotz_min_spanning_tree.hpp``>
43 The graph type must be a model of `Vertex List Graph`_ and
44 `Distributed Edge List Graph`_.
48 IN/OUT: ``WeightMap weight``
49 The weight map must be a `Distributed Property Map`_ and a `Readable
50 Property Map`_ whose key type is the edge descriptor of the graph
51 and whose value type is numerical.
55 IN/OUT: ``OutputIterator out``
56 The output iterator through which the edges of the MSF will be
57 written. Must be capable of accepting edge descriptors for output.
62 IN: ``VertexIndexMap index``
63 A mapping from vertex descriptors to indices in the range *[0,
64 num_vertices(g))*. This must be a `Readable Property Map`_ whose
65 key type is a vertex descriptor and whose value type is an integral
66 type, typically the ``vertices_size_type`` of the graph.
68 **Default:** ``get(vertex_index, g)``
71 IN/UTIL: ``RankMap rank_map``
72 Stores the rank of each vertex, which is used for maintaining
73 union-find data structures. This must be a `Read/Write Property Map`_
74 whose key type is a vertex descriptor and whose value type is an
77 **Default:** An ``iterator_property_map`` built from an STL vector
78 of the ``vertices_size_type`` of the graph and the vertex index map.
81 IN/UTIL: ``ParentMap parent_map``
82 Stores the parent (representative) of each vertex, which is used for
83 maintaining union-find data structures. This must be a `Read/Write
84 Property Map`_ whose key type is a vertex descriptor and whose value
85 type is also a vertex descriptor.
87 **Default:** An ``iterator_property_map`` built from an STL vector
88 of the ``vertex_descriptor`` of the graph and the vertex index map.
91 IN/UTIL: ``SupervertexMap supervertex_map``
92 Stores the supervertex index of each vertex, which is used for
93 maintaining the supervertex list data structures. This must be a
94 `Read/Write Property Map`_ whose key type is a vertex descriptor and
95 whose value type is an integral type.
97 **Default:** An ``iterator_property_map`` built from an STL vector
98 of the ``vertices_size_type`` of the graph and the vertex index map.
102 ``dense_boruvka_minimum_spanning_tree``
103 ---------------------------------------
108 template<typename Graph, typename WeightMap, typename OutputIterator,
109 typename VertexIndexMap, typename RankMap, typename ParentMap,
110 typename SupervertexMap>
112 dense_boruvka_minimum_spanning_tree(const Graph& g, WeightMap weight_map,
114 VertexIndexMap index,
115 RankMap rank_map, ParentMap parent_map,
116 SupervertexMap supervertex_map);
118 template<typename Graph, typename WeightMap, typename OutputIterator,
119 typename VertexIndex>
121 dense_boruvka_minimum_spanning_tree(const Graph& g, WeightMap weight_map,
122 OutputIterator out, VertexIndex index);
124 template<typename Graph, typename WeightMap, typename OutputIterator>
126 dense_boruvka_minimum_spanning_tree(const Graph& g, WeightMap weight_map,
133 The dense Boruvka distributed minimum spanning tree algorithm is a
134 direct parallelization of the sequential MST algorithm by
135 Boruvka. The algorithm first creates a *supervertex* out of each
136 vertex. Then, in each iteration, it finds the smallest-weight edge
137 incident to each vertex, collapses supervertices along these edges,
138 and removals all self loops. The only difference between the
139 sequential and parallel algorithms is that the parallel algorithm
140 performs an all-reduce operation so that all processes have the
141 global minimum set of edges.
143 Unlike the other three algorithms, this algorithm emits the complete
144 list of edges in the minimum spanning forest via the output iterator
145 on all processes. It may therefore be more useful than the others
146 when parallelizing sequential BGL programs.
151 The distributed algorithm requires *O(log n)* BSP supersteps, each of
152 which requires *O(m/p + n)* time and *O(n)* communication per
158 The following charts illustrate the performance of this algorithm on
159 various random graphs. We see that the algorithm scales well up to 64
160 or 128 processors, depending on the type of graph, for dense
161 graphs. However, for sparse graphs performance tapers off as the
162 number of processors surpases *m/n*, i.e., the average degree (which
163 is 30 for this graph). This behavior is expected from the algorithm.
165 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=5
167 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=5&speedup=1
169 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=5
171 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=5&speedup=1
173 ``merge_local_minimum_spanning_trees``
174 --------------------------------------
179 template<typename Graph, typename WeightMap, typename OutputIterator,
180 typename VertexIndexMap>
182 merge_local_minimum_spanning_trees(const Graph& g, WeightMap weight,
184 VertexIndexMap index);
186 template<typename Graph, typename WeightMap, typename OutputIterator>
187 inline OutputIterator
188 merge_local_minimum_spanning_trees(const Graph& g, WeightMap weight,
195 The merging local MSTs algorithm operates by computing minimum
196 spanning forests from the edges stored on each process. Then the
197 processes merge their edge lists along a tree. The child nodes cease
198 participating in the computation, but the parent nodes recompute MSFs
199 from the newly acquired edges. In the final round, the root of the
200 tree computes the global MSFs, having received candidate edges from
201 every other process via the tree.
206 This algorithm requires *O(log_D p)* BSP supersteps (where *D* is the
207 number of children in the tree, and is currently fixed at 3). Each
208 superstep requires *O((m/p) log (m/p) + n)* time and *O(m/p)*
209 communication per process.
214 The following charts illustrate the performance of this algorithm on
215 various random graphs. The algorithm only scales well for very dense
216 graphs, where most of the work is performed in the initial stage and
217 there is very little work in the later stages.
219 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=6
221 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=6&speedup=1
223 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=6
225 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=6&speedup=1
228 ``boruvka_then_merge``
229 ----------------------
234 template<typename Graph, typename WeightMap, typename OutputIterator,
235 typename VertexIndexMap, typename RankMap, typename ParentMap,
236 typename SupervertexMap>
238 boruvka_then_merge(const Graph& g, WeightMap weight, OutputIterator out,
239 VertexIndexMap index, RankMap rank_map,
240 ParentMap parent_map, SupervertexMap
243 template<typename Graph, typename WeightMap, typename OutputIterator,
244 typename VertexIndexMap>
245 inline OutputIterator
246 boruvka_then_merge(const Graph& g, WeightMap weight, OutputIterator out,
247 VertexIndexMap index);
249 template<typename Graph, typename WeightMap, typename OutputIterator>
250 inline OutputIterator
251 boruvka_then_merge(const Graph& g, WeightMap weight, OutputIterator out);
257 This algorithm applies both Boruvka steps and local MSF merging steps
258 together to achieve better asymptotic performance than either
259 algorithm alone. It first executes Boruvka steps until only *n/(log_d
260 p)^2* supervertices remain, then completes the MSF computation by
261 performing local MSF merging on the remaining edges and
267 This algorithm requires *log_D p* + *log log_D p* BSP supersteps. The
268 time required by each superstep depends on the type of superstep
269 being performed; see the distributed Boruvka or merging local MSFS
270 algorithms for details.
275 The following charts illustrate the performance of this algorithm on
276 various random graphs. We see that the algorithm scales well up to 64
277 or 128 processors, depending on the type of graph, for dense
278 graphs. However, for sparse graphs performance tapers off as the
279 number of processors surpases *m/n*, i.e., the average degree (which
280 is 30 for this graph). This behavior is expected from the algorithm.
282 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=7
284 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=7&speedup=1
286 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=7
288 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=7&speedup=1
290 ``boruvka_mixed_merge``
291 -----------------------
296 template<typename Graph, typename WeightMap, typename OutputIterator,
297 typename VertexIndexMap, typename RankMap, typename ParentMap,
298 typename SupervertexMap>
300 boruvka_mixed_merge(const Graph& g, WeightMap weight, OutputIterator out,
301 VertexIndexMap index, RankMap rank_map,
302 ParentMap parent_map, SupervertexMap
305 template<typename Graph, typename WeightMap, typename OutputIterator,
306 typename VertexIndexMap>
307 inline OutputIterator
308 boruvka_mixed_merge(const Graph& g, WeightMap weight, OutputIterator out,
309 VertexIndexMap index);
311 template<typename Graph, typename WeightMap, typename OutputIterator>
312 inline OutputIterator
313 boruvka_mixed_merge(const Graph& g, WeightMap weight, OutputIterator out);
319 This algorithm applies both Boruvka steps and local MSF merging steps
320 together to achieve better asymptotic performance than either method
321 alone. In each iteration, the algorithm first performs a Boruvka step
322 and then merges the local MSFs computed based on the supervertex
328 This algorithm requires *log_D p* BSP supersteps. The
329 time required by each superstep depends on the type of superstep
330 being performed; see the distributed Boruvka or merging local MSFS
331 algorithms for details. However, the algorithm is
332 communication-optional (requiring *O(n)* communication overall) when
333 the graph is sufficiently dense, i.e., *m/n >= p*.
338 The following charts illustrate the performance of this algorithm on
339 various random graphs. We see that the algorithm scales well up to 64
340 or 128 processors, depending on the type of graph, for dense
341 graphs. However, for sparse graphs performance tapers off as the
342 number of processors surpases *m/n*, i.e., the average degree (which
343 is 30 for this graph). This behavior is expected from the algorithm.
345 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=8
347 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&columns=8&speedup=1
349 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=8
351 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&columns=8&speedup=1
354 Selecting an MST algorithm
355 --------------------------
357 Dehne and Gotz reported [DG98]_ mixed results when evaluating these
358 four algorithms. No particular algorithm was clearly better than the
359 others in all cases. However, the asymptotically best algorithm
360 (``boruvka_mixed_merge``) seemed to perform more poorly in their tests
361 than the other merging-based algorithms. The following performance
362 charts illustrate the performance of these four minimum spanning tree
365 Overall, ``dense_boruvka_minimum_spanning_tree`` gives the most
366 consistent performance and scalability for the graphs we
367 tested. Additionally, it may be more suitable for sequential programs
368 that are being parallelized, because it emits complete MSF edge lists
369 via the output iterators in every process.
371 Performance on Sparse Graphs
372 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER&dataset=TimeSparse&columns=5,6,7,8
375 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER&dataset=TimeSparse&columns=5,6,7,8&speedup=1
377 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SF&dataset=TimeSparse&columns=5,6,7,8
379 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SF&dataset=TimeSparse&columns=5,6,7,8&speedup=1
381 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SW&dataset=TimeSparse&columns=5,6,7,8
383 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SW&dataset=TimeSparse&columns=5,6,7,8&speedup=1
385 Performance on Dense Graphs
386 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
387 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER&dataset=TimeDense&columns=5,6,7,8
389 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER&dataset=TimeDense&columns=5,6,7,8&speedup=1
391 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SF&dataset=TimeDense&columns=5,6,7,8
393 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SF&dataset=TimeDense&columns=5,6,7,8&speedup=1
395 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SW&dataset=TimeDense&columns=5,6,7,8
397 .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=SW&dataset=TimeDense&columns=5,6,7,8&speedup=1
399 -----------------------------------------------------------------------------
401 Copyright (C) 2004 The Trustees of Indiana University.
403 Authors: Douglas Gregor and Andrew Lumsdaine
405 .. |Logo| image:: pbgl-logo.png
408 :target: http://www.osl.iu.edu/research/pbgl
410 .. _minimum spanning tree: http://www.boost.org/libs/graph/doc/graph_theory_review.html#sec:minimum-spanning-tree
411 .. _Kruskal's algorithm: http://www.boost.org/libs/graph/doc/kruskal_min_spanning_tree.html
412 .. _Vertex list graph: http://www.boost.org/libs/graph/doc/VertexListGraph.html
413 .. _distributed adjacency list: distributed_adjacency_list.html
414 .. _vertex_list_adaptor: vertex_list_adaptor.html
415 .. _Distributed Edge List Graph: DistributedEdgeListGraph.html
416 .. _Distributed property map: distributed_property_map.html
417 .. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
418 .. _Read/Write Property Map: http://www.boost.org/libs/property_map/ReadWritePropertyMap.html
420 .. [DG98] Frank Dehne and Silvia Gotz. *Practical Parallel Algorithms
421 for Minimum Spanning Trees*. In Symposium on Reliable Distributed Systems,
422 pages 366--371, 1998.