-
-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathfour_edges.pg
More file actions
148 lines (130 loc) · 3.81 KB
/
four_edges.pg
File metadata and controls
148 lines (130 loc) · 3.81 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
-- CopyRight(c) pgRouting developers
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
SET extra_float_digits=-3;
CREATE TABLE four_edges (
id BIGINT,
source BIGINT,
target BIGINT,
cost FLOAT,
reverse_cost FLOAT);
INSERT INTO four_edges (id, source, target, cost, reverse_cost) VALUES
( 719 , 52163 , -56570 , 179.400001 , 179.400001),
( 717 , 52222 , 52163 , 977.000001 , 977.000001),
( 718 , 52220 , 52222 , 961.000001 , 961.000001),
( 716 , -21019 , 52220 , 992.000001 , 992.000001);
SELECT * FROM pgr_trsp(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM
(VALUES
(719, 52163, -56570, 179.400001, 179.400001),
(717, 52222, 52163, 977.000001, 977.000001),
(718, 52220, 52222, 961.000001, 961.000001),
(716, -21019, 52220, 992.000001, 992.000001)
) AS t (id, source, target, cost, reverse_cost)$$,
719, 0,
718, 0,
true, true, NULL);
SELECT * FROM pgr_trsp(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM
(VALUES
(719, 52163, -56570, 179.40000, 179.40000),
(717, 52222, 52163, 977.00000, 977.00000),
(718, 52220, 52222, 961.00000, 961.00000),
(716, -21019, 52220, 992.00000, 992.00000)
) AS t (id, source, target, cost, reverse_cost)$$,
(SELECT source::int FROM four_edges WHERE id = 719),
(SELECT source::int FROM four_edges WHERE id = 718),
true, true, NULL);
SELECT * FROM pgr_trsp(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM four_edges$$,
719, 0,
718, 0,
true, true, NULL);
SELECT * FROM pgr_dijkstra(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM four_edges$$,
52163,
52220,
false);
SELECT * FROM pgr_dijkstra(
$$SELECT
id, source, target, cost, reverse_cost
FROM four_edges$$,
(SELECT source FROM four_edges WHERE id = 719),
(SELECT source FROM four_edges WHERE id = 718),
true);
/* Comparing withPoints and trsp*/
SELECT * FROM pgr_trsp(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM four_edges$$,
719, 0.5,
718, 0,
true, true, NULL);
SELECT * FROM pgr_withPoints(
$$SELECT
id, source, target, cost, reverse_cost
FROM four_edges$$,
$$SELECT 719 AS edge_id, 0.5::float AS fraction$$,
-1,
/* selecting source because we have 0 */
(SELECT source FROM four_edges WHERE id = 718),
true);
/* TODO should give result more or less the same as above*/
SELECT * FROM pgr_withPoints(
$$SELECT
id, source, target, cost, reverse_cost
FROM four_edges$$,
$$(SELECT 719 AS edge_id, 0.5::float AS fraction)
UNION
(SELECT 718, 0)$$,
-1, -2,
true);
SELECT * FROM pgr_trsp(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM four_edges$$,
719, 0,
718, 0.5,
true, true, NULL);
SELECT * FROM pgr_withPoints(
$$SELECT
id, source, target, cost, reverse_cost
FROM four_edges$$,
$$SELECT 718 AS edge_id, 0.5::float AS fraction$$,
/* selecting source because we have 0 */
(SELECT source FROM four_edges WHERE id = 719),
-1,
true);
/* TODO should give result more or less the same as above*/
SELECT * FROM pgr_withPoints(
$$SELECT
id, source, target, cost, reverse_cost
FROM four_edges$$,
$$(SELECT 719 AS edge_id, 0::float AS fraction)
UNION
(SELECT 718, 0.5)$$,
-1, -2,
true);
SELECT * FROM pgr_trsp(
$$SELECT
id::int, source::int, target::int, cost::float, reverse_cost::float
FROM four_edges$$,
719, 0.5,
718, 0.5,
true, true, NULL);
SELECT * FROM pgr_withPoints(
$$SELECT
id, source, target, cost, reverse_cost
FROM four_edges$$,
$$(SELECT 719 AS edge_id, 0.5::float AS fraction)
UNION
(SELECT 718, 0.5)$$,
-1, -2,
true);