Skip to content

Commit 2314d3c

Browse files
committed
Fixes on result and documentation
1 parent 2cd5598 commit 2314d3c

File tree

3 files changed

+85
-24
lines changed

3 files changed

+85
-24
lines changed

doc/contraction/pgr_contractionDeadEnd.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Signatures
5858

5959
| pgr_contractionDeadEnd(`Edges SQL`_, [**options**])
6060
61-
| **options:** ``[directed, forbidden_vertices]``
61+
| **options:** ``[directed, forbidden]``
6262
| Returns set of |result-contract|
6363
6464
:Example: Dead end contraction on an undirected graph.

doc/contraction/pgr_contractionLinear.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Signatures
4444

4545
| pgr_contractionLinear(`Edges SQL`_, [**options**])
4646
47-
| **options:** ``[directed, max_cycles, forbidden_vertices]``
47+
| **options:** ``[directed, forbidden]``
4848
| Returns set of |result-contract|
4949
5050
:Example: Linear contraction on an undirected graph.
@@ -130,11 +130,11 @@ Contraction optional parameters
130130
- Type
131131
- Default
132132
- Description
133-
* - ``forbidden_vertices``
133+
* - ``forbidden``
134134
- ``ARRAY[`` **ANY-INTEGER** ``]``
135135
- **Empty**
136136
- Identifiers of vertices forbidden for contraction.
137-
* - ``max_cycles``
137+
* - ``cycles``
138138
- ``INTEGER``
139139
- :math:`1`
140140
- Number of times the contraction operations on ``contraction_order`` will

