forked from pgRouting/pgrouting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbandwidth.pg
More file actions
88 lines (84 loc) · 1.61 KB
/
Copy pathbandwidth.pg
File metadata and controls
88 lines (84 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
-- CopyRight(c) pgRouting developers
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
/* -- q1 */
SELECT * FROM pgr_bandwidth(
'SELECT id, source, target, cost, reverse_cost
FROM edges'
);
/* -- q2 */
CREATE TABLE my_edges1 (
id SERIAL PRIMARY KEY,
source INTEGER,
target INTEGER,
cost DOUBLE PRECISION,
reverse_cost DOUBLE PRECISION
);
/* -- q3 */
INSERT INTO my_edges1 (source, target, cost, reverse_cost) VALUES
(4, 7, 1, 1),
(7, 4, 1, 1),
(7, 9, 1, 1),
(9, 7, 1, 1),
(7, 0, 1, 1),
(0, 7, 1, 1),
(0, 2, 1, 1),
(2, 0, 1, 1),
(2, 5, 1, 1),
(5, 2, 1, 1),
(5, 9, 1, 1),
(9, 5, 1, 1),
(9, 8, 1, 1),
(8, 9, 1, 1),
(9, 1, 1, 1),
(1, 9, 1, 1),
(5, 1, 1, 1),
(1, 5, 1, 1),
(9, 6, 1, 1),
(6, 9, 1, 1),
(6, 3, 1, 1),
(3, 6, 1, 1),
(1, 3, 1, 1),
(3, 1, 1, 1);
/* -- q4 */
SELECT * FROM pgr_bandwidth(
'SELECT id, source, target, cost, reverse_cost FROM my_edges1'
);
/* -- q5 */
CREATE TABLE my_edges2 (
id SERIAL PRIMARY KEY,
source INTEGER,
target INTEGER,
cost DOUBLE PRECISION,
reverse_cost DOUBLE PRECISION
);
/* -- q6 */
INSERT INTO my_edges2 (source, target, cost, reverse_cost) VALUES
(0, 1, 1, 1),
(1, 0, 1, 1),
(1, 3, 1, 1),
(3, 1, 1, 1),
(1, 2, 1, 1),
(2, 1, 1, 1),
(2, 4, 1, 1),
(4, 2, 1, 1),
(4, 8, 1, 1),
(8, 4, 1, 1),
(8, 3, 1, 1),
(3, 8, 1, 1),
(3, 5, 1, 1),
(5, 3, 1, 1),
(3, 6, 1, 1),
(6, 3, 1, 1),
(3, 7, 1, 1),
(7, 3, 1, 1),
(8, 7, 1, 1),
(7, 8, 1, 1),
(6, 9, 1, 1),
(9, 6, 1, 1),
(7, 9, 1, 1),
(9, 7, 1, 1);
/* -- q7 */
SELECT * FROM pgr_bandwidth(
'SELECT id, source, target, cost, reverse_cost FROM my_edges2'
);
/* -- q8 */