strong_components.rst 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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)
  5. ===========================
  6. |Logo| Connected Components
  7. ===========================
  8. ::
  9. template<typename Graph, typename ComponentMap>
  10. inline typename property_traits<ComponentMap>::value_type
  11. strong_components( const Graph& g, ComponentMap c);
  12. namespace graph {
  13. template<typename Graph, typename VertexComponentMap>
  14. void
  15. fleischer_hendrickson_pinar_strong_components(const Graph& g, VertexComponentMap r);
  16. template<typename Graph, typename ReverseGraph,
  17. typename ComponentMap, typename IsoMapFR, typename IsoMapRF>
  18. inline typename property_traits<ComponentMap>::value_type
  19. fleischer_hendrickson_pinar_strong_components(const Graph& g,
  20. ComponentMap c,
  21. const ReverseGraph& gr,
  22. IsoMapFR fr, IsoMapRF rf);
  23. }
  24. The ``strong_components()`` function computes the strongly connected
  25. components of a directed graph. The distributed strong components
  26. algorithm uses the `sequential strong components`_ algorithm to
  27. identify components local to a processor. The distributed portion of
  28. the algorithm is built on the `distributed breadth first search`_
  29. algorithm and is based on the work of Fleischer, Hendrickson, and
  30. Pinar [FHP00]_. The interface is a superset of the interface to the
  31. BGL `sequential strong components`_ algorithm. The number of
  32. strongly-connected components in the graph is returned to all
  33. processes.
  34. The distributed strong components algorithm works on both ``directed``
  35. and ``bidirectional`` graphs. In the bidirectional case, a reverse
  36. graph adapter is used to produce the required reverse graph. In
  37. the directed case, a separate graph is constructed in which all the
  38. edges are reversed.
  39. .. contents::
  40. Where Defined
  41. -------------
  42. <``boost/graph/distributed/strong_components.hpp``>
  43. also accessible from
  44. <``boost/graph/strong_components.hpp``>
  45. Parameters
  46. ----------
  47. IN: ``const Graph& g``
  48. The graph type must be a model of `Distributed Graph`_. The graph
  49. type must also model the `Incidence Graph`_ and be directed.
  50. OUT: ``ComponentMap c``
  51. The algorithm computes how many strongly connected components are in the
  52. graph, and assigns each component an integer label. The algorithm
  53. then records to which component each vertex in the graph belongs by
  54. recording the component number in the component property map. The
  55. ``ComponentMap`` type must be a `Distributed Property Map`_. The
  56. value type must be the ``vertices_size_type`` of the graph. The key
  57. type must be the graph's vertex descriptor type.
  58. UTIL: ``VertexComponentMap r``
  59. The algorithm computes a mapping from each vertex to the
  60. representative of the strong component, stored in this property map.
  61. The ``VertexComponentMap`` type must be a `Distributed Property Map`_.
  62. The value and key types must be the vertex descriptor of the graph.
  63. IN: ``const ReverseGraph& gr``
  64. The reverse (or transpose) graph of ``g``, such that for each
  65. directed edge *(u, v)* in ``g`` there exists a directed edge
  66. *(fr(v), fr(u))* in ``gr`` and for each edge *(v', u')* in *gr*
  67. there exists an edge *(rf(u'), rf(v'))* in ``g``. The functions
  68. *fr* and *rf* map from vertices in the graph to the reverse graph
  69. and vice-verse, and are represented as property map arguments. The
  70. concept requirements on this graph type are equivalent to those on
  71. the ``Graph`` type, but the types need not be the same.
  72. **Default**: Either a ``reverse_graph`` adaptor over the original
  73. graph (if the graph type is bidirectional, i.e., models the
  74. `Bidirectional Graph`_ concept) or a `distributed adjacency list`_
  75. constructed from the input graph.
  76. IN: ``IsoMapFR fr``
  77. A property map that maps from vertices in the input graph ``g`` to
  78. vertices in the reversed graph ``gr``. The type ``IsoMapFR`` must
  79. model the `Readable Property Map`_ concept and have the graph's
  80. vertex descriptor as its key type and the reverse graph's vertex
  81. descriptor as its value type.
  82. **Default**: An identity property map (if the graph type is
  83. bidirectional) or a distributed ``iterator_property_map`` (if the
  84. graph type is directed).
  85. IN: ``IsoMapRF rf``
  86. A property map that maps from vertices in the reversed graph ``gr``
  87. to vertices in the input graph ``g``. The type ``IsoMapRF`` must
  88. model the `Readable Property Map`_ concept and have the reverse
  89. graph's vertex descriptor as its key type and the graph's vertex
  90. descriptor as its value type.
  91. **Default**: An identity property map (if the graph type is
  92. bidirectional) or a distributed ``iterator_property_map`` (if the
  93. graph type is directed).
  94. Complexity
  95. ----------
  96. The local phase of the algorithm is *O(V + E)*. The parallel phase of
  97. the algorithm requires at most *O(V)* supersteps each containing two
  98. breadth first searches which are *O(V + E)* each.
  99. Algorithm Description
  100. ---------------------
  101. Prior to executing the sequential phase of the algorithm, each process
  102. identifies any completely local strong components which it labels and
  103. removes from the vertex set considered in the parallel phase of the
  104. algorithm.
  105. The parallel phase of the distributed strong components algorithm
  106. consists of series of supersteps. Each superstep starts with one
  107. or more vertex sets which are guaranteed to completely contain
  108. any remaining strong components. A `distributed breadth first search`_
  109. is performed starting from the first vertex in each vertex set.
  110. All of these breadth first searches are performed in parallel by having
  111. each processor call ``breadth_first_search()`` with a different starting
  112. vertex, and if necessary inserting additional vertices into the
  113. ``distributed queue`` used for breadth first search before invoking
  114. the algorithm. A second `distributed breadth first search`_ is
  115. performed on the reverse graph in the same fashion. For each initial
  116. vertex set, the successor set (the vertices reached in the forward
  117. breadth first search), and the predecessor set (the vertices reached
  118. in the backward breadth first search) is computed. The intersection
  119. of the predecessor and successor sets form a strongly connected
  120. component which is labeled as such. The remaining vertices in the
  121. initial vertex set are partitioned into three subsets each guaranteed
  122. to completely contain any remaining strong components. These three sets
  123. are the vertices in the predecessor set not contained in the identified
  124. strongly connected component, the vertices in the successor set not
  125. in the strongly connected component, and the remaing vertices in the
  126. initial vertex set not in the predecessor or successor sets. Once
  127. new vertex sets are identified, the algorithm begins a new superstep.
  128. The algorithm halts when no vertices remain.
  129. To boost performance in sparse graphs when identifying small components,
  130. when less than a given portion of the initial number of vertices
  131. remain in active vertex sets, a filtered graph adapter is used
  132. to limit the graph seen by the breadth first search algorithm to the
  133. active vertices.
  134. Bibliography
  135. ------------
  136. .. [FHP00] Lisa Fleischer, Bruce Hendrickson, and Ali Pinar. On
  137. Identifying Strongly Connected Components in Parallel. In Parallel and
  138. Distributed Processing (IPDPS), volume 1800 of Lecture Notes in
  139. Computer Science, pages 505--511, 2000. Springer.
  140. -----------------------------------------------------------------------------
  141. Copyright (C) 2004, 2005 The Trustees of Indiana University.
  142. Authors: Nick Edmonds, Douglas Gregor, and Andrew Lumsdaine
  143. .. |Logo| image:: pbgl-logo.png
  144. :align: middle
  145. :alt: Parallel BGL
  146. :target: http://www.osl.iu.edu/research/pbgl
  147. .. _Sequential strong components: http://www.boost.org/libs/graph/doc/strong_components.html
  148. .. _Distributed breadth first search: breadth_first_search.html
  149. .. _Distributed Graph: DistributedGraph.html
  150. .. _Distributed Property Map: distributed_property_map.html
  151. .. _Incidence Graph: http://www.boost.org/libs/graph/doc/IncidenceGraph.html
  152. .. _Bidirectional Graph: http://www.boost.org/libs/graph/doc/BidirectionalGraph.html
  153. .. _distributed adjacency list: distributed_adjacency_list.html
  154. .. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
  155. ..