11/* PGR-GNU*****************************************************************
2- File: ordering .hpp
2+ File: minDegreeOrdering .hpp
33
44Generated with Template by:
55Copyright (c) 2015 pgRouting developers
@@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2727
2828 ********************************************************************PGR-GNU*/
2929
30- #ifndef INCLUDE_ORDERING_ORDERING_HPP_
31- #define INCLUDE_ORDERING_ORDERING_HPP_
30+ #ifndef INCLUDE_ORDERING_MINDEGREEORDERING_HPP_
31+ #define INCLUDE_ORDERING_MINDEGREEORDERING_HPP_
3232#pragma once
3333
3434#include < vector>
@@ -44,48 +44,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4444
4545#include " cpp_common/base_graph.hpp"
4646#include " cpp_common/interruption.hpp"
47- #include < boost/graph/king_ordering.hpp>
4847#include < boost/graph/minimum_degree_ordering.hpp>
4948
5049
5150namespace pgrouting {
5251
53- template <class G >
54- std::vector<int64_t >
55- kingOrdering (G &graph) {
56- using B_G = typename G::B_G;
57- using V = typename G::V;
58-
59- size_t n = boost::num_vertices (graph.graph );
60- std::vector<int64_t > results (n);
61-
62- auto index_map = boost::get (boost::vertex_index, graph.graph );
63-
64- std::vector<V> colors (n);
65- auto color_map = boost::make_iterator_property_map (colors.begin (), index_map);
66- auto degree_map = boost::make_degree_map (graph.graph );
67- std::vector<V> inv_perm (n);
68-
69- CHECK_FOR_INTERRUPTS ();
70- boost::king_ordering (
71- graph.graph ,
72- inv_perm.rbegin (),
73- color_map,
74- degree_map,
75- index_map);
76-
77- size_t j = 0 ;
78- for (auto i = inv_perm.begin (); i != inv_perm.end (); ++i, ++j) {
79- results[j] = static_cast <int64_t >(graph.graph [index_map[*i]].id );
80- }
81-
82- return results;
83- }
84-
8552template <class G >
8653std::vector<int64_t >
8754minDegreeOrdering (G &graph) {
88- using B_G = typename G::B_G;
8955 using V = typename G::V;
9056
9157 size_t n = boost::num_vertices (graph.graph );
@@ -99,27 +65,26 @@ minDegreeOrdering(G &graph) {
9965 std::vector<V> supernode_sizes (n, 1 );
10066 auto supernode_map = boost::make_iterator_property_map (supernode_sizes.begin (), index_map);
10167
102- std::vector<V> perm (n);
103- std::vector<V> inv_perm (n);
68+ std::vector<V> permutation (n);
69+ std::vector<V> inv_permutation (n);
10470
105- auto [vi, vi_end] = boost::vertices (graph.graph );
106- for (; vi != vi_end; ++vi) {
107- degree_map[*vi] = boost::degree (*vi, graph.graph );
71+ for (V v = 0 ; v < n; ++v) {
72+ degree_map[v] = boost::degree (v, graph.graph );
10873 }
10974
11075 CHECK_FOR_INTERRUPTS ();
11176
11277 boost::minimum_degree_ordering (
11378 graph.graph ,
11479 degree_map,
115- inv_perm .begin (),
116- perm .begin (),
80+ inv_permutation .begin (),
81+ permutation .begin (),
11782 supernode_map,
11883 0 ,
11984 index_map);
12085
12186 size_t j = 0 ;
122- for (auto i = inv_perm .begin (); i != inv_perm .end (); ++i, ++j) {
87+ for (auto i = inv_permutation .begin (); i != inv_permutation .end (); ++i, ++j) {
12388 results[j] = static_cast <int64_t >(graph.graph [index_map[*i]].id );
12489 }
12590
0 commit comments