sloan_start_end_vertices

Finds good start and end vertices for the Sloan profile and wavefront reduction ordering algorithm.

Complexity: Depends on graph structure (multiple internal BFS traversals)
Defined in: <boost/graph/sloan_ordering.hpp>

Example

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/sloan_ordering.hpp>
#include <iostream>

using namespace boost;

struct VertexData {
    default_color_type color;
    int degree;
};

using Graph = adjacency_list<vecS, vecS, undirectedS, VertexData>;
using Vertex = graph_traits<Graph>::vertex_descriptor;

int main() {
    Graph g(6);
    add_edge(0, 1, g); add_edge(1, 2, g);
    add_edge(2, 3, g); add_edge(3, 4, g);
    add_edge(4, 5, g); add_edge(0, 5, g);

    // sloan_start_end_vertices reads the degree field, so populate it first.
    auto deg = get(&VertexData::degree, g);
    for (auto v : make_iterator_range(vertices(g))) {
        put(deg, v, static_cast<int>(out_degree(v, g)));
    }

    Vertex s = *vertices(g).first;
    Vertex e = sloan_start_end_vertices(g, s,
        get(&VertexData::color, g), deg);

    std::cout << "Start vertex: " << s << "\n";
    std::cout << "End vertex:   " << e << "\n";
}
Start vertex: 0
End vertex:   3

(1) Single starting vertex

template <class Graph, class ColorMap, class DegreeMap>
typename graph_traits<Graph>::vertex_descriptor
sloan_start_end_vertices(
    Graph& G,
    typename graph_traits<Graph>::vertex_descriptor& s,
    ColorMap color,
    DegreeMap degree);
Direction Parameter Description

IN

Graph& G

An undirected graph. The graph’s type must be a model of Incidence Graph.

IN

vertex_descriptor s

The starting vertex.

WORK

ColorMap color

Used internally to keep track of the progress of the algorithm (to avoid visiting the same vertex twice).

IN

DegreeMap degree

This must map vertices to their degree.

Description

The goal of the sloan_start_end_vertices algorithm [77, 78] is to find good start- and end-vertices for the profile and wavefront reduction algorithm sloan_ordering. The algorithm is similar to pseudo_peripheral_pair and also based on breadth_first_search. With this breadth-first search a so-called rooted level structure (RLS) is formed, where the vertices with the same distance to the starting vertex are grouped together. The maximum number of vertices in one group is called the width of the RLS. sloan_start_end_vertices tries to find a pseudoperipheral pair with a minimum RLS-width.

References

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

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