Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
C++ Boost

sloan_ordering

Graphs: undirected
Properties: color, degree, current_degree, priority
Complexity: time: O(log(m)|E|) where m = max { degree(v) | v in V }
  (1)
  template <class Graph, class OutputIterator,
                  class ColorMap, class DegreeMap, 
                  class PriorityMap, class Weight>
  OutputIterator
  sloan_ordering(Graph& g,
                 typename graph_traits<Graph>::vertex_descriptor s,
                 typename graph_traits<Graph>::vertex_descriptor e,
                 OutputIterator permutation, 
                 ColorMap color, 
                 DegreeMap degree, 
                 PriorityMap priority, 
                 Weight W1, 
                 Weight W2 )

  (2)
   template <class Graph, class OutputIterator,
                  class ColorMap, class DegreeMap, 
                  class PriorityMap, class Weight>
  OutputIterator
  sloan_ordering(Graph& g,
                 OutputIterator permutation, 
                 ColorMap color, 
                 DegreeMap degree, 
                 PriorityMap priority, 
                 Weight W1, 
                 Weight W2 )


(3)
 template <class Graph, class OutputIterator,
                  class ColorMap, class DegreeMap, 
                  class PriorityMap>
  OutputIterator
  sloan_ordering(Graph& g,
                 typename graph_traits<Graph>::vertex_descriptor s,
                 typename graph_traits<Graph>::vertex_descriptor e,
                 OutputIterator permutation, 
                 ColorMap color, 
                 DegreeMap degree, 
                 PriorityMap priority )


(4)
 template <class Graph, class OutputIterator,
                  class ColorMap, class DegreeMap, 
                  class PriorityMap>
  OutputIterator
  sloan_ordering(Graph& g,
                 OutputIterator permutation, 
                 ColorMap color, 
                 DegreeMap degree, 
                 PriorityMap priority )

The goal of the Sloan ordering algorithm[1, 2] is to reduce the profile and the wavefront of a graph by reordering the indices assigned to each vertex. The Sloan algorithm needs a start and an end vertex. These vertices can be asigned manually. But there is also an algorithm sloan_starting_nodes that provides usually quite good start and end vertices. Each vertex is asigned with a priority. This priority is a weighted sum of the distance of the vector to the end vertex (a global criterion) and is called the current degree of vertex. This current degree basically reflects the status of the renumbering in the neighborhood of a vertex (a local criterion). Therefore the Sloan algorithm (in contrast to-McKee) takes into account local as well as global criteria for the renumbering sequence. One can play around with the relative weights, but the default values proposed by Sloan (weight1/weight2=1/2) turn out to be pretty good in most cases.

Version 1 of the algorithm lets the user choose the start- and end-vertex whereas version 2 finds a good starting vertex using the already mentioned sloan_starting_node algorithm. The choice of these vertices can have a significant effect on the quality of the ordering. Version 3 and 4 are identical to version 1 and 2 respectively, except that for the weights the standard weights W1=1 and W2=2 are used.

The output of the algorithm are the vertices in the new ordering. Depending on what kind of output iterator you use, you can get either the Sloan ordering or the reverse Sloan ordering. For example, if you store the output into a vector using the vector's reverse iterator, then you get the reverse Sloan ordering.

  std::vector<vertex_descriptor> inv_perm(num_vertices(G));
  sloan_ordering(G, inv_perm.rbegin());

Either way, storing the output into a vector gives you the permutation from the new ordering to the old ordering.

  inv_perm[new_index[u]] == u

Sometimes, it is the opposite permutation that you want, the permutation from the old index to the new index. This can easily be computed in the following way.

  for (size_type i = 0; i != inv_perm.size(); ++i)
    perm[old_index[inv_perm[i]]] = i;

Usually you need the reversed ordering with the Cuthill-McKee algorithm and the direct ordering with the Sloan algorithm.

Parameters

For version 1:

For version 2:

For version 3:

For version 4:

 

Example

See example/sloan_ordering.cpp.

See Also

sloan_start_end_vertices, bandwidth, profile, wavefront and degree_property_map in boost/graph/properties.hpp.

[1] S. W. Sloan, An algorithm for profile and wavefront reduction of sparse matrices, Int. j. numer. methods eng., 23, 239 - 251 (1986)

[2] S. W. Sloan, A fortran program for profile and wavefront reduction, Int. j. numer. methods eng., 28, 2651 - 2679 (1989)


Copyright © 2001-2002 Marc Wintermantel, ETH Zurich (wintermantel@imes.mavt.ethz.ch)