@@ -6,7 +6,7 @@ Copyright (c) 2022 pgRouting developers
66Mail: project@pgrouting.org
77
88Developer:
9- Copyright (c) 2025 Shobhit Chaurasia
9+ Copyright (c) 2025 Bipasha Gayary
1010Mail: bipashagayary at gmail.com
1111
1212------
@@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3535#include < vector>
3636#include < map>
3737#include < cstdint>
38+ #include < iterator>
3839
3940#include < boost/property_map/property_map.hpp>
4041#include < boost/graph/graph_traits.hpp>
@@ -47,8 +48,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4748#include " cpp_common/interruption.hpp"
4849#include " cpp_common/messages.hpp"
4950
50- #include " c_types/ii_t_rt.h"
51-
5251namespace pgrouting {
5352namespace functions {
5453
@@ -57,34 +56,31 @@ class sloanOrdering : public Pgr_messages {
5756 public:
5857 typedef typename G::V V;
5958 typedef typename G::E E;
60- typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph;
6159 typedef boost::graph_traits<Graph>::vertices_size_type size_type;
6260 typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
6361
64- std::vector<II_t_rt>
62+ template <class G >
63+ std::vector<int64_t >
6564 sloanOrdering (G &graph) {
66- std::vector<II_t_rt >results;
65+ std::vector<int64_t >results;
6766
68- // map which store the indices with their nodes.
6967 auto i_map = boost::get (boost::vertex_index, graph.graph );
7068
71- // vector which will store the order of the indices.
7269 std::vector<Vertex> inv_perm (boost::num_vertices (graph.graph ));
7370
74- // vector which will store the color of all the vertices in the graph
7571 std::vector <boost::default_color_type> colors (boost::num_vertices (graph.graph ));
7672
77- // An iterator property map which records the color of each vertex
78- auto color_map = boost::make_iterator_property_map (&colors[0 ], i_map, colors[0 ]);
73+ auto color_map = boost::make_iterator_property_map (colors.begin (), i_map);
74+
75+ auto degree_map = boost::make_out_degree_map (graph.graph );
7976
80- // map which store the degree of each vertex.
81- auto out_deg = boost::make_out_degree_map (graph. graph );
77+ std::vector< int > priorities ( boost::num_vertices (graph. graph ));
78+ auto priority_map = boost::make_iterator_property_map (priorities. begin (), i_map );
8279
83- /* abort in case of an interruption occurs (e.g. the query is being cancelled) */
8480 CHECK_FOR_INTERRUPTS ();
8581
8682 try {
87- boost::sloan_ordering (graph.graph , inv_perm.rbegin (), color_map, out_deg );
83+ boost::sloan_ordering (graph.graph , inv_perm.begin (), color_map, degree_map, priority_map );
8884 } catch (boost::exception const & ex) {
8985 (void )ex;
9086 throw ;
@@ -95,29 +91,10 @@ class sloanOrdering : public Pgr_messages {
9591 throw ;
9692 }
9793
98- results = get_results (inv_perm, graph);
94+ // results = get_results(inv_perm, graph);
9995
10096 return results;
10197 }
102-
103- // @}
104-
105- private:
106- std::vector <II_t_rt> get_results (
107- std::vector <size_type> & inv_perm,
108- const G &graph) {
109- std::vector <II_t_rt> results;
110-
111- for (std::vector<Vertex>::const_iterator i = inv_perm.begin ();
112- i != inv_perm.end (); ++i) {
113- log << inv_perm[*i] << " " ;
114- auto seq = graph[*i].id ;
115- results.push_back ({{seq}, {static_cast <int64_t >(graph.graph [*i].id )}});
116- seq++;
117- }
118-
119- return results;
120- }
12198};
12299} // namespace functions
123100} // namespace pgrouting
0 commit comments