boman_et_al_graph_coloring.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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| Boman et al graph coloring
  7. =================================
  8. ::
  9. namespace graph {
  10. template<typename DistributedGraph, typename ColorMap>
  11. typename property_traits<ColorMap>::value_type
  12. boman_et_al_graph_coloring
  13. (const DistributedGraph& g,
  14. ColorMap color,
  15. typename graph_traits<DistributedGraph>::vertices_size_type s = 100);
  16. template<typename DistributedGraph, typename ColorMap, typename ChooseColor>
  17. typename property_traits<ColorMap>::value_type
  18. boman_et_al_graph_coloring
  19. (const DistributedGraph& g,
  20. ColorMap color,
  21. typename graph_traits<DistributedGraph>::vertices_size_type s,
  22. ChooseColor choose_color);
  23. template<typename DistributedGraph, typename ColorMap, typename ChooseColor,
  24. typename VertexOrdering>
  25. typename property_traits<ColorMap>::value_type
  26. boman_et_al_graph_coloring
  27. (const DistributedGraph& g, ColorMap color,
  28. typename graph_traits<DistributedGraph>::vertices_size_type s,
  29. ChooseColor choose_color, VertexOrdering ordering);
  30. template<typename DistributedGraph, typename ColorMap, typename ChooseColor,
  31. typename VertexOrdering, typename VertexIndexMap>
  32. typename property_traits<ColorMap>::value_type
  33. boman_et_al_graph_coloring
  34. (const DistributedGraph& g,
  35. ColorMap color,
  36. typename graph_traits<DistributedGraph>::vertices_size_type s,
  37. ChooseColor choose_color,
  38. VertexOrdering ordering, VertexIndexMap vertex_index);
  39. }
  40. The ``boman_et_al_graph_coloring`` function colors the vertices of an
  41. undirected, distributed graph such that no two adjacent vertices have
  42. the same color. All of the vertices of a given color form an
  43. independent set in the graph. Graph coloring has been used to solve
  44. various problems, including register allocation in compilers,
  45. optimization problems, and scheduling problems.
  46. .. image:: ../vertex_coloring.png
  47. :width: 462
  48. :height: 269
  49. :alt: Vertex coloring example
  50. :align: right
  51. The problem of coloring a graph with the fewest possible number of
  52. colors is NP-complete, so many algorithms (including the one
  53. implemented here) are heuristic algorithms that try to minimize the
  54. number of colors but are not guaranteed to provide an optimal
  55. solution. This algorithm [BBC05]_ is similar to the
  56. ``sequential_vertex_coloring`` algorithm, that iterates through the
  57. vertices once and selects the lowest-numbered color that the current
  58. vertex can have. The coloring and the number of colors is therefore
  59. related to the ordering of the vertices in the sequential case.
  60. The distributed ``boman_et_al_graph_coloring`` algorithm will produce
  61. different colorings depending on the ordering and distribution of the
  62. vertices and the number of parallel processes cooperating to perform
  63. the coloring.
  64. The algorithm returns the number of colors ``num_colors`` used to
  65. color the graph.
  66. .. contents::
  67. Where Defined
  68. ~~~~~~~~~~~~~
  69. <``boost/graph/distributed/boman_et_al_graph_coloring.hpp``>
  70. Parameters
  71. ~~~~~~~~~~
  72. IN: ``Graph& g``
  73. The graph type must be a model of `Distributed Vertex List Graph`_ and
  74. `Distributed Edge List Graph`_.
  75. UTIL/OUT: ``ColorMap color``
  76. Stores the color of each vertex, which will be a value in the range
  77. [0, ``num_colors``). The type ``ColorMap`` must model the
  78. `Read/Write Property Map`_ concept and must be a `distributed
  79. property map`_.
  80. IN: ``vertices_size_type s``
  81. The number of vertices to color within each superstep. After
  82. ``s`` vertices have been colored, the colors of boundary vertices
  83. will be sent to their out-of-process neighbors. Smaller values
  84. communicate more often but may reduce the risk of conflicts,
  85. whereas larger values do more work in between communication steps
  86. but may create many conflicts.
  87. **Default**: 100
  88. IN: ``ChooseColor choose_color``
  89. A function object that chooses the color for a vertex given the
  90. colors of its neighbors. The function object will be passed a vector
  91. of values (``marked``) and a ``marked_true`` value, and should
  92. return a ``color`` value such that ``color >= marked.size()`` or
  93. ``marked[color] != marked_true``.
  94. **Default**:
  95. ``boost::graph::distributed::first_fit_color<color_type>()``, where
  96. ``color_type`` is the value type of the ``ColorMap`` property map.
  97. IN: ``VertexOrdering ordering``
  98. A binary predicate function object that provides total ordering on
  99. the vertices in the graph. Whenever a conflict arises, only one of
  100. the processes involved will recolor the vertex in the next round,
  101. and this ordering determines which vertex should be considered
  102. conflicting (its owning process will then handle the
  103. conflict). Ideally, this predicate should order vertices so that
  104. conflicting vertices will be spread uniformly across
  105. processes. However, this predicate *must* resolve the same way on
  106. both processors.
  107. **Default**: *unspecified*
  108. IN: ``VertexIndexMap index``
  109. A mapping from vertex descriptors to indices in the range *[0,
  110. num_vertices(g))*. This must be a `Readable Property Map`_ whose
  111. key type is a vertex descriptor and whose value type is an integral
  112. type, typically the ``vertices_size_type`` of the graph.
  113. **Default:** ``get(vertex_index, g)``
  114. Complexity
  115. ~~~~~~~~~~
  116. The complexity of this algorithm is hard to characterize,
  117. because it depends greatly on the number of *conflicts* that occur
  118. during the algorithm. A conflict occurs when a *boundary vertex*
  119. (i.e., a vertex that is adjacent to a vertex stored on a different
  120. processor) is given the same color is a boundary vertex adjacency to
  121. it (but on another processor). Conflicting vertices must be assigned
  122. new colors, requiring additional work and communication. The work
  123. involved in reassigning a color for a conflicting vertex is *O(d)*,
  124. where *d* is the degree of the vertex and *O(1)* messages of *O(1)*
  125. size are needed to resolve the conflict. Note that the number of
  126. conflicts grows with (1) the number of processes and (2) the number
  127. of inter-process edges.
  128. Performance
  129. ~~~~~~~~~~~
  130. The performance of this implementation of Bomen et al's graph coloring
  131. algorithm is illustrated by the following charts. Scaling and
  132. performance is reasonable for all of the graphs we have tried.
  133. .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&cluster=Odin&columns=11
  134. :align: left
  135. .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeSparse&cluster=Odin&columns=11&speedup=1
  136. .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&cluster=Odin&columns=11
  137. :align: left
  138. .. image:: http://www.osl.iu.edu/research/pbgl/performance/chart.php?generator=ER,SF,SW&dataset=TimeDense&cluster=Odin&columns=11&speedup=1
  139. -----------------------------------------------------------------------------
  140. Copyright (C) 2005 The Trustees of Indiana University.
  141. Authors: Douglas Gregor and Andrew Lumsdaine
  142. .. |Logo| image:: pbgl-logo.png
  143. :align: middle
  144. :alt: Parallel BGL
  145. :target: http://www.osl.iu.edu/research/pbgl
  146. .. _Distributed Vertex List Graph: DistributedVertexListGraph.html
  147. .. _Distributed Edge List Graph: DistributedEdgeListGraph.html
  148. .. _Distributed property map: distributed_property_map.html
  149. .. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
  150. .. _Read/Write Property Map: http://www.boost.org/libs/property_map/ReadWritePropertyMap.html
  151. .. [BBC05] Erik G. Boman, Doruk Bozdag, Umit Catalyurek, Assefaw
  152. H. Gebremedhin, and Fredrik Manne. A Scalable Parallel Graph Coloring
  153. Algorithm for Distributed Memory Computers. [preprint]