@@ -53,21 +53,27 @@ namespace pgrouting {
5353template <class G >
5454std::vector<int64_t >
5555kingOrdering (G &graph) {
56- using V = typename G::V;
5756 using B_G = typename G::B_G;
58- using vertices_size_type = typename boost::graph_traits<B_G>::vertices_size_type ;
57+ using V = typename G::V ;
5958
6059 size_t n = boost::num_vertices (graph.graph );
6160 std::vector<int64_t > results (n);
6261
6362 auto index_map = boost::get (boost::vertex_index, graph.graph );
64- std::vector<vertices_size_type> colors (n);
63+
64+ std::vector<V> colors (n);
6565 auto color_map = boost::make_iterator_property_map (colors.begin (), index_map);
6666 auto degree_map = boost::make_degree_map (graph.graph );
6767 std::vector<V> inv_perm (n);
6868
6969 CHECK_FOR_INTERRUPTS ();
70- boost::king_ordering (graph.graph , inv_perm. rbegin (), color_map, degree_map, index_map);
70+ boost::king_ordering (
71+ graph.graph ,
72+ inv_perm.rbegin (),
73+ color_map,
74+ degree_map,
75+ index_map);
76+
7177 size_t j = 0 ;
7278 for (auto i = inv_perm.begin (); i != inv_perm.end (); ++i, ++j) {
7379 results[j] = static_cast <int64_t >(graph.graph [index_map[*i]].id );
@@ -80,35 +86,41 @@ template <class G>
8086std::vector<int64_t >
8187minDegreeOrdering (G &graph) {
8288 using B_G = typename G::B_G;
83- using vertices_size_type = typename boost::graph_traits<B_G>::vertices_size_type ;
89+ using V = typename G::V ;
8490
8591 size_t n = boost::num_vertices (graph.graph );
8692 std::vector<int64_t > results (n);
8793
8894 auto index_map = boost::get (boost::vertex_index, graph.graph );
8995
90- std::vector<vertices_size_type> degree (n, 0 );
91- auto degree_map = boost::make_iterator_property_map (degree .begin (), index_map);
96+ std::vector<V> degrees (n );
97+ auto degree_map = boost::make_iterator_property_map (degrees .begin (), index_map);
9298
93- std::vector<vertices_size_type > supernode_sizes (n, 1 );
99+ std::vector<V > supernode_sizes (n, 1 );
94100 auto supernode_map = boost::make_iterator_property_map (supernode_sizes.begin (), index_map);
95101
96- std::vector<vertices_size_type> perm (n);
97- std::vector<vertices_size_type> inv_perm (n);
102+ std::vector<V> perm (n);
103+ std::vector<V> inv_perm (n);
104+
105+ auto [vi, vi_end] = boost::vertices (graph.graph );
106+ for (; vi != vi_end; ++vi) {
107+ degree_map[*vi] = boost::degree (*vi, graph.graph );
108+ }
98109
99110 CHECK_FOR_INTERRUPTS ();
100111
101112 boost::minimum_degree_ordering (
102113 graph.graph ,
103114 degree_map,
104- inv_perm.data (),
105- perm.data (),
115+ inv_perm.begin (),
116+ perm.begin (),
106117 supernode_map,
107118 0 ,
108119 index_map);
109120
110- for (size_t i = 0 ; i < n; ++i) {
111- results[i] = static_cast <int64_t >(graph.graph [inv_perm[i]].id );
121+ size_t j = 0 ;
122+ for (auto i = inv_perm.begin (); i != inv_perm.end (); ++i, ++j) {
123+ results[j] = static_cast <int64_t >(graph.graph [index_map[*i]].id );
112124 }
113125
114126 return results;
0 commit comments