sloan_ordering.htm 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <!-- saved from url=(0063)http://www.boost.org/libs/graph/doc/cuthill_mckee_ordering.html -->
  3. <HTML><HEAD><TITLE>Boost Graph Library: Sloan Ordering</TITLE>
  4. <META http-equiv=Content-Type content="text/html; charset=windows-1252"><!--
  5. -- Copyright (c) Jeremy Siek 2000
  6. --
  7. -- Distributed under the Boost Software License, Version 1.0.
  8. -- (See accompanying file LICENSE_1_0.txt or copy at
  9. -- http://www.boost.org/LICENSE_1_0.txt)
  10. -->
  11. <META content="MSHTML 6.00.2715.400" name=GENERATOR></HEAD>
  12. <BODY text=#000000 vLink=#551a8b aLink=#ff0000 link=#0000ee bgColor=#ffffff>
  13. <IMG SRC="../../../boost.png"
  14. ALT="C++ Boost" width="277" height="86"> <BR>
  15. <H1><A name=sec:bfs></a><tt>sloan_ordering</tt></H1>
  16. <P>
  17. <DIV align=left>
  18. <TABLE cellPadding=3 border=1>
  19. <TBODY>
  20. <TR>
  21. <TH align=left><B>Graphs:</B></TH>
  22. <TD align=left>undirected</TD></TR>
  23. <TR>
  24. <TH align=left><B>Properties:</B></TH>
  25. <TD align=left>color, degree, current_degree, priority</TD>
  26. </TR>
  27. <TR>
  28. <TH align=left><B>Complexity:</B></TH>
  29. <TD align=left>time: <I>O(log(m)|E|)</I> where <I>m = max { degree(v) | v
  30. in V }</I> </TD></TR></TBODY></TABLE></DIV>
  31. <PRE> (1)
  32. template &lt;class Graph, class OutputIterator,
  33. class ColorMap, class DegreeMap,
  34. class PriorityMap, class Weight&gt;
  35. OutputIterator
  36. sloan_ordering(Graph&amp; g,
  37. typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
  38. typename graph_traits&lt;Graph&gt;::vertex_descriptor e,
  39. OutputIterator permutation,
  40. ColorMap color,
  41. DegreeMap degree,
  42. PriorityMap priority,
  43. Weight W1,
  44. Weight W2 )
  45. (2)
  46. template &lt;class Graph, class OutputIterator,
  47. class ColorMap, class DegreeMap,
  48. class PriorityMap, class Weight&gt;
  49. OutputIterator
  50. sloan_ordering(Graph&amp; g,
  51. OutputIterator permutation,
  52. ColorMap color,
  53. DegreeMap degree,
  54. PriorityMap priority,
  55. Weight W1,
  56. Weight W2 )
  57. (3)
  58. template &lt;class Graph, class OutputIterator,
  59. class ColorMap, class DegreeMap,
  60. class PriorityMap&gt;
  61. OutputIterator
  62. sloan_ordering(Graph&amp; g,
  63. typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
  64. typename graph_traits&lt;Graph&gt;::vertex_descriptor e,
  65. OutputIterator permutation,
  66. ColorMap color,
  67. DegreeMap degree,
  68. PriorityMap priority )
  69. (4)
  70. template &lt;class Graph, class OutputIterator,
  71. class ColorMap, class DegreeMap,
  72. class PriorityMap&gt;
  73. OutputIterator
  74. sloan_ordering(Graph&amp; g,
  75. OutputIterator permutation,
  76. ColorMap color,
  77. DegreeMap degree,
  78. PriorityMap priority )</PRE>
  79. <p>The goal of the Sloan ordering algorithm[1, 2] is to reduce the profile and
  80. the wavefront of a graph by reordering the indices assigned to each vertex.
  81. The Sloan algorithm needs a start and an end vertex. These vertices can be asigned
  82. manually. But there is also an algorithm sloan_starting_nodes that provides
  83. usually quite good start and end vertices. Each vertex is asigned with a priority.
  84. This priority is a weighted sum of the distance of the vector to the end vertex
  85. (a global criterion) and is called the current degree of vertex. This current
  86. degree basically reflects the status of the renumbering in the neighborhood
  87. of a vertex (a local criterion). Therefore the Sloan algorithm (in contrast
  88. to-McKee) takes into account local as well as global criteria for the renumbering
  89. sequence. One can play around with the relative weights, but the default values
  90. proposed by Sloan (weight1/weight2=1/2) turn out to be pretty good in most cases.
  91. </p>
  92. <P>Version 1 of the algorithm lets the user choose the start- and end-vertex whereas
  93. version 2 finds a good starting vertex using the already mentioned sloan_starting_node
  94. algorithm. The choice of these vertices can have a significant effect on the
  95. quality of the ordering. Version 3 and 4 are identical to version 1 and 2 respectively,
  96. except that for the weights the standard weights W1=1 and W2=2 are used.
  97. <P>The output of the algorithm are the vertices in the new ordering. Depending
  98. on what kind of output iterator you use, you can get either the Sloan ordering
  99. or the reverse Sloan ordering. For example, if you store the output into a vector
  100. using the vector's reverse iterator, then you get the reverse Sloan ordering.
  101. <PRE> std::vector&lt;vertex_descriptor&gt; inv_perm(num_vertices(G));
  102. sloan_ordering(G, inv_perm.rbegin());
  103. </PRE>
  104. <P>Either way, storing the output into a vector gives you the permutation from
  105. the new ordering to the old ordering. <PRE> inv_perm[new_index[u]] == u
  106. </PRE>
  107. <P>Sometimes, it is the opposite permutation that you want, the permutation from
  108. the old index to the new index. This can easily be computed in the following
  109. way.
  110. <PRE> for (size_type i = 0; i != inv_perm.size(); ++i)
  111. perm[old_index[inv_perm[i]]] = i;
  112. </PRE>
  113. <p>Usually you need the reversed ordering with the Cuthill-McKee algorithm and
  114. the direct ordering with the Sloan algorithm.</p>
  115. <H3>Parameters</H3>
  116. For version 1:
  117. <UL>
  118. <LI><TT>Graph&amp; g</TT> &nbsp;(IN) <BR>
  119. An undirected graph. The graph's type must be a model of <A
  120. href="./IncidenceGraph.html">IncidenceGraph</a>.
  121. <LI><TT>vertex_descriptor s</TT> &nbsp;(IN) <BR>
  122. The starting vertex.
  123. <LI><tt>vertex_descriptor e</tt>&nbsp;(IN)<br>
  124. The ending vertex<br>
  125. <LI><TT>OutputIterator permutation</TT> &nbsp;(OUT) <BR>
  126. The new vertex ordering. The vertices are written to the <a
  127. href="http://www.boost.org/sgi/stl/OutputIterator.html">output iterator</a> in
  128. their new order.
  129. <LI><TT>ColorMap color_map</TT> &nbsp;(WORK) <BR>
  130. Used internally to keep track of the progress of the algorithm (to avoid visiting
  131. the same vertex twice).
  132. <LI><tt>PriorityMap priority_map</tt> &nbsp;(IN)<br>
  133. Used internally to store the priority for renumbering of each vertex. </LI>
  134. <LI><TT>DegreeMap degree_map</TT> &nbsp;(IN) <BR>
  135. This must map vertices to their degree. </LI>
  136. <LI><tt>Weight W1 &amp; W2</tt> &nbsp;(IN) <br>
  137. Heuristical weights for the Sloan algorithm. </LI>
  138. </UL>
  139. <p>For version 2: </p>
  140. <ul>
  141. <li><tt>Graph&amp; g</tt> &nbsp;(IN) <br>
  142. An undirected graph. The graph's type must be a model of <a
  143. href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
  144. <li><tt>OutputIterator permutation</tt> &nbsp;(OUT) <br>
  145. The new vertex ordering. The vertices are written to the <a
  146. href="http://www.boost.org/sgi/stl/OutputIterator.html">output iterator</a> in
  147. their new order.
  148. <li><tt>ColorMap color_map</tt> &nbsp;(WORK) <br>
  149. Used internally to keep track of the progress of the algorithm (to avoid visiting
  150. the same vertex twice).
  151. <li><tt>PriorityMap priority_map</tt> &nbsp;(IN)<br>
  152. Used internally to store the priority for renumbering of each vertex. </li>
  153. <li><tt>DegreeMap degree_map</tt> &nbsp;(IN) <br>
  154. This must map vertices to their degree. </li>
  155. <li><tt>Weight W1 &amp; W2</tt> &nbsp;(IN) <br>
  156. Heuristical weights for the Sloan algorithm. </li>
  157. </ul>
  158. <p>For version 3: </p>
  159. <ul>
  160. <li><tt>Graph&amp; g</tt> &nbsp;(IN) <br>
  161. An undirected graph. The graph's type must be a model of <a
  162. href="./IncidenceGraph.html">IncidenceGraph</a>.
  163. <li><tt>vertex_descriptor s</tt> &nbsp;(IN) <br>
  164. The starting vertex.
  165. <li><tt>vertex_descriptor e</tt>&nbsp;(IN)<br>
  166. The ending vertex<br>
  167. <li><tt>OutputIterator permutation</tt> &nbsp;(OUT) <br>
  168. The new vertex ordering. The vertices are written to the <a
  169. href="http://www.boost.org/sgi/stl/OutputIterator.html">output iterator</a> in
  170. their new order.
  171. <li><tt>ColorMap color_map</tt> &nbsp;(WORK) <br>
  172. Used internally to keep track of the progress of the algorithm (to avoid visiting
  173. the same vertex twice).
  174. <li><tt>PriorityMap priority_map</tt> &nbsp;(IN)<br>
  175. Used internally to store the priority for renumbering of each vertex. </li>
  176. <li><tt>DegreeMap degree_map</tt> &nbsp;(IN) <br>
  177. This must map vertices to their degree. </li>
  178. </ul>
  179. <p>For version 4: </p>
  180. <ul>
  181. <li><tt>Graph&amp; g</tt> &nbsp;(IN) <br>
  182. An undirected graph. The graph's type must be a model of <a
  183. href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
  184. <li><tt>OutputIterator permutation</tt> &nbsp;(OUT) <br>
  185. The new vertex ordering. The vertices are written to the <a
  186. href="http://www.boost.org/sgi/stl/OutputIterator.html">output iterator</a> in
  187. their new order.
  188. <li><tt>ColorMap color_map</tt> &nbsp;(WORK) <br>
  189. Used internally to keep track of the progress of the algorithm (to avoid visiting
  190. the same vertex twice).
  191. <li><tt>PriorityMap priority_map</tt> &nbsp;(IN)<br>
  192. Used internally to store the priority for renumbering of each vertex. </li>
  193. <li><tt>DegreeMap degree_map</tt> &nbsp;(IN) <br>
  194. This must map vertices to their degree. </li>
  195. </ul>
  196. <p>&nbsp;</p>
  197. <H3>Example</H3>
  198. See <A
  199. href="../example/sloan_ordering.cpp"><TT>example/sloan_ordering.cpp</TT></A>.
  200. <H3>See Also</H3>
  201. <p><a href="./sloan_start_end_vertices.htm">sloan_start_end_vertices</a>,
  202. <A
  203. href="./bandwidth.html">bandwidth</a>, <a href="./profile.htm">profile</a>, <a href="./wavefront.htm">wavefront</a>
  204. and <TT>degree_property_map</TT> in <TT>boost/graph/properties.hpp</TT>. </p>
  205. <p>[1] S. W. Sloan, <i>An algorithm for profile and wavefront reduction of sparse
  206. matrices</i>, Int. j. numer. methods eng., <b>23</b>, 239 - 251 (1986)</p>
  207. <p>[2] S. W. Sloan, <i>A fortran program for profile and wavefront reduction</i>,
  208. Int. j. numer. methods eng., <b>28</b>, 2651 - 2679 (1989)<BR>
  209. </p>
  210. <HR>
  211. <TABLE width="718">
  212. <TBODY>
  213. <TR vAlign=top>
  214. <TD noWrap>Copyright © 2001-2002</TD>
  215. <TD>Marc Wintermantel, ETH Zurich (<A
  216. href="mailto:wintermantel@imes.mavt.ethz.ch">wintermantel@imes.mavt.ethz.ch</a>)
  217. </TD>
  218. </TR></TBODY></TABLE></BODY></HTML>