Skip to content

Commit 8d19133

Browse files
authored
Merge pull request #460 from bipashabg/week-5-sloanordering
Week 5 sloan ordering
2 parents 4956c27 + dceb5f6 commit 8d19133

File tree

16 files changed

+88
-141
lines changed

16 files changed

+88
-141
lines changed

doc/ordering/ordering-family.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Ordering - Family of functions
2222
.. official-start
2323
2424
* :doc:`pgr_cuthillMckeeOrdering` - Return reverse Cuthill-McKee ordering of an undirected graph.
25-
* :doc:`pgr_sloanOrdering` - Return sloan ordering of an undirected graph.
2625
* :doc:`pgr_topologicalSort` - Linear ordering of the vertices for directed
2726
acyclic graph.
2827

@@ -32,7 +31,6 @@ Ordering - Family of functions
3231
:hidden:
3332

3433
pgr_cuthillMckeeOrdering
35-
pgr_sloanOrdering
3634
pgr_topologicalSort
3735

3836
See Also

docqueries/ordering/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
SET(LOCAL_FILES
33
cuthillMckeeOrdering
44
topologicalSort
5+
sloanOrdering
56
)
67

78
foreach (f ${LOCAL_FILES})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- CopyRight(c) pgRouting developers
2+
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
3+
/* -- q1 */
4+
SELECT * FROM pgr_sloanOrdering(
5+
'SELECT id, source, target, cost, reverse_cost FROM edges'
6+
);
7+
/* -- q2 */

docqueries/ordering/sloanOrdering.result

Whitespace-only changes.

docqueries/ordering/test.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'files' => [qw(
66
cuthillMckeeOrdering.pg
77
topologicalSort.pg
8+
sloanOrdering.pg
89
)]
910
},
1011

include/drivers/ordering_driver.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3232
#pragma once
3333

3434
#include <cstddef>
35-
#include <cstddef>
36-
using Edge_t = struct Edge_t;
37-
using II_t_rt = struct II_t_rt;
3835
#include <string>
3936

4037

4138
void
4239
do_ordering(
43-
std::string, int64_t, int64_t,
40+
std::string, int,
4441

45-
II_t_rt**, size_t*,
42+
int64_t**, size_t*,
4643
char **, char **, char **);
4744

4845

include/ordering/ordering.hpp renamed to include/ordering/sloanOrdering.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3434
#include <vector>
3535
#include <limits>
3636
#include <iterator>
37-
37+
#include <utility>
3838

3939
#include <boost/config.hpp>
4040
#include <boost/graph/adjacency_list.hpp>
@@ -63,30 +63,27 @@ struct inf_plus {
6363
template <class G>
6464
std::vector<std::vector<int64_t>>
6565
sloan(G &graph) {
66-
6766
CHECK_FOR_INTERRUPTS();
6867

69-
std::pair<typename G::V, typename G::V> starting_nodes =
70-
boost::sloan_starting_nodes(graph.graph);
68+
std::pair<typename G::V, typename G::V> starting_nodes = boost::sloan_starting_nodes(graph.graph);
7169

7270
std::vector<typename G::V> inv_perm(graph.num_vertices());
7371

7472
boost::sloan_ordering(
7573
graph.graph,
7674
inv_perm.begin(),
7775
boost::get(boost::vertex_color_t(), graph.graph),
78-
boost::make_degree_map(graph.graph),
76+
boost::make_degree_map(graph.graph),
7977
starting_nodes.first,
80-
starting_nodes.second
81-
);
78+
starting_nodes.second);
8279

8380
CHECK_FOR_INTERRUPTS();
8481

8582
std::vector<int64_t> result;
8683
result.reserve(inv_perm.size());
8784

8885
for (const auto& vertex_desc : inv_perm) {
89-
result.push_back(graph[vertex_desc].id);
86+
result.push_back(graph[vertex_desc].id);
9087
}
9188

9289
return result;

include/process/ordering_process.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2828
#pragma once
2929

3030
#ifdef __cplusplus
31+
#include <stdbool.h>
3132
#include <cstddef>
3233
#include <cstdint>
33-
#include <stdbool.h>
34-
using Edge_t = struct Edge_t;
35-
using II_t_rt = struct II_t_rt;
34+
#include <string>
35+
3636
#else
3737
#include <stddef.h>
3838
#include <stdint.h>
39-
typedef struct Edge_t Edge_t;
40-
typedef struct II_t_rt II_t_rt;
4139
#endif
4240

41+
4342
#ifdef __cplusplus
4443
extern "C" {
4544
#endif
4645

47-
void pgr_process_ordering(const char*, int16_t, II_t_rt **, size_t *);
46+
void pgr_process_ordering(const char*, int, int64_t**, size_t*);
4847

4948
#ifdef __cplusplus
5049
}

pgtap/ordering/sloan/types_check.pg

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
********************************************************************PGR-GNU*/
2020
BEGIN;
2121

22-
SELECT CASE WHEN min_version('4.0.0') THEN plan(1) ELSE plan(5) END;
22+
SELECT CASE WHEN min_version('4.0.0') THEN plan(5) ELSE plan(1) END;
2323

2424
CREATE OR REPLACE FUNCTION types_check()
2525
RETURNS SETOF TEXT AS
2626
$BODY$
2727
BEGIN
2828

2929
IF NOT min_version('4.0.0') THEN
30-
RETURN QUERY
31-
SELECT skip(1, 'Function is new on 4.0.0');
30+
RETURN QUERY SELECT skip(1, 'Function is new on 4.0.0');
3231
RETURN;
3332
END IF;
3433

@@ -38,11 +37,10 @@ BEGIN
3837

3938
RETURN QUERY
4039
SELECT function_args_eq('pgr_sloanordering',
41-
$$SELECT '{"","seq","node"}'::TEXT[] $$
40+
$$SELECT '{"", seq, node}'::TEXT[] $$
4241
);
4342

44-
RETURN QUERY
45-
SELECT function_types_eq('pgr_sloanordering',
43+
RETURN QUERY SELECT function_types_eq('pgr_sloanordering',
4644
$$VALUES
4745
('{text,int8,int8}'::TEXT[])
4846
$$

sql/ordering/_sloanOrdering.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ RETURNS SETOF RECORD AS
4242
'MODULE_PATHNAME'
4343
LANGUAGE C IMMUTABLE STRICT;
4444

45-
-- COMMENTS
46-
4745
COMMENT ON FUNCTION _pgr_sloanOrdering(TEXT)
4846
IS 'pgRouting internal function';
4947

0 commit comments

Comments
 (0)