boman_et_al_graph_coloring.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 Boman et al graph coloring</title>
  8. <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-boman-et-al-graph-coloring">
  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> Boman et al graph coloring</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. template&lt;typename DistributedGraph, typename ColorMap&gt;
  20. typename property_traits&lt;ColorMap&gt;::value_type
  21. boman_et_al_graph_coloring
  22. (const DistributedGraph&amp; g,
  23. ColorMap color,
  24. typename graph_traits&lt;DistributedGraph&gt;::vertices_size_type s = 100);
  25. template&lt;typename DistributedGraph, typename ColorMap, typename ChooseColor&gt;
  26. typename property_traits&lt;ColorMap&gt;::value_type
  27. boman_et_al_graph_coloring
  28. (const DistributedGraph&amp; g,
  29. ColorMap color,
  30. typename graph_traits&lt;DistributedGraph&gt;::vertices_size_type s,
  31. ChooseColor choose_color);
  32. template&lt;typename DistributedGraph, typename ColorMap, typename ChooseColor,
  33. typename VertexOrdering&gt;
  34. typename property_traits&lt;ColorMap&gt;::value_type
  35. boman_et_al_graph_coloring
  36. (const DistributedGraph&amp; g, ColorMap color,
  37. typename graph_traits&lt;DistributedGraph&gt;::vertices_size_type s,
  38. ChooseColor choose_color, VertexOrdering ordering);
  39. template&lt;typename DistributedGraph, typename ColorMap, typename ChooseColor,
  40. typename VertexOrdering, typename VertexIndexMap&gt;
  41. typename property_traits&lt;ColorMap&gt;::value_type
  42. boman_et_al_graph_coloring
  43. (const DistributedGraph&amp; g,
  44. ColorMap color,
  45. typename graph_traits&lt;DistributedGraph&gt;::vertices_size_type s,
  46. ChooseColor choose_color,
  47. VertexOrdering ordering, VertexIndexMap vertex_index);
  48. }
  49. </pre>
  50. <p>The <tt class="docutils literal"><span class="pre">boman_et_al_graph_coloring</span></tt> function colors the vertices of an
  51. undirected, distributed graph such that no two adjacent vertices have
  52. the same color. All of the vertices of a given color form an
  53. independent set in the graph. Graph coloring has been used to solve
  54. various problems, including register allocation in compilers,
  55. optimization problems, and scheduling problems.</p>
  56. <img align="right" alt="Vertex coloring example" class="align-right" src="../vertex_coloring.png" style="width: 462px; height: 269px;" />
  57. <p>The problem of coloring a graph with the fewest possible number of
  58. colors is NP-complete, so many algorithms (including the one
  59. implemented here) are heuristic algorithms that try to minimize the
  60. number of colors but are not guaranteed to provide an optimal
  61. solution. This algorithm <a class="citation-reference" href="#bbc05" id="id1">[BBC05]</a> is similar to the
  62. <tt class="docutils literal"><span class="pre">sequential_vertex_coloring</span></tt> algorithm, that iterates through the
  63. vertices once and selects the lowest-numbered color that the current
  64. vertex can have. The coloring and the number of colors is therefore
  65. related to the ordering of the vertices in the sequential case.</p>
  66. <p>The distributed <tt class="docutils literal"><span class="pre">boman_et_al_graph_coloring</span></tt> algorithm will produce
  67. different colorings depending on the ordering and distribution of the
  68. vertices and the number of parallel processes cooperating to perform
  69. the coloring.</p>
  70. <p>The algorithm returns the number of colors <tt class="docutils literal"><span class="pre">num_colors</span></tt> used to
  71. color the graph.</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="id2">Where Defined</a></li>
  76. <li><a class="reference internal" href="#parameters" id="id3">Parameters</a></li>
  77. <li><a class="reference internal" href="#complexity" id="id4">Complexity</a></li>
  78. <li><a class="reference internal" href="#performance" id="id5">Performance</a></li>
  79. </ul>
  80. </div>
  81. <div class="section" id="where-defined">
  82. <h1><a class="toc-backref" href="#id2">Where Defined</a></h1>
  83. <p>&lt;<tt class="docutils literal"><span class="pre">boost/graph/distributed/boman_et_al_graph_coloring.hpp</span></tt>&gt;</p>
  84. </div>
  85. <div class="section" id="parameters">
  86. <h1><a class="toc-backref" href="#id3">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 type must be a model of <a class="reference external" href="DistributedVertexListGraph.html">Distributed Vertex List Graph</a> and
  90. <a class="reference external" href="DistributedEdgeListGraph.html">Distributed Edge List Graph</a>.</dd>
  91. <dt>UTIL/OUT: <tt class="docutils literal"><span class="pre">ColorMap</span> <span class="pre">color</span></tt></dt>
  92. <dd>Stores the color of each vertex, which will be a value in the range
  93. [0, <tt class="docutils literal"><span class="pre">num_colors</span></tt>). The type <tt class="docutils literal"><span class="pre">ColorMap</span></tt> must model the
  94. <a class="reference external" href="http://www.boost.org/libs/property_map/ReadWritePropertyMap.html">Read/Write Property Map</a> concept and must be a <a class="reference external" href="distributed_property_map.html">distributed
  95. property map</a>.</dd>
  96. <dt>IN: <tt class="docutils literal"><span class="pre">vertices_size_type</span> <span class="pre">s</span></tt></dt>
  97. <dd><p class="first">The number of vertices to color within each superstep. After
  98. <tt class="docutils literal"><span class="pre">s</span></tt> vertices have been colored, the colors of boundary vertices
  99. will be sent to their out-of-process neighbors. Smaller values
  100. communicate more often but may reduce the risk of conflicts,
  101. whereas larger values do more work in between communication steps
  102. but may create many conflicts.</p>
  103. <p class="last"><strong>Default</strong>: 100</p>
  104. </dd>
  105. <dt>IN: <tt class="docutils literal"><span class="pre">ChooseColor</span> <span class="pre">choose_color</span></tt></dt>
  106. <dd><p class="first">A function object that chooses the color for a vertex given the
  107. colors of its neighbors. The function object will be passed a vector
  108. of values (<tt class="docutils literal"><span class="pre">marked</span></tt>) and a <tt class="docutils literal"><span class="pre">marked_true</span></tt> value, and should
  109. return a <tt class="docutils literal"><span class="pre">color</span></tt> value such that <tt class="docutils literal"><span class="pre">color</span> <span class="pre">&gt;=</span> <span class="pre">marked.size()</span></tt> or
  110. <tt class="docutils literal"><span class="pre">marked[color]</span> <span class="pre">!=</span> <span class="pre">marked_true</span></tt>.</p>
  111. <p class="last"><strong>Default</strong>:
  112. <tt class="docutils literal"><span class="pre">boost::graph::distributed::first_fit_color&lt;color_type&gt;()</span></tt>, where
  113. <tt class="docutils literal"><span class="pre">color_type</span></tt> is the value type of the <tt class="docutils literal"><span class="pre">ColorMap</span></tt> property map.</p>
  114. </dd>
  115. <dt>IN: <tt class="docutils literal"><span class="pre">VertexOrdering</span> <span class="pre">ordering</span></tt></dt>
  116. <dd><p class="first">A binary predicate function object that provides total ordering on
  117. the vertices in the graph. Whenever a conflict arises, only one of
  118. the processes involved will recolor the vertex in the next round,
  119. and this ordering determines which vertex should be considered
  120. conflicting (its owning process will then handle the
  121. conflict). Ideally, this predicate should order vertices so that
  122. conflicting vertices will be spread uniformly across
  123. processes. However, this predicate <em>must</em> resolve the same way on
  124. both processors.</p>
  125. <p class="last"><strong>Default</strong>: <em>unspecified</em></p>
  126. </dd>
  127. <dt>IN: <tt class="docutils literal"><span class="pre">VertexIndexMap</span> <span class="pre">index</span></tt></dt>
  128. <dd><p class="first">A mapping from vertex descriptors to indices in the range <em>[0,
  129. num_vertices(g))</em>. This must be a <a class="reference external" href="http://www.boost.org/libs/property_map/ReadablePropertyMap.html">Readable Property Map</a> whose
  130. key type is a vertex descriptor and whose value type is an integral
  131. type, typically the <tt class="docutils literal"><span class="pre">vertices_size_type</span></tt> of the graph.</p>
  132. <p class="last"><strong>Default:</strong> <tt class="docutils literal"><span class="pre">get(vertex_index,</span> <span class="pre">g)</span></tt></p>
  133. </dd>
  134. </dl>
  135. </div>
  136. <div class="section" id="complexity">
  137. <h1><a class="toc-backref" href="#id4">Complexity</a></h1>
  138. <p>The complexity of this algorithm is hard to characterize,
  139. because it depends greatly on the number of <em>conflicts</em> that occur
  140. during the algorithm. A conflict occurs when a <em>boundary vertex</em>
  141. (i.e., a vertex that is adjacent to a vertex stored on a different
  142. processor) is given the same color is a boundary vertex adjacency to
  143. it (but on another processor). Conflicting vertices must be assigned
  144. new colors, requiring additional work and communication. The work
  145. involved in reassigning a color for a conflicting vertex is <em>O(d)</em>,
  146. where <em>d</em> is the degree of the vertex and <em>O(1)</em> messages of <em>O(1)</em>
  147. size are needed to resolve the conflict. Note that the number of
  148. conflicts grows with (1) the number of processes and (2) the number
  149. of inter-process edges.</p>
  150. </div>
  151. <div class="section" id="performance">
  152. <h1><a class="toc-backref" href="#id5">Performance</a></h1>
  153. <p>The performance of this implementation of Bomen et al's graph coloring
  154. algorithm is illustrated by the following charts. Scaling and
  155. performance is reasonable for all of the graphs we have tried.</p>
  156. <img align="left" alt="chart_php_generator_ER_SF_SW_dataset_TimeSparse_cluster_Odin_columns_11.png" class="align-left" src="chart_php_generator_ER_SF_SW_dataset_TimeSparse_cluster_Odin_columns_11.png" />
  157. <img alt="chart_php_generator_ER_SF_SW_dataset_TimeSparse_cluster_Odin_columns_11_speedup_1.png" src="chart_php_generator_ER_SF_SW_dataset_TimeSparse_cluster_Odin_columns_11_speedup_1.png" />
  158. <img align="left" alt="chart_php_generator_ER_SF_SW_dataset_TimeDense_cluster_Odin_columns_11.png" class="align-left" src="chart_php_generator_ER_SF_SW_dataset_TimeDense_cluster_Odin_columns_11.png" />
  159. <img alt="chart_php_generator_ER_SF_SW_dataset_TimeDense_cluster_Odin_columns_11_speedup_1.png" src="chart_php_generator_ER_SF_SW_dataset_TimeDense_cluster_Odin_columns_11_speedup_1.png" />
  160. <hr class="docutils" />
  161. <p>Copyright (C) 2005 The Trustees of Indiana University.</p>
  162. <p>Authors: Douglas Gregor and Andrew Lumsdaine</p>
  163. <table class="docutils citation" frame="void" id="bbc05" rules="none">
  164. <colgroup><col class="label" /><col /></colgroup>
  165. <tbody valign="top">
  166. <tr><td class="label"><a class="fn-backref" href="#id1">[BBC05]</a></td><td>Erik G. Boman, Doruk Bozdag, Umit Catalyurek, Assefaw
  167. H. Gebremedhin, and Fredrik Manne. A Scalable Parallel Graph Coloring
  168. Algorithm for Distributed Memory Computers. [preprint]</td></tr>
  169. </tbody>
  170. </table>
  171. </div>
  172. </div>
  173. <div class="footer">
  174. <hr class="footer" />
  175. Generated on: 2009-05-31 00:21 UTC.
  176. 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.
  177. </div>
  178. </body>
  179. </html>