docqueries/contraction/contractionLinear.result

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,107 @@ SET
66
SELECT * FROM pgr_contractionLinear(
77
'SELECT id, source, target, cost, reverse_cost FROM edges',
88
directed => false);
9-
ERROR: function pgr_contractionlinear(unknown, directed => boolean) does not exist
10-
LINE 2: SELECT * FROM pgr_contractionLinear(
11-
^
12-
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
9+
type | id | contracted_vertices | source | target | cost
10+
------+----+---------------------+--------+--------+------
11+
e | -1 | {3} | 1 | 7 | 2
12+
e | -2 | {17} | 12 | 16 | 2
13+
e | -3 | {15} | 10 | 16 | 2
14+
(3 rows)
15+
1316
/* -- q2 */
1417
SELECT * FROM pgr_contractionLinear(
1518
$$SELECT * FROM (VALUES
1619
(1, 1, 2, 1, -1),
1720
(2, 2, 3, 3, 4))
1821
AS edges(id,source,target,cost,reverse_cost)$$,
1922
directed => true);
20-
ERROR: current transaction is aborted, commands ignored until end of transaction block
23+
type | id | contracted_vertices | source | target | cost
24+
------+----+---------------------+--------+--------+------
25+
(0 rows)
26+
2127
/* -- q3 */
2228
SELECT * FROM pgr_contractionLinear(
2329
$$SELECT * FROM (VALUES
2430
(1, 1, 2, 1, -1),
2531
(2, 2, 3, 3, 4))
2632
AS edges(id,source,target,cost,reverse_cost)$$,
2733
directed => false);
28-
ERROR: current transaction is aborted, commands ignored until end of transaction block
34+
type | id | contracted_vertices | source | target | cost
35+
------+----+---------------------+--------+--------+------
36+
e | -1 | {2} | 1 | 3 | 4
37+
(1 row)
38+
2939
/* -- q4 */
3040
SELECT * FROM pgr_contractionLinear(
3141
$$SELECT * FROM (VALUES
3242
(1, 1, 2, 1, 2),
3343
(2, 2, 3, 3, 4))
3444
AS edges(id,source,target,cost,reverse_cost)$$,
3545
directed => true);
36-
ERROR: current transaction is aborted, commands ignored until end of transaction block
46+
type | id | contracted_vertices | source | target | cost
47+
------+----+---------------------+--------+--------+------
48+
e | -1 | {2} | 1 | 3 | 4
49+
e | -2 | {2} | 3 | 1 | 6
50+
(2 rows)
51+
3752
/* -- q5 */
3853
SELECT * FROM pgr_contractionLinear(
3954
$$SELECT * FROM (VALUES
4055
(1, 1, 2, 1, 2),
4156
(2, 2, 3, 3, 4))
4257
AS edges(id,source,target,cost,reverse_cost)$$,
4358
directed => false);
44-
ERROR: current transaction is aborted, commands ignored until end of transaction block
59+
type | id | contracted_vertices | source | target | cost
60+
------+----+---------------------+--------+--------+------
61+
e | -1 | {2} | 1 | 3 | 4
62+
(1 row)
63+
4564
/* -- q6 */
4665
SELECT * FROM pgr_contractionLinear(
4766
$$SELECT * FROM (VALUES
4867
(1, 1, 2, 1),
4968
(2, 2, 3, 1),
5069
(2, 3, 4, 1))
5170
AS edges(id,source,target,cost)$$);
52-
ERROR: current transaction is aborted, commands ignored until end of transaction block
71+
type | id | contracted_vertices | source | target | cost
72+
------+----+---------------------+--------+--------+------
73+
e | -1 | {2,3} | 1 | 4 | 3
74+
(1 row)
75+
5376
/* -- q7 */
5477
/* -- cg1 */
5578
ALTER TABLE vertices ADD is_contracted BOOLEAN DEFAULT false;
56-
ERROR: current transaction is aborted, commands ignored until end of transaction block
79+
ALTER TABLE
5780
ALTER TABLE edges ADD is_new BOOLEAN DEFAULT false;
58-
ERROR: current transaction is aborted, commands ignored until end of transaction block
81+
ALTER TABLE
5982
ALTER TABLE edges ADD contracted_vertices BIGINT[];
60-
ERROR: current transaction is aborted, commands ignored until end of transaction block
83+
ALTER TABLE
6184
/* -- cg2 */
6285
SELECT * INTO contraction_results
6386
FROM pgr_contractionLinear(
6487
'SELECT id, source, target, cost, reverse_cost FROM edges',
6588
directed => false);
66-
ERROR: current transaction is aborted, commands ignored until end of transaction block
89+
SELECT 3
6790
/* -- cg3 */
6891
UPDATE vertices
6992
SET is_contracted = true
7093
WHERE id IN (SELECT unnest(contracted_vertices) FROM contraction_results);
71-
ERROR: current transaction is aborted, commands ignored until end of transaction block
94+
UPDATE 3
7295
/* -- cg4 */
7396
SELECT id, is_contracted
7497
FROM vertices WHERE is_contracted ORDER BY id;
75-
ERROR: current transaction is aborted, commands ignored until end of transaction block
98+
id | is_contracted
99+
----+---------------
100+
3 | t
101+
15 | t
102+
17 | t
103+
(3 rows)
104+
76105
/* -- cg5 */
77106
INSERT INTO edges(source, target, cost, reverse_cost, contracted_vertices, is_new)
78107
SELECT source, target, cost, -1, contracted_vertices, true
79108
FROM contraction_results;
80-
ERROR: current transaction is aborted, commands ignored until end of transaction block
109+
INSERT 0 3
81110
/* -- cg6 */
82111
CREATE VIEW contracted_graph AS
83112
WITH
@@ -89,14 +118,38 @@ FROM edges
89118
WHERE source IN (SELECT * FROM vertices_in_graph)
90119
AND target IN (SELECT * FROM vertices_in_graph)
91120
ORDER BY id;
92-
ERROR: current transaction is aborted, commands ignored until end of transaction block
121+
CREATE VIEW
93122
/* -- cg7 */
94123
SELECT * FROM contracted_graph ORDER by id;
95-
ERROR: current transaction is aborted, commands ignored until end of transaction block
124+
id | source | target | cost | reverse_cost
125+
----+--------+--------+------+--------------
126+
1 | 5 | 6 | 1 | 1
127+
2 | 6 | 10 | -1 | 1
128+
4 | 6 | 7 | 1 | 1
129+
5 | 10 | 11 | 1 | -1
130+
8 | 7 | 11 | 1 | 1
131+
9 | 11 | 16 | 1 | 1
132+
10 | 7 | 8 | 1 | 1
133+
11 | 11 | 12 | 1 | -1
134+
12 | 8 | 12 | 1 | -1
135+
14 | 8 | 9 | 1 | 1
136+
17 | 2 | 4 | 1 | 1
137+
18 | 13 | 14 | 1 | 1
138+
19 | 1 | 7 | 2 | -1
139+
20 | 12 | 16 | 2 | -1
140+
21 | 10 | 16 | 2 | -1
141+
(15 rows)
142+
96143
/* -- cg8 */
97144
SELECT *
98145
FROM pgr_dijkstra('SELECT * FROM contracted_graph', 7, 16);
99-
ERROR: current transaction is aborted, commands ignored until end of transaction block
146+
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
147+
-----+----------+-----------+---------+------+------+------+----------
148+
1 | 1 | 7 | 16 | 7 | 8 | 1 | 0
149+
2 | 2 | 7 | 16 | 11 | 9 | 1 | 1
150+
3 | 3 | 7 | 16 | 16 | -1 | 0 | 2
151+
(3 rows)
152+
100153
/* -- cg9 */
101154
SELECT * FROM pgr_dijkstra(
102155
'WITH in_line AS (SELECT contracted_vertices FROM edges WHERE 17 = ANY(contracted_vertices))
@@ -108,7 +161,15 @@ SELECT * FROM pgr_dijkstra(
108161

109162
SELECT id, source, target, cost, reverse_cost FROM contracted_graph',
110163
1, 17);
111-
ERROR: current transaction is aborted, commands ignored until end of transaction block
164+
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
165+
-----+----------+-----------+---------+------+------+------+----------
166+
1 | 1 | 1 | 17 | 1 | 19 | 2 | 0
167+
2 | 2 | 1 | 17 | 7 | 8 | 1 | 2
168+
3 | 3 | 1 | 17 | 11 | 9 | 1 | 3
169+
4 | 4 | 1 | 17 | 16 | 15 | 1 | 4
170+
5 | 5 | 1 | 17 | 17 | -1 | 0 | 5
171+
(5 rows)
172+
112173
/* -- cg10 */
113174
ROLLBACK;
114175
ROLLBACK

0 commit comments

Comments
 (0)