2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-30 07:52:10 +00:00

changed namespace

[SVN r9434]
This commit is contained in:
Jeremy Siek
2001-03-04 18:53:02 +00:00
parent 51d4f166cf
commit ad856f3fd4

View File

@@ -113,56 +113,57 @@ namespace boost {
DegreeMap degree;
};
// Compute Pseudo peripheral
//
// To compute an approximated peripheral for a given vertex.
// Used in <tt>reverse_cuthill_mckee_ordering</tt> algorithm.
//
template <class Graph, class Vertex, class ColorMap, class DegreeMap>
Vertex
pseudo_peripheral_pair(Graph& G, const Vertex& u, int& ecc,
ColorMap color, DegreeMap degree)
{
typedef typename property_traits<ColorMap>::value_type ColorValue;
typedef color_traits<ColorValue> Color;
rcm_queue<Vertex, DegreeMap> Q(degree);
typename boost::graph_traits<Graph>::vertex_iterator ui, ui_end;
for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
put(color, *ui, Color::white());
breadth_first_search(G, u, Q, bfs_visitor<>(), color);
ecc = Q.eccentricity();
return Q.spouse();
}
// Find a good starting node
//
// This is to find a good starting node for the
// reverse_cuthill_mckee_ordering algorithm. "good" is in the sense
// of the ordering generated by RCM.
//
template <class Graph, class Vertex, class Color, class Degree>
Vertex find_starting_node(Graph& G, Vertex r, Color color, Degree degree)
{
Vertex x, y;
int eccen_r, eccen_x;
x = pseudo_peripheral_pair(G, r, eccen_r, color, degree);
y = pseudo_peripheral_pair(G, x, eccen_x, color, degree);
while (eccen_x > eccen_r) {
r = x;
eccen_r = eccen_x;
x = y;
y = pseudo_peripheral_pair(G, x, eccen_x, color, degree);
}
return x;
}
} // namespace detail
// Compute Pseudo peripheral
//
// To compute an approximated peripheral for a given vertex.
// Used in <tt>reverse_cuthill_mckee_ordering</tt> algorithm.
//
template <class Graph, class Vertex, class ColorMap, class DegreeMap>
Vertex
pseudo_peripheral_pair(Graph& G, const Vertex& u, int& ecc,
ColorMap color, DegreeMap degree)
{
typedef typename property_traits<ColorMap>::value_type ColorValue;
typedef color_traits<ColorValue> Color;
detail::rcm_queue<Vertex, DegreeMap> Q(degree);
typename boost::graph_traits<Graph>::vertex_iterator ui, ui_end;
for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
put(color, *ui, Color::white());
breadth_first_search(G, u, Q, bfs_visitor<>(), color);
ecc = Q.eccentricity();
return Q.spouse();
}
// Find a good starting node
//
// This is to find a good starting node for the
// reverse_cuthill_mckee_ordering algorithm. "good" is in the sense
// of the ordering generated by RCM.
//
template <class Graph, class Vertex, class Color, class Degree>
Vertex find_starting_node(Graph& G, Vertex r, Color color, Degree degree)
{
Vertex x, y;
int eccen_r, eccen_x;
x = pseudo_peripheral_pair(G, r, eccen_r, color, degree);
y = pseudo_peripheral_pair(G, x, eccen_x, color, degree);
while (eccen_x > eccen_r) {
r = x;
eccen_r = eccen_x;
x = y;
y = pseudo_peripheral_pair(G, x, eccen_x, color, degree);
}
return x;
}
// Reverse Cuthill-McKee algorithm with a given starting Vertex.
//
// This algorithm requires user to provide a starting vertex to
@@ -170,13 +171,12 @@ namespace boost {
template <class Graph, class OutputIterator,
class ColorMap, class DegreeMap>
void
OutputIterator
cuthill_mckee_ordering(Graph& g,
typename graph_traits<Graph>::vertex_descriptor s,
OutputIterator inverse_permutation,
ColorMap color, DegreeMap degree)
{
typedef typename property_traits<DegreeMap>::value_type DS;
typedef typename property_traits<ColorMap>::value_type ColorValue;
typedef color_traits<ColorValue> Color;
@@ -216,11 +216,12 @@ namespace boost {
}
put(color, u, Color::black());
} // while
return inverse_permutation;
}
template < class Graph, class OutputIterator,
class Color, class Degree >
inline void
inline OutputIterator
cuthill_mckee_ordering(Graph& G, OutputIterator inverse_permutation,
Color color, Degree degree)
{
@@ -229,10 +230,10 @@ namespace boost {
VerIter ri = vertices(G).first;
Vertex r = *ri;
Vertex s = detail::find_starting_node(G, r, color, degree);
cuthill_mckee_ordering(G, s, inverse_permutation, color, degree);
//if G has several forests, how to let is cover all. ??
Vertex s = find_starting_node(G, r, color, degree);
return cuthill_mckee_ordering(G, s, inverse_permutation, color, degree);
}
} // namespace boost