Skip to content

Commit 2aceee0

Browse files
committed
(bandwidth/docqueries) Adding test documentation examples code for pgr_bandwidth
1 parent cc5b800 commit 2aceee0

4 files changed

Lines changed: 197 additions & 0 deletions

File tree

docqueries/metrics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Do not use extensions
22
SET(LOCAL_FILES
3+
bandwidth
34
betweennessCentrality
45
degree
56
)

docqueries/metrics/bandwidth.pg

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
-- CopyRight(c) pgRouting developers
2+
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
3+
4+
/* -- q1 */
5+
SELECT * FROM pgr_bandwidth(
6+
'SELECT id, source, target, cost, reverse_cost
7+
FROM edges'
8+
);
9+
10+
/* -- q2 */
11+
CREATE TABLE my_edges1 (
12+
id SERIAL PRIMARY KEY,
13+
source INTEGER,
14+
target INTEGER,
15+
cost DOUBLE PRECISION,
16+
reverse_cost DOUBLE PRECISION
17+
);
18+
/* -- q3 */
19+
INSERT INTO my_edges1 (source, target, cost, reverse_cost) VALUES
20+
(4, 7, 1, 1),
21+
(7, 4, 1, 1),
22+
(7, 9, 1, 1),
23+
(9, 7, 1, 1),
24+
(7, 0, 1, 1),
25+
(0, 7, 1, 1),
26+
(0, 2, 1, 1),
27+
(2, 0, 1, 1),
28+
(2, 5, 1, 1),
29+
(5, 2, 1, 1),
30+
(5, 9, 1, 1),
31+
(9, 5, 1, 1),
32+
(9, 8, 1, 1),
33+
(8, 9, 1, 1),
34+
(9, 1, 1, 1),
35+
(1, 9, 1, 1),
36+
(5, 1, 1, 1),
37+
(1, 5, 1, 1),
38+
(9, 6, 1, 1),
39+
(6, 9, 1, 1),
40+
(6, 3, 1, 1),
41+
(3, 6, 1, 1),
42+
(1, 3, 1, 1),
43+
(3, 1, 1, 1);
44+
/* -- q4 */
45+
SELECT * FROM pgr_bandwidth(
46+
'SELECT id, source, target, cost, reverse_cost FROM my_edges1'
47+
);
48+
49+
/* -- q5 */
50+
CREATE TABLE my_edges2 (
51+
id SERIAL PRIMARY KEY,
52+
source INTEGER,
53+
target INTEGER,
54+
cost DOUBLE PRECISION,
55+
reverse_cost DOUBLE PRECISION
56+
);
57+
/* -- q6 */
58+
INSERT INTO my_edges2 (source, target, cost, reverse_cost) VALUES
59+
(0, 1, 1, 1),
60+
(1, 0, 1, 1),
61+
(1, 3, 1, 1),
62+
(3, 1, 1, 1),
63+
(1, 2, 1, 1),
64+
(2, 1, 1, 1),
65+
(2, 4, 1, 1),
66+
(4, 2, 1, 1),
67+
(4, 8, 1, 1),
68+
(8, 4, 1, 1),
69+
(8, 3, 1, 1),
70+
(3, 8, 1, 1),
71+
(3, 5, 1, 1),
72+
(5, 3, 1, 1),
73+
(3, 6, 1, 1),
74+
(6, 3, 1, 1),
75+
(3, 7, 1, 1),
76+
(7, 3, 1, 1),
77+
(8, 7, 1, 1),
78+
(7, 8, 1, 1),
79+
(6, 9, 1, 1),
80+
(9, 6, 1, 1),
81+
(7, 9, 1, 1),
82+
(9, 7, 1, 1);
83+
/* -- q7 */
84+
SELECT * FROM pgr_bandwidth(
85+
'SELECT id, source, target, cost, reverse_cost FROM my_edges2'
86+
);
87+
88+
/* -- q8 */
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
BEGIN;
2+
BEGIN
3+
SET client_min_messages TO NOTICE;
4+
SET
5+
/* -- q1 */
6+
SELECT * FROM pgr_bandwidth(
7+
'SELECT id, source, target, cost, reverse_cost
8+
FROM edges'
9+
);
10+
bandwidth
11+
-----------
12+
5
13+
(1 row)
14+
15+
/* -- q2 */
16+
CREATE TABLE my_edges1 (
17+
id SERIAL PRIMARY KEY,
18+
source INTEGER,
19+
target INTEGER,
20+
cost DOUBLE PRECISION,
21+
reverse_cost DOUBLE PRECISION
22+
);
23+
CREATE TABLE
24+
/* -- q3 */
25+
INSERT INTO my_edges1 (source, target, cost, reverse_cost) VALUES
26+
(4, 7, 1, 1),
27+
(7, 4, 1, 1),
28+
(7, 9, 1, 1),
29+
(9, 7, 1, 1),
30+
(7, 0, 1, 1),
31+
(0, 7, 1, 1),
32+
(0, 2, 1, 1),
33+
(2, 0, 1, 1),
34+
(2, 5, 1, 1),
35+
(5, 2, 1, 1),
36+
(5, 9, 1, 1),
37+
(9, 5, 1, 1),
38+
(9, 8, 1, 1),
39+
(8, 9, 1, 1),
40+
(9, 1, 1, 1),
41+
(1, 9, 1, 1),
42+
(5, 1, 1, 1),
43+
(1, 5, 1, 1),
44+
(9, 6, 1, 1),
45+
(6, 9, 1, 1),
46+
(6, 3, 1, 1),
47+
(3, 6, 1, 1),
48+
(1, 3, 1, 1),
49+
(3, 1, 1, 1);
50+
INSERT 0 24
51+
/* -- q4 */
52+
SELECT * FROM pgr_bandwidth(
53+
'SELECT id, source, target, cost, reverse_cost FROM my_edges1'
54+
);
55+
bandwidth
56+
-----------
57+
8
58+
(1 row)
59+
60+
/* -- q5 */
61+
CREATE TABLE my_edges2 (
62+
id SERIAL PRIMARY KEY,
63+
source INTEGER,
64+
target INTEGER,
65+
cost DOUBLE PRECISION,
66+
reverse_cost DOUBLE PRECISION
67+
);
68+
CREATE TABLE
69+
/* -- q6 */
70+
INSERT INTO my_edges2 (source, target, cost, reverse_cost) VALUES
71+
(0, 1, 1, 1),
72+
(1, 0, 1, 1),
73+
(1, 3, 1, 1),
74+
(3, 1, 1, 1),
75+
(1, 2, 1, 1),
76+
(2, 1, 1, 1),
77+
(2, 4, 1, 1),
78+
(4, 2, 1, 1),
79+
(4, 8, 1, 1),
80+
(8, 4, 1, 1),
81+
(8, 3, 1, 1),
82+
(3, 8, 1, 1),
83+
(3, 5, 1, 1),
84+
(5, 3, 1, 1),
85+
(3, 6, 1, 1),
86+
(6, 3, 1, 1),
87+
(3, 7, 1, 1),
88+
(7, 3, 1, 1),
89+
(8, 7, 1, 1),
90+
(7, 8, 1, 1),
91+
(6, 9, 1, 1),
92+
(9, 6, 1, 1),
93+
(7, 9, 1, 1),
94+
(9, 7, 1, 1);
95+
INSERT 0 24
96+
/* -- q7 */
97+
SELECT * FROM pgr_bandwidth(
98+
'SELECT id, source, target, cost, reverse_cost FROM my_edges2'
99+
);
100+
bandwidth
101+
-----------
102+
5
103+
(1 row)
104+
105+
/* -- q8 */
106+
ROLLBACK;
107+
ROLLBACK

docqueries/metrics/test.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
%main::tests = (
44
'any' => {
55
'files' => [qw(
6+
bandwidth.pg
67
betweennessCentrality.pg
78
degree.pg
89
)]

0 commit comments

Comments
 (0)