connected_components.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
  7. <title>Parallel BGL Connected Components</title>
  8. <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-connected-components">
  12. <h1 class="title"><a class="reference external" href="http://www.osl.iu.edu/research/pbgl"><img align="middle" alt="Parallel BGL" class="align-middle" src="pbgl-logo.png" /></a> Connected Components</h1>
  13. <!-- Copyright (C) 2004-2008 The Trustees of Indiana University.
  14. Use, modification and distribution is subject to the Boost Software
  15. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  16. http://www.boost.org/LICENSE_1_0.txt) -->
  17. <pre class="literal-block">
  18. namespace graph {
  19. // Default constructed ParentMap
  20. template&lt;typename Graph, typename ComponentMap, typename ParentMap&gt;
  21. typename property_traits&lt;ComponentMap&gt;::value_type
  22. connected_components( const Graph&amp; g, ComponentMap c);
  23. // User supplied ParentMap
  24. template&lt;typename Graph, typename ComponentMap, typename ParentMap&gt;
  25. typename property_traits&lt;ComponentMap&gt;::value_type
  26. connected_components( const Graph&amp; g, ComponentMap c, ParentMap p);
  27. }
  28. </pre>
  29. <p>The <tt class="docutils literal"><span class="pre">connected_components()</span></tt> function computes the connected
  30. components of an undirected graph. The distributed connected
  31. components algorithm uses the sequential version of the connected
  32. components algorithm to compute the connected components of the local
  33. subgraph, then executes the parallel phase of the algorithm. The
  34. parallel portion of the connected components algorithm is loosely
  35. based on the work of Goddard, Kumar, and Prins. The interface is a
  36. superset of the interface to the BGL <a class="reference external" href="http://www.boost.org/libs/graph/doc/connected_components.html">sequential connected
  37. components</a> algorithm.</p>
  38. <p>Prior to executing the sequential phase of the algorithm, each process
  39. identifies the roots of its local components. An adjacency list of
  40. all vertices adjacent to members of the component is then constructed
  41. at the root vertex of each component.</p>
  42. <p>The parallel phase of the distributed connected components algorithm
  43. consists of a series of supersteps. In each superstep, each root
  44. attempts to hook to a member of it's adjacency list by assigning it's
  45. parent pointer to that vertex. Hooking is restricted to vertices
  46. which are logically less than the current vertex to prevent looping.
  47. Vertices which hook successfully are removed from the list of roots
  48. and placed on another list of completed vertices. All completed
  49. vertices now execute a pointer jumping step until every completed
  50. vertex has as its parent the root of a component. This pointer
  51. jumping step may be further optimized by the addition of Cycle
  52. Reduction (CR) rules developed by Johnson and Metaxas, however current
  53. performance evaluations indicate that this would have a negligible
  54. impact on the overall performance of the algorithm. These CR rules
  55. reduce the number of pointer jumping steps from <em>O(n)</em> to <em>O(log n)</em>.
  56. Following this pointer jumping step, roots which have hooked in this
  57. phase transmit their adjacency list to their new parent. The
  58. remaining roots receive these edges and execute a pruning step on
  59. their adjacency lists to remove vertices that are now members of their
  60. component. The parallel phase of the algorithm is complete when no
  61. root successfully hooks. Once the parallel phase is complete a final
  62. pointer jumping step is performed on all vertices to assign the parent
  63. pointers of the leaves of the initial local subgraph components to
  64. their final parent which has now been determined.</p>
  65. <p>The single largest performance bottleneck in the distributed connected
  66. components algorithm is the effect of poor vertex distribution on the
  67. algorithm. For sparse graphs with a single large component, many
  68. roots may hook to the same component, resulting in severe load
  69. imbalance at the process owning this component. Several methods of
  70. modifying the hooking strategy to avoid this behavior have been
  71. implemented but none has been successful as of yet.</p>
  72. <div class="contents topic" id="contents">
  73. <p class="topic-title first">Contents</p>
  74. <ul class="simple">
  75. <li><a class="reference internal" href="#where-defined" id="id1">Where Defined</a></li>
  76. <li><a class="reference internal" href="#parameters" id="id2">Parameters</a></li>
  77. <li><a class="reference internal" href="#complexity" id="id3">Complexity</a></li>
  78. <li><a class="reference internal" href="#performance" id="id4">Performance</a></li>
  79. </ul>
  80. </div>
  81. <div class="section" id="where-defined">
  82. <h1><a class="toc-backref" href="#id1">Where Defined</a></h1>
  83. <p>&lt;<tt class="docutils literal"><span class="pre">boost/graph/connected_components.hpp</span></tt>&gt;</p>
  84. </div>
  85. <div class="section" id="parameters">
  86. <h1><a class="toc-backref" href="#id2">Parameters</a></h1>
  87. <dl class="docutils">
  88. <dt>IN: <tt class="docutils literal"><span class="pre">Graph&amp;</span> <span class="pre">g</span></tt></dt>
  89. <dd>The graph typed must be a model of <a class="reference external" href="DistributedGraph.html">Distributed Graph</a>.</dd>
  90. <dt>OUT: <tt class="docutils literal"><span class="pre">ComponentMap</span> <span class="pre">c</span></tt></dt>
  91. <dd>The algorithm computes how many connected components are in the
  92. graph, and assigns each component an integer label. The algorithm
  93. then records to which component each vertex in the graph belongs by
  94. recording the component number in the component property map. The
  95. <tt class="docutils literal"><span class="pre">ComponentMap</span></tt> type must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. The
  96. value type must be the <tt class="docutils literal"><span class="pre">vertices_size_type</span></tt> of the graph. The key
  97. type must be the graph's vertex descriptor type. If you do not wish
  98. to compute component numbers, pass <tt class="docutils literal"><span class="pre">dummy_property_map</span></tt> as the
  99. component map and parent information will be provided in the parent
  100. map.</dd>
  101. <dt>UTIL: <tt class="docutils literal"><span class="pre">ParentMap</span> <span class="pre">p</span></tt></dt>
  102. <dd>A parent map may be supplied to the algorithm, if not supplied the
  103. parent map will be constructed automatically. The <tt class="docutils literal"><span class="pre">ParentMap</span></tt> type
  104. must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. The value type and key type
  105. must be the graph's vertex descriptor type.</dd>
  106. <dt>OUT: <tt class="docutils literal"><span class="pre">property_traits&lt;ComponentMap&gt;::value_type</span></tt></dt>
  107. <dd>The number of components found will be returned as the value type of
  108. the component map.</dd>
  109. </dl>
  110. </div>
  111. <div class="section" id="complexity">
  112. <h1><a class="toc-backref" href="#id3">Complexity</a></h1>
  113. <p>The local phase of the algorithm is <em>O(V + E)</em>. The parallel phase of
  114. the algorithm requires at most <em>O(d)</em> supersteps where <em>d</em> is the
  115. number of initial roots. <em>d</em> is at most <em>O(V)</em> but becomes
  116. significantly smaller as <em>E</em> increases. The pointer jumping phase
  117. within each superstep requires at most <em>O(c)</em> steps on each of the
  118. completed roots where <em>c</em> is the length of the longest cycle.
  119. Application of CR rules can reduce this to <em>O(log c)</em>.</p>
  120. </div>
  121. <div class="section" id="performance">
  122. <h1><a class="toc-backref" href="#id4">Performance</a></h1>
  123. <p>The following charts illustrate the performance of the Parallel BGL
  124. connected components algorithm. It performs well on very sparse and
  125. very dense graphs. However, for cases where the graph has a medium
  126. density with a giant connected component, the algorithm will perform
  127. poorly. This is a known problem with the algorithm and as far as we
  128. know all implemented algorithms have this degenerate behavior.</p>
  129. <img align="left" alt="chart_php_generator_ER_SF_SW_dataset_TimeSparse_columns_9.png" class="align-left" src="chart_php_generator_ER_SF_SW_dataset_TimeSparse_columns_9.png" />
  130. <img alt="chart_php_generator_ER_SF_SW_dataset_TimeSparse_columns_9_speedup_1.png" src="chart_php_generator_ER_SF_SW_dataset_TimeSparse_columns_9_speedup_1.png" />
  131. <img align="left" alt="chart_php_generator_ER_SF_SW_dataset_TimeDense_columns_9.png" class="align-left" src="chart_php_generator_ER_SF_SW_dataset_TimeDense_columns_9.png" />
  132. <img alt="chart_php_generator_ER_SF_SW_dataset_TimeDense_columns_9_speedup_1.png" src="chart_php_generator_ER_SF_SW_dataset_TimeDense_columns_9_speedup_1.png" />
  133. <hr class="docutils" />
  134. <p>Copyright (C) 2004 The Trustees of Indiana University.</p>
  135. <p>Authors: Nick Edmonds, Douglas Gregor, and Andrew Lumsdaine</p>
  136. </div>
  137. </div>
  138. <div class="footer">
  139. <hr class="footer" />
  140. Generated on: 2009-05-31 00:22 UTC.
  141. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
  142. </div>
  143. </body>
  144. </html>