diff --git a/include/boost/graph/cuthill_mckee_ordering.hpp b/include/boost/graph/cuthill_mckee_ordering.hpp
index 13b5bf62..3a1abe33 100644
--- a/include/boost/graph/cuthill_mckee_ordering.hpp
+++ b/include/boost/graph/cuthill_mckee_ordering.hpp
@@ -113,56 +113,57 @@ namespace boost {
DegreeMap degree;
};
- // Compute Pseudo peripheral
- //
- // To compute an approximated peripheral for a given vertex.
- // Used in reverse_cuthill_mckee_ordering algorithm.
- //
- template
- Vertex
- pseudo_peripheral_pair(Graph& G, const Vertex& u, int& ecc,
- ColorMap color, DegreeMap degree)
- {
- typedef typename property_traits::value_type ColorValue;
- typedef color_traits Color;
-
- rcm_queue Q(degree);
-
- typename boost::graph_traits::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
- 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 reverse_cuthill_mckee_ordering algorithm.
+ //
+ template
+ Vertex
+ pseudo_peripheral_pair(Graph& G, const Vertex& u, int& ecc,
+ ColorMap color, DegreeMap degree)
+ {
+ typedef typename property_traits::value_type ColorValue;
+ typedef color_traits Color;
+
+ detail::rcm_queue Q(degree);
+
+ typename boost::graph_traits::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
+ 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
- void
+ OutputIterator
cuthill_mckee_ordering(Graph& g,
typename graph_traits::vertex_descriptor s,
OutputIterator inverse_permutation,
ColorMap color, DegreeMap degree)
{
-
typedef typename property_traits::value_type DS;
typedef typename property_traits::value_type ColorValue;
typedef color_traits 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