Skip to content

Commit 9eadf7a

Browse files
committed
(sloanOrdering/docqueries) Adding test documentation examples code for pgr_sloanOrdering
1 parent 2ed2c6d commit 9eadf7a

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

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
kingOrdering
67
)
78

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 */
8+
9+
CREATE TABLE example_edges1 (
10+
id SERIAL PRIMARY KEY,
11+
source INTEGER,
12+
target INTEGER,
13+
cost DOUBLE PRECISION,
14+
reverse_cost DOUBLE PRECISION
15+
);
16+
/* --q3 */
17+
INSERT INTO example_edges1 (source, target, cost, reverse_cost) VALUES
18+
(4, 7, 1, 1),
19+
(7, 4, 1, 1),
20+
(7, 9, 1, 1),
21+
(9, 7, 1, 1),
22+
(7, 0, 1, 1),
23+
(0, 7, 1, 1),
24+
(0, 2, 1, 1),
25+
(2, 0, 1, 1),
26+
(2, 5, 1, 1),
27+
(5, 2, 1, 1),
28+
(5, 9, 1, 1),
29+
(9, 5, 1, 1),
30+
(9, 8, 1, 1),
31+
(8, 9, 1, 1),
32+
(9, 1, 1, 1),
33+
(1, 9, 1, 1),
34+
(5, 1, 1, 1),
35+
(1, 5, 1, 1),
36+
(9, 6, 1, 1),
37+
(6, 9, 1, 1),
38+
(6, 3, 1, 1),
39+
(3, 6, 1, 1),
40+
(1, 3, 1, 1),
41+
(3, 1, 1, 1);
42+
/* --q4 */
43+
SELECT * FROM pgr_sloanOrdering(
44+
'SELECT id, source, target, cost, reverse_cost FROM example_edges1'
45+
);
46+
/* --q5 */
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
BEGIN;
2+
BEGIN
3+
SET client_min_messages TO NOTICE;
4+
SET
5+
/* -- q1 */
6+
SELECT * FROM pgr_sloanOrdering(
7+
'SELECT id, source, target, cost, reverse_cost FROM edges'
8+
);
9+
seq | node
10+
-----+------
11+
1 | 1
12+
2 | 3
13+
3 | 8
14+
4 | 9
15+
5 | 12
16+
6 | 7
17+
7 | 5
18+
8 | 17
19+
9 | 6
20+
10 | 11
21+
11 | 16
22+
12 | 10
23+
13 | 15
24+
14 | 1
25+
15 | 1
26+
16 | 1
27+
17 | 1
28+
(17 rows)
29+
30+
/* -- q2 */
31+
CREATE TABLE example_edges1 (
32+
id SERIAL PRIMARY KEY,
33+
source INTEGER,
34+
target INTEGER,
35+
cost DOUBLE PRECISION,
36+
reverse_cost DOUBLE PRECISION
37+
);
38+
CREATE TABLE
39+
/* --q3 */
40+
INSERT INTO example_edges1 (source, target, cost, reverse_cost) VALUES
41+
(4, 7, 1, 1),
42+
(7, 4, 1, 1),
43+
(7, 9, 1, 1),
44+
(9, 7, 1, 1),
45+
(7, 0, 1, 1),
46+
(0, 7, 1, 1),
47+
(0, 2, 1, 1),
48+
(2, 0, 1, 1),
49+
(2, 5, 1, 1),
50+
(5, 2, 1, 1),
51+
(5, 9, 1, 1),
52+
(9, 5, 1, 1),
53+
(9, 8, 1, 1),
54+
(8, 9, 1, 1),
55+
(9, 1, 1, 1),
56+
(1, 9, 1, 1),
57+
(5, 1, 1, 1),
58+
(1, 5, 1, 1),
59+
(9, 6, 1, 1),
60+
(6, 9, 1, 1),
61+
(6, 3, 1, 1),
62+
(3, 6, 1, 1),
63+
(1, 3, 1, 1),
64+
(3, 1, 1, 1);
65+
INSERT 0 24
66+
/* --q4 */
67+
SELECT * FROM pgr_sloanOrdering(
68+
'SELECT id, source, target, cost, reverse_cost FROM example_edges1'
69+
);
70+
seq | node
71+
-----+------
72+
1 | 4
73+
2 | 0
74+
3 | 2
75+
4 | 7
76+
5 | 8
77+
6 | 5
78+
7 | 9
79+
8 | 3
80+
9 | 1
81+
10 | 6
82+
(10 rows)
83+
84+
/* --q5 */
85+
ROLLBACK;
86+
ROLLBACK

docqueries/ordering/test.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
%main::tests = (
44
'any' => {
55
'files' => [qw(
6+
sloanOrdering.pg
67
cuthillMckeeOrdering.pg
78
topologicalSort.pg
9+
sloanOrdering.pg
810
kingOrdering.pg
911
)]
1012
},

0 commit comments

Comments
 (0)