diff --git a/pgtap/contraction/deadend/directed/big_ids.pg b/pgtap/contraction/deadend/directed/big_ids.pg deleted file mode 100644 index ce3bb110b7b..00000000000 --- a/pgtap/contraction/deadend/directed/big_ids.pg +++ /dev/null @@ -1,140 +0,0 @@ - -/*PGR-GNU***************************************************************** - -Copyright (c) 2018 pgRouting developers -Mail: project@pgrouting.org - ------- -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - ********************************************************************PGR-GNU*/ -BEGIN; - -UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost); -SELECT plan(6); - -UPDATE edges -SET id = id + POWER(10, 8), - source = source + POWER(10, 8), - target = target + POWER(10, 8); - - --- input: 5 <-> 6, forbidden = 20 --- output: 2{1} ---Checking dead end contraction with invalid forbidden vertices -PREPARE q1 AS -SELECT * FROM pgr_contraction( - $$SELECT id, source, target, cost, reverse_cost FROM edges - WHERE id = 100000005$$, - ARRAY[1]::integer[], 1, ARRAY[20]::BIGINT[], true); - -SELECT set_eq('q1', - $$SELECT - 'v'::CHAR AS type, - 100000011::BIGINT AS id, - ARRAY[100000010]::BIGINT[] AS contracted_vertices, - -1::BIGINT AS source, - -1::BIGINT AS target, - -1::FLOAT AS cost$$); - --- Checking dead end contraction with no dead end node --- input: 10->6 6<->7, 7<->11, 10->11 --q1 --- output: -PREPARE q2 AS -SELECT * FROM pgr_contraction( - $$SELECT id, source, target, cost, reverse_cost FROM edges - WHERE id IN (100000002, 100000004, 100000005, 100000008)$$, - ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true); - -SELECT is_empty('q2'); - --- input: 5 <-> 6 --- outputt: 6{5} ---Checking dead end contraction for single dead end node -PREPARE q3 AS -SELECT * FROM pgr_contraction( - $$SELECT id, source, target, cost, reverse_cost FROM edges - WHERE id = 100000001$$, - ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true); - -SELECT set_eq('q3', - $$SELECT - 'v'::CHAR AS type, - 100000006::BIGINT AS id, - ARRAY[100000005]::BIGINT[] AS contracted_vertices, - -1::BIGINT AS source, - -1::BIGINT AS target, - -1::FLOAT AS cost$$); - --- Checking dead end contraction for two dead end nodes --- input: 6 <- 10 <- 15 --- output: 15{6, 10} -PREPARE q4 AS -SELECT * FROM pgr_contraction( - $$SELECT id, source, target, cost, reverse_cost FROM edges - WHERE id IN (100000002, 100000003)$$, - ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true); - -SELECT set_eq('q4', - $$SELECT - 'v'::CHAR AS type, - 100000006::BIGINT AS id, - ARRAY[100000010,100000015]::BIGINT[] AS contracted_vertices, - -1::BIGINT AS source, - -1::BIGINT AS target, - -1::FLOAT AS cost$$); - ---Checking dead end contraction for multiple dead end nodes --- input: 5 <-> 6 <- 10 <- 15 --- output: 6{5, 10, 15} -PREPARE q5 AS -SELECT type, id, unnest(contracted_vertices) FROM pgr_contraction( - $$SELECT id, source, target, cost, reverse_cost FROM edges - WHERE id IN (100000001, 100000002, 100000003)$$, - ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true); - -PREPARE sol5 AS -SELECT type, id, unnest -FROM (VALUES - ('v'::CHAR, 100000006::BIGINT, 100000005), - ('v'::CHAR, 100000006::BIGINT, 100000015), - ('v'::CHAR, 100000006::BIGINT, 100000010) -) AS t(type, id, unnest); - -SELECT set_eq('q5', 'sol5'); - --- all table --- 15{14} --- 16{17} --- 10{13} --- 5{7,8} --- 2{1} --- Checking dead end contraction for sample data -PREPARE q6 AS -SELECT * FROM pgr_contraction( - 'SELECT id, source, target, cost, reverse_cost FROM edges', - ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], true); - -PREPARE sol6 AS -SELECT type, id, contracted_vertices, source, target, cost -FROM (VALUES - ('v'::CHAR, 100000004::BIGINT, ARRAY[100000002]::BIGINT[], -1::BIGINT, -1::BIGINT, -1::FLOAT), - ('v', 100000007, ARRAY[100000001,100000003], -1, -1, -1), - ('v', 100000006, ARRAY[100000005], -1, -1, -1), - ('v', 100000008, ARRAY[100000009], -1, -1, -1), - ('v', 100000014, ARRAY[100000013], -1, -1, -1) -) AS t(type, id, contracted_vertices, source, target, cost ); - -SELECT set_eq('q6', 'sol6'); - -SELECT finish(); -ROLLBACK; diff --git a/tools/testers/contraction_tapfuncs.sql b/tools/testers/contraction_tapfuncs.sql index d66c6e490b9..59194493b4d 100644 --- a/tools/testers/contraction_tapfuncs.sql +++ b/tools/testers/contraction_tapfuncs.sql @@ -24,6 +24,7 @@ vids BIGINT[] = ARRAY[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]; x BIGINT; q TEXT; mainq TEXT; +otherq TEXT; expected TEXT; BEGIN UPDATE edges @@ -66,48 +67,55 @@ BEGIN -1::BIGINT AS target, -1::FLOAT AS cost$$); - q = format(mainq, ARRAY[vids[1], vids[2]], directed); + otherq = $d$ SELECT type, id, unnest(contracted_vertices) FROM pgr_contraction( + $$SELECT id, source, target, cost, reverse_cost FROM edges WHERE id = ANY('%1$s'::BIGINT[]) $$, + ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], '%2$s'::BOOLEAN)$d$; - RETURN QUERY - SELECT set_eq(q, - $$SELECT - 'v'::CHAR AS type, - $$ || vids[10] || $$::BIGINT AS id, - ARRAY[ $$ || vids[5] || $$,$$ || vids[6] || $$]::BIGINT[] AS contracted_vertices, - -1::BIGINT AS source, - -1::BIGINT AS target, - -1::FLOAT AS cost$$); + q = format(otherq, ARRAY[vids[1], vids[2]], directed); + + expected = format($d$ + SELECT type, id, unnest + FROM (VALUES + ('v'::TEXT, %1$s::BIGINT, %2$s::BIGINT), + ('v', %1$s, %3$s) + ) AS t(type, id, unnest)$d$, + vids[10], vids[5], vids[6]) ; + + RETURN QUERY SELECT set_eq(q, expected); - q = format(mainq, ARRAY[vids[1], vids[2], vids[3]], directed); + q = format(otherq, ARRAY[vids[1], vids[2], vids[3]], directed); expected = format($d$ - SELECT type, id, contracted_vertices, source, target, cost + SELECT type, id, unnest FROM (VALUES - ('v'::CHAR, %1$s::BIGINT, '%2$s'::BIGINT[], -1::BIGINT, -1::BIGINT, -1::FLOAT) - ) AS t(type, id, contracted_vertices, source, target, cost )$d$, - vids[6], ARRAY[vids[5], vids[10], vids[15]]) ; + ('v'::TEXT, %1$s::BIGINT, %2$s::BIGINT), + ('v', %1$s, %3$s), + ('v', %1$s, %4$s) + ) AS t(type, id, unnest)$d$, + vids[6], vids[5], vids[10], vids[15]) ; RETURN QUERY SELECT set_eq(q, expected); - q = format($d$ SELECT * FROM pgr_contraction( + q = format($d$ SELECT type, id, unnest(contracted_vertices) FROM pgr_contraction( $$SELECT id, source, target, cost, reverse_cost FROM edges$$, ARRAY[1]::integer[], 1, ARRAY[]::BIGINT[], '%1$s'::BOOLEAN)$d$, directed); expected = format($d$ - SELECT type, id, contracted_vertices, source, target, cost + SELECT type, id, unnest FROM (VALUES - ('v'::CHAR, %1$s::BIGINT, '%2$s'::BIGINT[], -1::BIGINT, -1::BIGINT, -1::FLOAT), - ('v', %3$s, '%4$s'::BIGINT[], -1, -1, -1), - ('v', %5$s, '%6$s'::BIGINT[], -1, -1, -1), - ('v', %7$s, '%8$s'::BIGINT[], -1, -1, -1), - ('v', %9$s, '%10$s'::BIGINT[], -1, -1, -1) - ) AS t(type, id, contracted_vertices, source, target, cost )$d$, - vids[4], ARRAY[vids[2]], - vids[6], ARRAY[vids[5]], - vids[7], ARRAY[vids[1], vids[3]], - vids[8], ARRAY[vids[9]], - vids[14], ARRAY[vids[13]]); + ('v'::CHAR, %1$s::BIGINT, %2$s), + ('v', %3$s, %4$s), + ('v', %5$s, %6$s), + ('v', %5$s, %7$s), + ('v', %8$s, %9$s), + ('v', %10$s, %11$s) + ) AS t(type, id, unnest)$d$, + vids[4], vids[2], + vids[6], vids[5], + vids[7], vids[1], vids[3], + vids[8], vids[9], + vids[14], vids[13]); RETURN QUERY SELECT set_eq(q, expected);