-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from bedupako12mas/centrality-week9
Centrality Week 9
- Loading branch information
Showing
5 changed files
with
170 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*PGR-GNU***************************************************************** | ||
|
||
Copyright (c) 2024 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(15); | ||
|
||
SELECT test_agg_cost('pgr_floydWarshall', true); | ||
SELECT test_agg_cost('pgr_floydWarshall', false); | ||
SELECT allPairs_test_flags('pgr_floydwarshall'); | ||
|
||
PREPARE q2 AS | ||
SELECT * FROM pgr_floydWarshall( | ||
'SELECT source, target, cost, reverse_cost FROM edges' | ||
); | ||
|
||
PREPARE q3 AS | ||
SELECT * FROM pgr_floydWarshall( | ||
'SELECT source, target, cost FROM edges', | ||
true | ||
); | ||
|
||
SELECT lives_ok('q2', 'SHOULD WORK: without id with flag'); | ||
SELECT lives_ok('q3', 'SHOULD WORK: without id, with flag'); | ||
|
||
SELECT finish(); | ||
ROLLBACK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
/*PGR-GNU***************************************************************** | ||
|
||
Copyright (c) 2024 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 CASE WHEN NOT min_version('3.7.0') THEN plan(1) ELSE plan(54) END; | ||
|
||
CREATE OR REPLACE FUNCTION inner_query() | ||
RETURNS SETOF TEXT AS | ||
$BODY$ | ||
BEGIN | ||
|
||
IF NOT min_version('3.7.0') THEN | ||
RETURN QUERY | ||
SELECT skip(1, 'Function is new on 3.7.0'); | ||
RETURN; | ||
END IF; | ||
|
||
RETURN QUERY | ||
SELECT style_dijkstra('pgr_betweennessCentrality(', ')'); | ||
|
||
END; | ||
$BODY$ | ||
LANGUAGE plpgsql; | ||
|
||
SELECT inner_query(); | ||
|
||
SELECT finish(); | ||
ROLLBACK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
/*PGR-GNU***************************************************************** | ||
|
||
Copyright (c) 2024 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 CASE WHEN NOT min_version('3.7.0') THEN plan(1) ELSE plan(7) END; | ||
|
||
PREPARE edges_q AS | ||
SELECT id, source, target, cost, reverse_cost FROM edges; | ||
|
||
PREPARE null_ret AS | ||
SELECT id FROM vertices WHERE id IN (-1); | ||
|
||
PREPARE null_ret_arr AS | ||
SELECT array_agg(id) FROM vertices WHERE id IN (-1); | ||
|
||
|
||
CREATE OR REPLACE FUNCTION no_crash() | ||
RETURNS SETOF TEXT AS | ||
$BODY$ | ||
DECLARE | ||
params TEXT[]; | ||
subs TEXT[]; | ||
BEGIN | ||
IF NOT min_version('3.7.0') THEN | ||
RETURN QUERY | ||
SELECT skip(1, 'Function is new on 3.7.0'); | ||
RETURN; | ||
END IF; | ||
|
||
RETURN QUERY | ||
SELECT isnt_empty('edges_q', 'Should be not empty to tests be meaningful'); | ||
RETURN QUERY | ||
SELECT is_empty('null_ret', 'Should be empty to tests be meaningful'); | ||
RETURN QUERY | ||
SELECT set_eq('null_ret_arr', 'SELECT NULL::BIGINT[]', 'Should be empty to tests be meaningful'); | ||
|
||
params = ARRAY[ | ||
'$$SELECT id, source, target, cost, reverse_cost FROM edges$$' | ||
]::TEXT[]; | ||
subs = ARRAY[ | ||
'NULL' | ||
]::TEXT[]; | ||
|
||
RETURN query SELECT * FROM no_crash_test('pgr_betweennessCentrality', params, subs); | ||
|
||
END | ||
$BODY$ | ||
LANGUAGE plpgsql VOLATILE; | ||
|
||
|
||
SELECT * FROM no_crash(); | ||
|
||
SELECT finish(); | ||
ROLLBACK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters