Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dijkstra code simplification #2521

Merged
merged 30 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e137cd3
[dijkstra][C++] pgr_dijkstra.hpp -> dijkstra.hpp
cvvergara May 22, 2023
dd55df8
[dijkstra] adjusting code to previous change
cvvergara May 22, 2023
95b20d7
[Dijkstra][visitors] creating a visitors file for dijkstra
cvvergara May 22, 2023
61cf7ac
[dijkstra] adjusting code to previous change
cvvergara May 22, 2023
51f7850
[Dijkstra][visitors] moving visitors got visitors file
cvvergara May 22, 2023
80ef5dc
[dijkstra] adjusting code to previous change
cvvergara May 22, 2023
8f38334
[dijkstra]:broom: removing unused code & linting
cvvergara May 22, 2023
ab11cf1
[Dijkstra][visitors] moving visitor to visitors file
cvvergara May 22, 2023
fc1118f
[dijkstra] adjusting code to previous change
cvvergara May 22, 2023
7182b7f
[dijkstra]:broom: removing unused code
cvvergara May 22, 2023
92f0efb
[dijkstra] 1 to 1 is a function
cvvergara May 22, 2023
97cdb61
[dijkstra]:broom: removing unused code
cvvergara May 22, 2023
2721232
[dijkstra] making call with map a function
cvvergara May 22, 2023
40f338f
[dijkstra] adjusting code to previous change
cvvergara May 22, 2023
180f666
[dijkstra]:broom: removing unused code
cvvergara May 22, 2023
face553
[dijkstra] many to many not used anymore
cvvergara May 22, 2023
37cc640
[dijkstra] marking unused code
cvvergara May 22, 2023
bd0ca0b
[dijkstra]:broom: removing unused code
cvvergara May 22, 2023
ffe352d
Separating driving distance from dijkstra
cvvergara May 22, 2023
a4303cd
[dijkstra/drivingDistance] adjusting code to previous change
cvvergara May 22, 2023
1315106
[dijkstra/drivingDistance]:broom: removing unused code
cvvergara May 22, 2023
e3bc881
dijkstra is on algorithms namespace
cvvergara May 22, 2023
afb189a
[dijkstra] Using departure & destination when data has boost graph info
cvvergara May 22, 2023
9b9915d
[1 to many] Using Boost graph in fn that calls boost
cvvergara May 22, 2023
d2d776d
[dijkstra] 1 to 1 using combinations
cvvergara May 22, 2023
48c596a
[dijkstra]:broom: removing unused code
cvvergara May 22, 2023
bb928f4
fixing licenses
cvvergara May 25, 2023
9f9f6d7
[docqueries] Removing windows ctrl-M
cvvergara May 25, 2023
a133cd4
[doc] Updating NEWS and release notes
cvvergara May 25, 2023
cf66b7f
[visitors] one goal visitor is used
cvvergara May 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pgRouting 3.6.0 Release Notes
duplicate code on Dijkstra.
* `2517 <https://github.com/pgRouting/pgrouting/pull/2517>` Astar code
simplification.
* `2521 <https://github.com/pgRouting/pgrouting/pull/2521>` Dijkstra code
simplification.

**Documentation**

Expand Down
2 changes: 2 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pgRouting 3.6.0 Release Notes
duplicate code on Dijkstra.
* `2517 <https://github.com/pgRouting/pgrouting/pull/2517>` Astar code
simplification.
* `2521 <https://github.com/pgRouting/pgrouting/pull/2521>` Dijkstra code
simplification.

.. rubric:: Documentation

Expand Down
214 changes: 107 additions & 107 deletions docqueries/topology/degree.result
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
BEGIN;
BEGIN
SET client_min_messages TO NOTICE;
SET
/* -- q1 */
DROP TABLE IF EXISTS tmp_edges_vertices_pgr;
NOTICE: table "tmp_edges_vertices_pgr" does not exist, skipping
DROP TABLE
CREATE TEMP TABLE tmp_edges_vertices_pgr AS
SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges');
SELECT 17
SELECT * FROM pgr_degree(
$$SELECT id FROM edges$$,
$$SELECT id, in_edges, out_edges
FROM tmp_edges_vertices_pgr$$);
node | degree
------+--------
1 | 1
2 | 1
3 | 2
4 | 1
5 | 1
6 | 3
7 | 4
8 | 3
9 | 1
10 | 3
11 | 4
12 | 3
13 | 1
14 | 1
15 | 2
16 | 3
17 | 2
(17 rows)
/* -- q2 */
SELECT * FROM pgr_degree(
$$SELECT id FROM edges WHERE id < 17$$,
$$SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$);
node | degree
------+--------
1 | 1
2 | 0
3 | 2
4 | 0
5 | 1
6 | 3
7 | 4
8 | 3
9 | 1
10 | 3
11 | 4
12 | 3
13 | 0
14 | 0
15 | 2
16 | 3
17 | 2
(17 rows)
/* -- q3 */
SELECT * FROM pgr_degree(
$$SELECT id FROM edges WHERE id < 17$$,
$$SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$,
dryrun => true);
NOTICE:
WITH
-- a sub set of edges of the graph goes here
g_edges AS (
SELECT id FROM edges WHERE id < 17
),
-- sub set of vertices of the graph goes here
all_vertices AS (
SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges')
),
g_vertices AS (
SELECT id,
unnest(
coalesce(in_edges::BIGINT[], '{}'::BIGINT[])
||
coalesce(out_edges::BIGINT[], '{}'::BIGINT[])) AS eid
FROM all_vertices
),
totals AS (
SELECT v.id, count(*)
FROM g_vertices AS v
JOIN g_edges AS e ON (e.id = eid) GROUP BY v.id
)
SELECT id::BIGINT, coalesce(count, 0)::BIGINT FROM all_vertices LEFT JOIN totals USING (id)
;
node | degree
------+--------
(0 rows)
/* -- q4 */
ROLLBACK;
ROLLBACK
BEGIN;
BEGIN
SET client_min_messages TO NOTICE;
SET
/* -- q1 */
DROP TABLE IF EXISTS tmp_edges_vertices_pgr;
NOTICE: table "tmp_edges_vertices_pgr" does not exist, skipping
DROP TABLE
CREATE TEMP TABLE tmp_edges_vertices_pgr AS
SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges');
SELECT 17
SELECT * FROM pgr_degree(
$$SELECT id FROM edges$$,
$$SELECT id, in_edges, out_edges
FROM tmp_edges_vertices_pgr$$);
node | degree
------+--------
1 | 1
2 | 1
3 | 2
4 | 1
5 | 1
6 | 3
7 | 4
8 | 3
9 | 1
10 | 3
11 | 4
12 | 3
13 | 1
14 | 1
15 | 2
16 | 3
17 | 2
(17 rows)

/* -- q2 */
SELECT * FROM pgr_degree(
$$SELECT id FROM edges WHERE id < 17$$,
$$SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$);
node | degree
------+--------
1 | 1
2 | 0
3 | 2
4 | 0
5 | 1
6 | 3
7 | 4
8 | 3
9 | 1
10 | 3
11 | 4
12 | 3
13 | 0
14 | 0
15 | 2
16 | 3
17 | 2
(17 rows)

/* -- q3 */
SELECT * FROM pgr_degree(
$$SELECT id FROM edges WHERE id < 17$$,
$$SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges')$$,
dryrun => true);
NOTICE:
WITH

-- a sub set of edges of the graph goes here
g_edges AS (
SELECT id FROM edges WHERE id < 17
),

-- sub set of vertices of the graph goes here
all_vertices AS (
SELECT id, in_edges, out_edges
FROM pgr_extractVertices('SELECT id, geom FROM edges')
),

g_vertices AS (
SELECT id,
unnest(
coalesce(in_edges::BIGINT[], '{}'::BIGINT[])
||
coalesce(out_edges::BIGINT[], '{}'::BIGINT[])) AS eid
FROM all_vertices
),

totals AS (
SELECT v.id, count(*)
FROM g_vertices AS v
JOIN g_edges AS e ON (e.id = eid) GROUP BY v.id
)

SELECT id::BIGINT, coalesce(count, 0)::BIGINT FROM all_vertices LEFT JOIN totals USING (id)
;
node | degree
------+--------
(0 rows)

/* -- q4 */
ROLLBACK;
ROLLBACK
Loading