diff --git a/.gitignore b/.gitignore index 70f98d9273..7b591360ba 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ notUsed .vscode taptest.sh +run.sh diff --git a/NEWS.md b/NEWS.md index 5a2d28dd93..42f8c0f378 100644 --- a/NEWS.md +++ b/NEWS.md @@ -54,6 +54,9 @@ Functions promoted to official **Signatures promoted to official** +[#2718](https://github.com/pgRouting/pgrouting/issues/2918) + Make official the Combinations signature on the official functions + * pgr_aStar(Combinations) * pgr_aStarCost(Combinations) * pgr_bdAstar(Combinations) @@ -74,14 +77,8 @@ SQL signatures and output standardization [#2904](https://github.com/pgRouting/pgrouting/issues/2904) Standardize output columns of functions with different output columns within overloads - **Official functions** -* [#2906](https://github.com/pgRouting/pgrouting/issues/2906) pgr_bdDijkstra - - * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` - * Combinations signature promoted to official. - * [#2905](https://github.com/pgRouting/pgrouting/issues/2905) pgr_withPoints @@ -92,15 +89,10 @@ Standardize output columns of functions with different output columns within ove - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - Undirected graph valid values: ``b`` or ``B`` -* [#2905](https://github.com/pgRouting/pgrouting/issues/2905) - pgr_withPointsCost +* [#2906](https://github.com/pgRouting/pgrouting/issues/2906) pgr_bdDijkstra - * Function promoted to official. - * Output columns standardized to ``(start_vid, end_vid, agg_cost)`` - * Signature change: ``driving_side`` parameter changed from named optional to - unnamed positional. - - Directed graph valid values: ``l`` or ``L`` and ``r``, ``R`` - - Undirected graph valid values: ``b`` or ``B`` + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + * Combinations signature promoted to official. **Experimental functions** @@ -109,11 +101,21 @@ Standardize output columns of functions with different output columns within ove * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` +* [#2908](https://github.com/pgRouting/pgrouting/issues/2908) + pgr_binaryBreadthFirstSearch + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + * [#2910](https://github.com/pgRouting/pgrouting/issues/2910) pgr_edwardMoore * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` +* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) + pgr_DAGshortestPath + + * Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)`` + Removal of SQL deprecated signatures ............................................................................... @@ -207,6 +209,10 @@ Related issues: [#2897](https://github.com/pgRouting/pgrouting/issues/2897) * _v4trsp(text,text,text,boolean) * _pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) * _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) + _pgr_dagshortestpath(text,text,boolean,boolean) +* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) + _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) * [#2861](https://github.com/pgRouting/pgrouting/issues/2861): @@ -253,5 +259,7 @@ Code enhancements * _v4trsp(text,text,anyarray,anyarray,boolean) * _v4trsp(text,text,text,boolean) * _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) +* [#2913](https://github.com/pgRouting/pgrouting/issues/2913) + _pgr_dagshortestpath diff --git a/doc/dagShortestPath/pgr_dagShortestPath.rst b/doc/dagShortestPath/pgr_dagShortestPath.rst index 005799c942..c380b282a7 100644 --- a/doc/dagShortestPath/pgr_dagShortestPath.rst +++ b/doc/dagShortestPath/pgr_dagShortestPath.rst @@ -27,15 +27,19 @@ In particular, the DAG shortest paths algorithm implemented by Boost.Graph. .. rubric:: Availability -* Version 3.2.0 +.. rubric:: Version 4.0.0 - * New experimental function. +* Output columns standardized to |short-generic-result| - * pgr_dagShortestPath(Combinations) +.. rubric:: Version 3.2.0 -* Version 3.0.0 +* New experimental function. - * New experimental function. + * pgr_dagShortestPath(Combinations) + +..rubric:: Version 3.0.0 + +* New experimental function. Description @@ -93,7 +97,7 @@ Signatures | pgr_dagShortestPath(`Edges SQL`_, **start vids**, **end vids**) | pgr_dagShortestPath(`Edges SQL`_, `Combinations SQL`_) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET @@ -108,7 +112,7 @@ One to One | pgr_dagShortestPath(`Edges SQL`_, **start vid**, **end vid**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertex :math:`5` to vertex :math:`11` on a **directed** graph @@ -128,7 +132,7 @@ One to Many | pgr_dagShortestPath(`Edges SQL`_, **start vid**, **end vids**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertex :math:`5` to vertices :math:`\{7, 11\}` @@ -148,7 +152,7 @@ Many to One | pgr_dagShortestPath(`Edges SQL`_, **start vids**, **end vid**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertices :math:`\{5, 10\}` to vertex :math:`11` @@ -168,7 +172,7 @@ Many to Many | pgr_dagShortestPath(`Edges SQL`_, **start vids**, **end vids**) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertices :math:`\{5, 15\}` to vertices :math:`\{11, 17\}` on an @@ -189,7 +193,7 @@ Combinations | pgr_dagShortestPath(`Edges SQL`_, `Combinations SQL`_) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: Using a combinations table on an **undirected** graph @@ -234,8 +238,8 @@ Return columns ------------------------------------------------------------------------------- .. include:: pgRouting-concepts.rst - :start-after: return_path_short_start - :end-before: return_path_short_end + :start-after: return_path_complete_start + :end-before: return_path_complete_end Additional Examples ------------------------------------------------------------------------------- diff --git a/doc/src/migration.rst b/doc/src/migration.rst index c1ba077b39..6456c24329 100644 --- a/doc/src/migration.rst +++ b/doc/src/migration.rst @@ -81,6 +81,10 @@ types. - `Migration of single path functions`_ * - .. versionchanged:: 4.0.0 :doc:`pgr_bellmanFord` [3]_ - `Migration of single path functions`_ + * - .. versionchanged:: 4.0.0 :doc:`pgr_binaryBreadthFirstSearch` [3]_ + - `Migration of single path functions`_ + * - .. versionchanged:: 4.0.0 :doc:`pgr_dagShortestPath` [3]_ + - `Migration of single path functions`_ * - .. versionchanged:: 4.0.0 :doc:`pgr_edwardMoore` [3]_ - `Migration of single path functions`_ * - .. versionchanged:: 4.0.0 :doc:`pgr_withPoints` [2]_ @@ -313,6 +317,9 @@ application. * - ``pgr_bellmanFord`` - v < 4.0 - |old-generic-result| + * - ``pgr_dagShortestPath`` + - v < 4.0 + - |result-1-1| * - ``pgr_edwardMoore`` - v < 4.0 - |old-generic-result| @@ -410,6 +417,24 @@ Before updating pgRouting enumerate the columns: |result-1-1| :start-after: --bdDijkstra-1-to-1-filter :end-before: --bdDijkstra-1-to-m +.. rubric:: Using ``pgr_DAGshortestPath`` + +Migrating `this v3.8 +`__ +example. + +.. literalinclude:: migration.queries + :start-after: --DAGshortestPath-1-to-1 + :end-before: --DAGshortestPath-1-to-1-filter + +Before updating pgRouting enumerate the columns: |result-1-1| + +.. literalinclude:: migration.queries + :start-after: --DAGshortestPath-1-to-1-filter + :end-before: --DAGshortestPath-END + +.. note:: This applies to all signatures of ``pgr_DAGshortestPath`` + Examples for One to Many with one route result ............................................................................... diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 0900f1d452..97bd782143 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -75,6 +75,9 @@ Functions promoted to official .. rubric:: Signatures promoted to official +`#2718 `__ + Make official the Combinations signature on the official functions + * pgr_aStar(Combinations) * pgr_aStarCost(Combinations) * pgr_bdAstar(Combinations) @@ -95,15 +98,8 @@ SQL signatures and output standardization `#2904 `__ Standardize output columns of functions with different output columns within overloads - .. rubric:: Official functions -* `#2906 `__ pgr_bdDijkstra - - .. include:: pgr_bdDijkstra.rst - :start-after: Version 4.0.0 - :end-before: .. rubric - * `#2905 `__ pgr_withPoints @@ -111,10 +107,9 @@ Standardize output columns of functions with different output columns within ove :start-after: Version 4.0.0 :end-before: .. rubric -* `#2905 `__ - pgr_withPointsCost +* `#2906 `__ pgr_bdDijkstra - .. include:: pgr_withPointsCost.rst + .. include:: pgr_bdDijkstra.rst :start-after: Version 4.0.0 :end-before: .. rubric @@ -127,6 +122,13 @@ Standardize output columns of functions with different output columns within ove :start-after: Version 4.0.0 :end-before: .. rubric +* `#2908 `__ + pgr_binaryBreadthFirstSearch + + .. include:: pgr_binaryBreadthFirstSearch.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + * `#2910 `__ pgr_edwardMoore @@ -134,6 +136,13 @@ Standardize output columns of functions with different output columns within ove :start-after: Version 4.0.0 :end-before: .. rubric +* `#2913 `__ + pgr_DAGshortestPath + + .. include:: pgr_dagShortestPath.rst + :start-after: Version 4.0.0 + :end-before: .. rubric + Removal of SQL deprecated signatures ............................................................................... @@ -227,6 +236,10 @@ Related issues: `#2897 `__ * _v4trsp(text,text,text,boolean) * _pgr_tspeuclidean(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) * _pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean) +* `#2913 `__ + _pgr_dagshortestpath(text,text,boolean,boolean) +* `#2913 `__ + _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) * `#2861 `__: @@ -273,6 +286,8 @@ Code enhancements * _v4trsp(text,text,anyarray,anyarray,boolean) * _v4trsp(text,text,text,boolean) * _pgr_withpointsdd(text,text,anyarray,double precision,boolean,character,boolean,boolean) +* `#2913 `__ + _pgr_dagshortestpath pgRouting 3 ******************************************************************************* diff --git a/doc/traversal/pgr_binaryBreadthFirstSearch.rst b/doc/traversal/pgr_binaryBreadthFirstSearch.rst index ebdedac726..0860396590 100644 --- a/doc/traversal/pgr_binaryBreadthFirstSearch.rst +++ b/doc/traversal/pgr_binaryBreadthFirstSearch.rst @@ -29,15 +29,19 @@ non-negative integer, is termed as a 'binary graph'. .. rubric:: Availability -* Version 3.2.0 +.. rubric:: Version 4.0.0 - * New experimental signature: +* Output columns standardized to |short-generic-result| - * pgr_binaryBreadthFirstSearch(Combinations) +.. rubric:: Version 3.2.0 -* Version 3.0.0 +* New experimental signature: - * New experimental function. + * pgr_binaryBreadthFirstSearch(Combinations) + +.. rubric:: Version 3.0.0 + +* New experimental function. Description ------------------------------------------------------------------------------- @@ -47,7 +51,7 @@ vertices can be found using Breadth First Search in :math:`O(|E|)` in an unweighted graph, i.e. the distance is the minimal number of edges that you need to traverse from the source to another vertex. We can interpret such a graph also as a weighted graph, where every edge has the weight :math:`1`. -If not alledges in graph have the same weight, that we need a more general +If not all edges in graph have the same weight, that we need a more general algorithm, like Dijkstra's Algorithm which runs in :math:`O(|E|log|V|)` time. However if the weights are more constrained, we can use a faster algorithm. @@ -87,7 +91,7 @@ Signatures | pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vids**, **end vids**, [``directed``]) | pgr_binaryBreadthFirstSearch(`Edges SQL`_, `Combinations SQL`_, [``directed``]) - | Returns set of |old-generic-result| + | Returns set of |short-generic-result| | OR EMPTY SET **Note:** Using the :doc:`sampledata` Network as all weights are same (i.e @@ -104,7 +108,7 @@ One to One | pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vid**, **end vid**, [``directed``]) - | Returns set of |result-1-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertex :math:`6` to vertex :math:`10` on a **directed** graph @@ -124,7 +128,7 @@ One to Many | pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vid**, **end vids**, [``directed``]) - | Returns set of |result-1-m| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertex :math:`6` to vertices :math:`\{10, 17\}` on a **directed** @@ -145,7 +149,7 @@ Many to One | pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vids**, **end vid**, [``directed``]) - | Returns set of |result-m-1| + | Returns set of |short-generic-result| | OR EMPTY SET :Example: From vertices :math:`\{6, 1\}` to vertex :math:`17` on a **directed** diff --git a/docqueries/dagShortestPath/dagShortestPath.result b/docqueries/dagShortestPath/dagShortestPath.result index ff51c63054..efc8f85ff2 100644 --- a/docqueries/dagShortestPath/dagShortestPath.result +++ b/docqueries/dagShortestPath/dagShortestPath.result @@ -6,62 +6,62 @@ SET SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 5, 11); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 (4 rows) /* -- q3 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 5, ARRAY[7, 11]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | -1 | 0 | 2 - 4 | 1 | 5 | 1 | 1 | 0 - 5 | 2 | 6 | 4 | 1 | 1 - 6 | 3 | 7 | 8 | 1 | 2 - 7 | 4 | 11 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 7 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 7 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 7 | 7 | -1 | 0 | 2 + 4 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 5 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 6 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 7 | 4 | 5 | 11 | 11 | -1 | 0 | 3 (7 rows) /* -- q4 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 10], 11); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 10 | 5 | 1 | 0 - 6 | 2 | 11 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 10 | 11 | 10 | 5 | 1 | 0 + 6 | 2 | 10 | 11 | 11 | -1 | 0 | 1 (6 rows) /* -- q5 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 15], ARRAY[11, 17]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 5 | 1 | 1 | 0 - 6 | 2 | 6 | 4 | 1 | 1 - 7 | 3 | 7 | 8 | 1 | 2 - 8 | 4 | 11 | 9 | 1 | 3 - 9 | 5 | 16 | 15 | 1 | 4 - 10 | 6 | 17 | -1 | 0 | 5 - 11 | 1 | 15 | 16 | 1 | 0 - 12 | 2 | 16 | 15 | 1 | 1 - 13 | 3 | 17 | -1 | 0 | 2 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 5 | 17 | 5 | 1 | 1 | 0 + 6 | 2 | 5 | 17 | 6 | 4 | 1 | 1 + 7 | 3 | 5 | 17 | 7 | 8 | 1 | 2 + 8 | 4 | 5 | 17 | 11 | 9 | 1 | 3 + 9 | 5 | 5 | 17 | 16 | 15 | 1 | 4 + 10 | 6 | 5 | 17 | 17 | -1 | 0 | 5 + 11 | 1 | 15 | 17 | 15 | 16 | 1 | 0 + 12 | 2 | 15 | 17 | 16 | 15 | 1 | 1 + 13 | 3 | 15 | 17 | 17 | -1 | 0 | 2 (13 rows) /* -- q51 */ @@ -79,58 +79,58 @@ SELECT source, target FROM combinations; SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 'SELECT source, target FROM combinations'); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 6 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 6 | 6 | -1 | 0 | 1 (2 rows) /* -- q6 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 10, 5, 10, 10, 5], ARRAY[11, 17, 17, 11]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 5 | 1 | 1 | 0 - 6 | 2 | 6 | 4 | 1 | 1 - 7 | 3 | 7 | 8 | 1 | 2 - 8 | 4 | 11 | 9 | 1 | 3 - 9 | 5 | 16 | 15 | 1 | 4 - 10 | 6 | 17 | -1 | 0 | 5 - 11 | 1 | 10 | 5 | 1 | 0 - 12 | 2 | 11 | -1 | 0 | 1 - 13 | 1 | 10 | 5 | 1 | 0 - 14 | 2 | 11 | 9 | 1 | 1 - 15 | 3 | 16 | 15 | 1 | 2 - 16 | 4 | 17 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 5 | 17 | 5 | 1 | 1 | 0 + 6 | 2 | 5 | 17 | 6 | 4 | 1 | 1 + 7 | 3 | 5 | 17 | 7 | 8 | 1 | 2 + 8 | 4 | 5 | 17 | 11 | 9 | 1 | 3 + 9 | 5 | 5 | 17 | 16 | 15 | 1 | 4 + 10 | 6 | 5 | 17 | 17 | -1 | 0 | 5 + 11 | 1 | 10 | 11 | 10 | 5 | 1 | 0 + 12 | 2 | 10 | 11 | 11 | -1 | 0 | 1 + 13 | 1 | 10 | 17 | 10 | 5 | 1 | 0 + 14 | 2 | 10 | 17 | 11 | 9 | 1 | 1 + 15 | 3 | 10 | 17 | 16 | 15 | 1 | 2 + 16 | 4 | 10 | 17 | 17 | -1 | 0 | 3 (16 rows) /* -- q7 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', ARRAY[5, 10, 11], ARRAY[5, 10, 11]); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 - 5 | 1 | 10 | 5 | 1 | 0 - 6 | 2 | 11 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 + 5 | 1 | 10 | 11 | 10 | 5 | 1 | 0 + 6 | 2 | 10 | 11 | 11 | -1 | 0 | 1 (6 rows) /* -- q8 */ SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edges', 'SELECT * FROM (VALUES (6, 10), (6, 7), (12, 10)) AS combinations (source, target)'); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 6 | 4 | 1 | 0 - 2 | 2 | 7 | -1 | 0 | 1 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 6 | 7 | 6 | 4 | 1 | 0 + 2 | 2 | 6 | 7 | 7 | -1 | 0 | 1 (2 rows) /* -- q9 */ diff --git a/docqueries/src/migration.result b/docqueries/src/migration.result index f7abbc293f..0dcf166b18 100644 --- a/docqueries/src/migration.result +++ b/docqueries/src/migration.result @@ -1593,12 +1593,12 @@ FROM pgr_bdDijkstra( SELECT * FROM pgr_DAGshortestPath( 'select id, source, target, cost from edges', 5, 11); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 5 | 1 | 1 | 0 - 2 | 2 | 6 | 4 | 1 | 1 - 3 | 3 | 7 | 8 | 1 | 2 - 4 | 4 | 11 | -1 | 0 | 3 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 5 | 11 | 5 | 1 | 1 | 0 + 2 | 2 | 5 | 11 | 6 | 4 | 1 | 1 + 3 | 3 | 5 | 11 | 7 | 8 | 1 | 2 + 4 | 4 | 5 | 11 | 11 | -1 | 0 | 3 (4 rows) /* --DAGshortestPath-1-to-1-filter */ diff --git a/docqueries/traversal/binaryBreadthFirstSearch.result b/docqueries/traversal/binaryBreadthFirstSearch.result index 051126fb36..0a72efb171 100644 --- a/docqueries/traversal/binaryBreadthFirstSearch.result +++ b/docqueries/traversal/binaryBreadthFirstSearch.result @@ -6,52 +6,52 @@ SET SELECT * FROM pgr_binaryBreadthFirstSearch( 'SELECT id, source, target, cost, reverse_cost from edges', 6, 10, true); - seq | path_seq | node | edge | cost | agg_cost ------+----------+------+------+------+---------- - 1 | 1 | 6 | 4 | 1 | 0 - 2 | 2 | 7 | 8 | 1 | 1 - 3 | 3 | 11 | 9 | 1 | 2 - 4 | 4 | 16 | 16 | 1 | 3 - 5 | 5 | 15 | 3 | 1 | 4 - 6 | 6 | 10 | -1 | 0 | 5 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 6 | 10 | 6 | 4 | 1 | 0 + 2 | 2 | 6 | 10 | 7 | 8 | 1 | 1 + 3 | 3 | 6 | 10 | 11 | 9 | 1 | 2 + 4 | 4 | 6 | 10 | 16 | 16 | 1 | 3 + 5 | 5 | 6 | 10 | 15 | 3 | 1 | 4 + 6 | 6 | 6 | 10 | 10 | -1 | 0 | 5 (6 rows) /* -- q2 */ SELECT * FROM pgr_binaryBreadthFirstSearch( 'SELECT id, source, target, cost, reverse_cost from edges', 6, ARRAY[10, 17]); - seq | path_seq | end_vid | node | edge | cost | agg_cost ------+----------+---------+------+------+------+---------- - 1 | 1 | 10 | 6 | 4 | 1 | 0 - 2 | 2 | 10 | 7 | 8 | 1 | 1 - 3 | 3 | 10 | 11 | 9 | 1 | 2 - 4 | 4 | 10 | 16 | 16 | 1 | 3 - 5 | 5 | 10 | 15 | 3 | 1 | 4 - 6 | 6 | 10 | 10 | -1 | 0 | 5 - 7 | 1 | 17 | 6 | 4 | 1 | 0 - 8 | 2 | 17 | 7 | 8 | 1 | 1 - 9 | 3 | 17 | 11 | 11 | 1 | 2 - 10 | 4 | 17 | 12 | 13 | 1 | 3 - 11 | 5 | 17 | 17 | -1 | 0 | 4 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 6 | 10 | 6 | 4 | 1 | 0 + 2 | 2 | 6 | 10 | 7 | 8 | 1 | 1 + 3 | 3 | 6 | 10 | 11 | 9 | 1 | 2 + 4 | 4 | 6 | 10 | 16 | 16 | 1 | 3 + 5 | 5 | 6 | 10 | 15 | 3 | 1 | 4 + 6 | 6 | 6 | 10 | 10 | -1 | 0 | 5 + 7 | 1 | 6 | 17 | 6 | 4 | 1 | 0 + 8 | 2 | 6 | 17 | 7 | 8 | 1 | 1 + 9 | 3 | 6 | 17 | 11 | 11 | 1 | 2 + 10 | 4 | 6 | 17 | 12 | 13 | 1 | 3 + 11 | 5 | 6 | 17 | 17 | -1 | 0 | 4 (11 rows) /* -- q3 */ SELECT * FROM pgr_binaryBreadthFirstSearch( 'SELECT id, source, target, cost, reverse_cost from edges', ARRAY[6, 1], 17); - seq | path_seq | start_vid | node | edge | cost | agg_cost ------+----------+-----------+------+------+------+---------- - 1 | 1 | 1 | 1 | 6 | 1 | 0 - 2 | 2 | 1 | 3 | 7 | 1 | 1 - 3 | 3 | 1 | 7 | 8 | 1 | 2 - 4 | 4 | 1 | 11 | 11 | 1 | 3 - 5 | 5 | 1 | 12 | 13 | 1 | 4 - 6 | 6 | 1 | 17 | -1 | 0 | 5 - 7 | 1 | 6 | 6 | 4 | 1 | 0 - 8 | 2 | 6 | 7 | 8 | 1 | 1 - 9 | 3 | 6 | 11 | 11 | 1 | 2 - 10 | 4 | 6 | 12 | 13 | 1 | 3 - 11 | 5 | 6 | 17 | -1 | 0 | 4 + seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost +-----+----------+-----------+---------+------+------+------+---------- + 1 | 1 | 1 | 17 | 1 | 6 | 1 | 0 + 2 | 2 | 1 | 17 | 3 | 7 | 1 | 1 + 3 | 3 | 1 | 17 | 7 | 8 | 1 | 2 + 4 | 4 | 1 | 17 | 11 | 11 | 1 | 3 + 5 | 5 | 1 | 17 | 12 | 13 | 1 | 4 + 6 | 6 | 1 | 17 | 17 | -1 | 0 | 5 + 7 | 1 | 6 | 17 | 6 | 4 | 1 | 0 + 8 | 2 | 6 | 17 | 7 | 8 | 1 | 1 + 9 | 3 | 6 | 17 | 11 | 11 | 1 | 2 + 10 | 4 | 6 | 17 | 12 | 13 | 1 | 3 + 11 | 5 | 6 | 17 | 17 | -1 | 0 | 4 (11 rows) /* -- q4 */ diff --git a/include/c_types/metrics_rt.h b/include/c_types/metrics_rt.h new file mode 100644 index 0000000000..1ceab37263 --- /dev/null +++ b/include/c_types/metrics_rt.h @@ -0,0 +1,47 @@ +/*PGR-GNU***************************************************************** +File: metrics_rt.h + +Copyright (c) 2025 pgRouting developers +Mail: project@pgrouting.org + +Function's developer: +Copyright (c) 2025 Saloni Kumari +Mail: chaudharysaloni2510 at gmail.com + +------ + +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*/ +#ifndef INCLUDE_C_TYPES_METRICS_RT_H_ +#define INCLUDE_C_TYPES_METRICS_RT_H_ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct { + int64_t node; + double metric_value; +} Metrics_rt; + +#ifdef __cplusplus +} +#endif + +#endif // INCLUDE_C_TYPES_METRICS_RT_H_ \ No newline at end of file diff --git a/include/drivers/metrics_driver.hpp b/include/drivers/metrics_driver.hpp index 0697859a84..97b35e15ea 100644 --- a/include/drivers/metrics_driver.hpp +++ b/include/drivers/metrics_driver.hpp @@ -38,11 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include -struct Metrics_rt { - int64_t node; - double metric_value; -}; - +#include "c_types/metrics_rt.h" void do_metrics( std::string, diff --git a/include/metrics/bandwidth.hpp b/include/metrics/bandwidth.hpp index 72a4fa5822..45385e8b5f 100644 --- a/include/metrics/bandwidth.hpp +++ b/include/metrics/bandwidth.hpp @@ -4,6 +4,7 @@ File: bandwidth.hpp Copyright (c) 2025 pgRouting developers Mail: project@pgrouting.org +Developers: Copyright (c) 2025 Saloni Kumari Mail: chaudharysaloni2510 at gmail.com @@ -51,10 +52,8 @@ int bandwidth(const G &graph) { int bw = std::numeric_limits::max(); - // We need a vertex index map for consistent ordering auto index_map = boost::get(boost::vertex_index, graph.graph); - // Loop over all edges to compute max absolute difference of vertex indices typename boost::graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = boost::edges(graph.graph); ei != ei_end; ++ei) { Vertex u = boost::source(*ei, graph.graph); @@ -66,7 +65,6 @@ int bandwidth(const G &graph) { } } - // If graph has no edges, bandwidth is zero if (bw == std::numeric_limits::max()) { bw = 0; } diff --git a/include/process/metrics_process.h b/include/process/metrics_process.h index d3f2d4866d..81d54e7800 100644 --- a/include/process/metrics_process.h +++ b/include/process/metrics_process.h @@ -36,20 +36,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #endif -#include "c_types/graph_bandwidth_rt.h" - -#include "cpp_common/edge_t.hpp" +#include "c_types/bandwidth_rt.h" #ifdef __cplusplus extern "C" { #endif -void pgr_process_bandwidth( - const Edge_t* edges_sql, +void pgr_process_metrics( + const char* edges_sql, GraphBandwidth_rt** result_tuples, size_t* result_count, char** log_msg, - char** notice_msg); + char** notice_msg +); #ifdef __cplusplus } diff --git a/locale/en/LC_MESSAGES/pgrouting_doc_strings.po b/locale/en/LC_MESSAGES/pgrouting_doc_strings.po index f94e240c5e..0497d97b39 100644 --- a/locale/en/LC_MESSAGES/pgrouting_doc_strings.po +++ b/locale/en/LC_MESSAGES/pgrouting_doc_strings.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: pgRouting v3.8\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-12 15:41+0000\n" +"POT-Creation-Date: 2025-06-16 16:56+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3971,6 +3971,12 @@ msgstr "" msgid "Signatures promoted to official" msgstr "" +msgid "`#2718 `__" +msgstr "" + +msgid "Make official the Combinations signature on the official functions" +msgstr "" + msgid "pgr_aStar(Combinations)" msgstr "" @@ -4022,18 +4028,18 @@ msgstr "" msgid "Official functions" msgstr "" -msgid "" -"`#2906 `__ " -"pgr_bdDijkstra" +msgid "`#2905 `__" msgstr "" -msgid "Combinations signature promoted to official." +msgid "pgr_withPoints" msgstr "" -msgid "`#2905 `__" +msgid "" +"`#2906 `__ " +"pgr_bdDijkstra" msgstr "" -msgid "pgr_withPoints" +msgid "Combinations signature promoted to official." msgstr "" msgid "" @@ -4041,11 +4047,21 @@ msgid "" "pgr_bellmanFord" msgstr "" +msgid "" +"`#2908 `__ " +"pgr_binaryBreadthFirstSearch" +msgstr "" + msgid "" "`#2910 `__ " "pgr_edwardMoore" msgstr "" +msgid "" +"`#2913 `__ " +"pgr_DAGshortestPath" +msgstr "" + msgid "Removal of SQL deprecated signatures" msgstr "" @@ -4272,6 +4288,16 @@ msgid "" "precision,double precision,boolean)" msgstr "" +msgid "" +"`#2913 `__ " +"_pgr_dagshortestpath(text,text,boolean,boolean)" +msgstr "" + +msgid "" +"`#2913 `__ " +"_pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean)" +msgstr "" + msgid "" "`#2861 `__: Remove " "unused internal functions" @@ -4355,6 +4381,11 @@ msgstr "" msgid "Internal C/C++ functions in legacy" msgstr "" +msgid "" +"`#2913 `__ " +"_pgr_dagshortestpath" +msgstr "" + msgid "All releases" msgstr "" @@ -4469,6 +4500,12 @@ msgstr "" msgid ":doc:`pgr_bellmanFord` [3]_" msgstr "" +msgid ":doc:`pgr_binaryBreadthFirstSearch` [3]_" +msgstr "" + +msgid ":doc:`pgr_dagShortestPath` [3]_" +msgstr "" + msgid ":doc:`pgr_edwardMoore` [3]_" msgstr "" @@ -4671,6 +4708,12 @@ msgstr "" msgid "``pgr_bellmanFord``" msgstr "" +msgid "``pgr_dagShortestPath``" +msgstr "" + +msgid "|result-1-1|" +msgstr "" + msgid "``pgr_edwardMoore``" msgstr "" @@ -4750,6 +4793,18 @@ msgid "" "example." msgstr "" +msgid "Using ``pgr_DAGshortestPath``" +msgstr "" + +msgid "" +"Migrating `this v3.8 " +"`__ example." +msgstr "" + +msgid "This applies to all signatures of ``pgr_DAGshortestPath``" +msgstr "" + msgid "Examples for One to Many with one route result" msgstr "" @@ -8947,9 +9002,9 @@ msgid "" "in an unweighted graph, i.e. the distance is the minimal number of edges " "that you need to traverse from the source to another vertex. We can " "interpret such a graph also as a weighted graph, where every edge has the" -" weight :math:`1`. If not alledges in graph have the same weight, that we" -" need a more general algorithm, like Dijkstra's Algorithm which runs in " -":math:`O(|E|log|V|)` time." +" weight :math:`1`. If not all edges in graph have the same weight, that " +"we need a more general algorithm, like Dijkstra's Algorithm which runs in" +" :math:`O(|E|log|V|)` time." msgstr "" #, python-brace-format @@ -9002,15 +9057,6 @@ msgid "" "(i.e :math:`1``)" msgstr "" -msgid "Returns set of |result-1-1|" -msgstr "" - -msgid "Returns set of |result-1-m|" -msgstr "" - -msgid "Returns set of |result-m-1|" -msgstr "" - msgid "" "`Boost: Breadth First Search " "`__" @@ -10464,6 +10510,9 @@ msgstr "" msgid "pgr_dagShortestPath(Combinations)" msgstr "" +msgid "..rubric:: Version 3.0.0" +msgstr "" + msgid "" "Shortest Path for Directed Acyclic Graph(DAG) is a graph search algorithm" " that solves the shortest path problem for weighted directed acyclic " diff --git a/locale/pot/pgrouting_doc_strings.pot b/locale/pot/pgrouting_doc_strings.pot index 2fc58898b4..148341765b 100644 --- a/locale/pot/pgrouting_doc_strings.pot +++ b/locale/pot/pgrouting_doc_strings.pot @@ -8,11 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: pgRouting v4.0\n" "Report-Msgid-Bugs-To: \n" -<<<<<<< HEAD -"POT-Creation-Date: 2025-06-09 15:35+0000\n" -======= -"POT-Creation-Date: 2025-06-12 15:41+0000\n" ->>>>>>> pgr/develop +"POT-Creation-Date: 2025-06-16 16:56+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3110,9 +3106,6 @@ msgstr "" msgid ":doc:`pgr_betweennessCentrality` - Calculates relative betweenness centrality using Brandes Algorithm" msgstr "" -msgid ":doc:`pgr_bandwidth` - Computes the bandwidth of a graph." -msgstr "" - msgid ":doc:`TRSP-family`" msgstr "" @@ -3566,6 +3559,12 @@ msgstr "" msgid "Signatures promoted to official" msgstr "" +msgid "`#2718 `__" +msgstr "" + +msgid "Make official the Combinations signature on the official functions" +msgstr "" + msgid "pgr_aStar(Combinations)" msgstr "" @@ -3614,24 +3613,30 @@ msgstr "" msgid "Official functions" msgstr "" -msgid "`#2906 `__ pgr_bdDijkstra" +msgid "`#2905 `__" msgstr "" -msgid "Combinations signature promoted to official." +msgid "pgr_withPoints" msgstr "" -msgid "`#2905 `__" +msgid "`#2906 `__ pgr_bdDijkstra" msgstr "" -msgid "pgr_withPoints" +msgid "Combinations signature promoted to official." msgstr "" msgid "`#2907 `__ pgr_bellmanFord" msgstr "" +msgid "`#2908 `__ pgr_binaryBreadthFirstSearch" +msgstr "" + msgid "`#2910 `__ pgr_edwardMoore" msgstr "" +msgid "`#2913 `__ pgr_DAGshortestPath" +msgstr "" + msgid "Removal of SQL deprecated signatures" msgstr "" @@ -3806,6 +3811,12 @@ msgstr "" msgid "_pgr_tsp(text,bigint,bigint,double precision,integer,integer,integer,double precision,double precision,double precision,boolean)" msgstr "" +msgid "`#2913 `__ _pgr_dagshortestpath(text,text,boolean,boolean)" +msgstr "" + +msgid "`#2913 `__ _pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean)" +msgstr "" + msgid "`#2861 `__: Remove unused internal functions" msgstr "" @@ -3887,6 +3898,9 @@ msgstr "" msgid "Internal C/C++ functions in legacy" msgstr "" +msgid "`#2913 `__ _pgr_dagshortestpath" +msgstr "" + msgid "All releases" msgstr "" @@ -3989,15 +4003,18 @@ msgstr "" msgid ":doc:`pgr_bdDijkstra` [1]_" msgstr "" -<<<<<<< HEAD -======= msgid ":doc:`pgr_bellmanFord` [3]_" msgstr "" +msgid ":doc:`pgr_binaryBreadthFirstSearch` [3]_" +msgstr "" + +msgid ":doc:`pgr_dagShortestPath` [3]_" +msgstr "" + msgid ":doc:`pgr_edwardMoore` [3]_" msgstr "" ->>>>>>> pgr/develop msgid ":doc:`pgr_withPoints` [2]_" msgstr "" @@ -4016,12 +4033,9 @@ msgstr "" msgid "Official function in v4.0.0" msgstr "" -<<<<<<< HEAD -======= msgid "Experimental or proposed in v4.0.0" msgstr "" ->>>>>>> pgr/develop msgid "Migration of cost functions" msgstr "" @@ -4133,29 +4147,12 @@ msgstr "" msgid "THe standardized :ref:`pgRouting-concepts:Result columns for single path functions` are |short-generic-result|" msgstr "" -<<<<<<< HEAD -msgid "``pgr_aStar``" -msgstr "" - -msgid "v < 3.6" -msgstr "" - -msgid "|old-generic-result|" -msgstr "" - -======= ->>>>>>> pgr/develop msgid "``pgr_dijkstra``" msgstr "" msgid "v < 3.5" msgstr "" -<<<<<<< HEAD -msgid "``pgr_bdDijkstra``" -msgstr "" - -======= msgid "|old-generic-result|" msgstr "" @@ -4171,10 +4168,15 @@ msgstr "" msgid "``pgr_bellmanFord``" msgstr "" +msgid "``pgr_dagShortestPath``" +msgstr "" + +msgid "|result-1-1|" +msgstr "" + msgid "``pgr_edwardMoore``" msgstr "" ->>>>>>> pgr/develop msgid "``pgr_withPoints``" msgstr "" @@ -4241,6 +4243,15 @@ msgstr "" msgid "Migrating `this v3.8 `__ example." msgstr "" +msgid "Using ``pgr_DAGshortestPath``" +msgstr "" + +msgid "Migrating `this v3.8 `__ example." +msgstr "" + +msgid "This applies to all signatures of ``pgr_DAGshortestPath``" +msgstr "" + msgid "Examples for One to Many with one route result" msgstr "" @@ -6626,7 +6637,7 @@ msgstr "" msgid "Individuals (in alphabetical order)" msgstr "" -msgid "Aasheesh Tiwari, Abhinav Jain, Aditya Pratap Singh, Adrien Berchet, Akio Takubo, Andrea Nardelli, Anthony Tasca, Anton Patrushev, Aryan Gupta, Ashraf Hossain, Ashish Kumar, Aurélie Bousquet, Cayetano Benavent, Christian Gonzalez, Daniel Kastl, Dapeng Wang, Dave Potts, David Techer, Denis Rykov, Ema Miyawaki, Esteban Zimanyi, Florian Thurkow, Frederic Junod, Gerald Fenoy, Gudesa Venkata Sai Akhil, Hang Wu, Himanshu Raj, Imre Samu, Jay Mahadeokar, Jinfu Leng, Kai Behncke, Kishore Kumar, Ko Nagase, Mahmoud Sakr, Manikata Kondeti, Mario Basa, Martin Wiesenhaan, Maxim Dubinin, Maoguang Wang, Mohamed Bakli, Mohamed Zia, Mukul Priya, Nitish Chauhan, Rajat Shinde, Razequl Islam, Regina Obe, Rohith Reddy, Saloni Kumari, Sarthak Agarwal, Shobhit Chaurasia, Sourabh Garg, Stephen Woodbridge, Swapnil Joshi, Sylvain Housseman, Sylvain Pasche, Veenit Kumar, Vidhan Jain, Virginia Vergara, Yige Huang" +msgid "Aasheesh Tiwari, Abhinav Jain, Aditya Pratap Singh, Adrien Berchet, Akio Takubo, Andrea Nardelli, Anthony Tasca, Anton Patrushev, Aryan Gupta, Ashraf Hossain, Ashish Kumar, Aurélie Bousquet, Cayetano Benavent, Christian Gonzalez, Daniel Kastl, Dapeng Wang, Dave Potts, David Techer, Denis Rykov, Ema Miyawaki, Esteban Zimanyi, Florian Thurkow, Frederic Junod, Gerald Fenoy, Gudesa Venkata Sai Akhil, Hang Wu, Himanshu Raj, Imre Samu, Jay Mahadeokar, Jinfu Leng, Kai Behncke, Kishore Kumar, Ko Nagase, Mahmoud Sakr, Manikata Kondeti, Mario Basa, Martin Wiesenhaan, Maxim Dubinin, Maoguang Wang, Mohamed Bakli, Mohamed Zia, Mukul Priya, Nitish Chauhan, Rajat Shinde, Razequl Islam, Regina Obe, Rohith Reddy, Sarthak Agarwal, Shobhit Chaurasia, Sourabh Garg, Stephen Woodbridge, Swapnil Joshi, Sylvain Housseman, Sylvain Pasche, Veenit Kumar, Vidhan Jain, Virginia Vergara, Yige Huang" msgstr "" msgid "Corporate Sponsors (in alphabetical order)" @@ -7604,21 +7615,6 @@ msgstr "" msgid "pgr_bellmanFord(`Edges SQL`_, `Combinations SQL`_, [``directed``])" msgstr "" -<<<<<<< HEAD -msgid "Returns set of |result-1-1|" -msgstr "" - -msgid "Returns set of |result-1-m|" -msgstr "" - -msgid "Returns set of |result-m-1|" -msgstr "" - -msgid "Using a combinations table on an **undirected** graph." -msgstr "" - -======= ->>>>>>> pgr/develop msgid "`Boost: Bellman Ford `__" msgstr "" @@ -7754,7 +7750,7 @@ msgstr "" msgid "pgr_binaryBreadthFirstSearch(Combinations)" msgstr "" -msgid "It is well-known that the shortest paths between a single source and all other vertices can be found using Breadth First Search in :math:`O(|E|)` in an unweighted graph, i.e. the distance is the minimal number of edges that you need to traverse from the source to another vertex. We can interpret such a graph also as a weighted graph, where every edge has the weight :math:`1`. If not alledges in graph have the same weight, that we need a more general algorithm, like Dijkstra's Algorithm which runs in :math:`O(|E|log|V|)` time." +msgid "It is well-known that the shortest paths between a single source and all other vertices can be found using Breadth First Search in :math:`O(|E|)` in an unweighted graph, i.e. the distance is the minimal number of edges that you need to traverse from the source to another vertex. We can interpret such a graph also as a weighted graph, where every edge has the weight :math:`1`. If not all edges in graph have the same weight, that we need a more general algorithm, like Dijkstra's Algorithm which runs in :math:`O(|E|log|V|)` time." msgstr "" msgid "However if the weights are more constrained, we can use a faster algorithm. This algorithm, termed as 'Binary Breadth First Search' as well as '0-1 BFS', is a variation of the standard Breadth First Search problem to solve the SSSP (single-source shortest path) problem in :math:`O(|E|)`, if the weights of each edge belongs to the set {0,X}, where 'X' is any non-negative real integer." @@ -7784,15 +7780,6 @@ msgstr "" msgid "**Note:** Using the :doc:`sampledata` Network as all weights are same (i.e :math:`1``)" msgstr "" -msgid "Returns set of |result-1-1|" -msgstr "" - -msgid "Returns set of |result-1-m|" -msgstr "" - -msgid "Returns set of |result-m-1|" -msgstr "" - msgid "`Boost: Breadth First Search `__" msgstr "" @@ -8966,6 +8953,9 @@ msgstr "" msgid "pgr_dagShortestPath(Combinations)" msgstr "" +msgid "..rubric:: Version 3.0.0" +msgstr "" + msgid "Shortest Path for Directed Acyclic Graph(DAG) is a graph search algorithm that solves the shortest path problem for weighted directed acyclic graph, producing a shortest path from a starting vertex (``start_vid``) to an ending vertex (``end_vid``)." msgstr "" @@ -10139,11 +10129,7 @@ msgstr "" msgid "pgr_edwardMoore(`Edges SQL`_, `Combinations SQL`_, [``directed``])" msgstr "" -<<<<<<< HEAD -msgid "From vertex :math:`6` to vertices :math:`\\{ 10, 17\\}` on a **directed** graph" -======= msgid "Using a combinations table on an **undirected** graph." ->>>>>>> pgr/develop msgstr "" msgid "https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm" diff --git a/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg b/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg index 38ec79a805..65acdb17c1 100644 --- a/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg +++ b/pgtap/others/dagShortestPath/edge_cases/empty_combinations_empty_result.pg @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; +UPDATE edges SET cost = sign(cost), reverse_cost = -1 * sign(cost); SELECT plan(1); CREATE OR REPLACE FUNCTION empty_combinations() @@ -26,18 +27,19 @@ RETURNS SETOF TEXT AS $BODY$ BEGIN - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations signature is new on 3.2.0'); + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); RETURN; END IF; - RETURN query SELECT is_empty( - 'SELECT seq, path_seq, node, edge, cost, agg_cost FROM pgr_dagShortestPath( - ''SELECT id, source, target, cost FROM edges'', - ''SELECT * FROM combinations WHERE source IN (-1)'' ) ' - ); - RETURN; + RETURN query SELECT is_empty( + $$ + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dagShortestPath( + 'SELECT id, source, target, cost FROM edges', + 'SELECT * FROM combinations WHERE source IN (-1)') + $$ + ); + END $BODY$ language plpgsql; diff --git a/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg b/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg index 8f0c4bad8f..7454b24252 100644 --- a/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg +++ b/pgtap/others/dagShortestPath/edge_cases/many_to_many_eq_combinations.pg @@ -21,6 +21,7 @@ BEGIN; SELECT plan(1); +UPDATE edges SET cost = sign(cost), reverse_cost = -1 * sign(cost); UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id; CREATE OR REPLACE FUNCTION eq_many( sql_TestFunction TEXT, cant INTEGER default 18 ) @@ -30,13 +31,12 @@ DECLARE sql_Combinations TEXT; sql_Many TEXT; BEGIN - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations signature is new on 3.2.0'); + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); RETURN; END IF; - sql_Combinations := ''; sql_Many := ''; FOR i IN 1.. cant LOOP @@ -69,8 +69,7 @@ END $BODY$ language plpgsql; -SELECT * FROM eq_many('SELECT path_seq, node, edge, cost, agg_cost FROM pgr_dagShortestPath'); +SELECT eq_many('SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost FROM pgr_dagShortestPath'); --- Finish the tests and clean up. SELECT * FROM finish(); ROLLBACK; diff --git a/pgtap/others/dagShortestPath/inner_query.pg b/pgtap/others/dagShortestPath/inner_query.pg index 9cb16839c6..22d997005f 100644 --- a/pgtap/others/dagShortestPath/inner_query.pg +++ b/pgtap/others/dagShortestPath/inner_query.pg @@ -19,31 +19,33 @@ 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 min_version('3.2.0') THEN plan(132) ELSE plan(98) END; - --- TODO the column has to be dropped because it creates a cycle when cost and reverse cost both have positive values -ALTER TABLE edges DROP COLUMN reverse_cost; - --- ONE TO ONE -SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, 3)'); --- ONE TO MANY -SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, ARRAY[3])'); --- MANY TO ONE -SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], 3)'); --- MANY TO MANY -SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], ARRAY[3])'); - --- COMBINATIONS +UPDATE edges SET cost = sign(cost), reverse_cost = -1 * sign(cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(132) ELSE plan(1) END; + CREATE OR REPLACE FUNCTION inner_query() RETURNS SETOF TEXT AS $BODY$ +DECLARE +params TEXT[]; +subs TEXT[]; BEGIN - IF min_version('3.2.0') THEN - RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', $$SELECT * FROM combinations$$)'); - RETURN QUERY SELECT innerquery_combinations('pgr_dagshortestpath($$SELECT * FROM edges$$,',')'); - ELSE - RETURN QUERY SELECT skip(2, 'Combinations signature added on 3.2.0'); + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); + RETURN; END IF; + + -- ONE TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, 3)'); + -- ONE TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', 2, ARRAY[3])'); + -- MANY TO ONE + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], 3)'); + -- MANY TO MANY + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', ARRAY[2], ARRAY[3])'); + + RETURN QUERY SELECT style_dijkstra('pgr_dagshortestpath(', ', $$SELECT * FROM combinations$$)'); + RETURN QUERY SELECT innerquery_combinations('pgr_dagshortestpath($$SELECT * FROM edges$$,',')'); + END $BODY$ LANGUAGE plpgsql VOLATILE; diff --git a/pgtap/others/dagShortestPath/no_crash_test.pg b/pgtap/others/dagShortestPath/no_crash_test.pg index d869863d1a..ce2901a643 100644 --- a/pgtap/others/dagShortestPath/no_crash_test.pg +++ b/pgtap/others/dagShortestPath/no_crash_test.pg @@ -19,8 +19,8 @@ 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 min_version('3.2.0') THEN plan(81) ELSE plan(68) END; +UPDATE edges SET cost = sign(cost), reverse_cost = -sign(cost); +SELECT CASE WHEN min_version('4.0.0') THEN plan(81) ELSE plan(1) END; CREATE OR REPLACE FUNCTION no_crash() RETURNS SETOF TEXT AS @@ -29,6 +29,12 @@ DECLARE params TEXT[]; subs TEXT[]; BEGIN + + IF NOT min_version('4.0.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_DAGshortestPath return columns are standardized on v4.0.0'); + RETURN; + END IF; + PREPARE edges AS SELECT id, source, target, cost FROM edges; @@ -118,12 +124,6 @@ BEGIN ]::TEXT[]; RETURN query SELECT * FROM no_crash_test('pgr_dagShortestPath', params, subs); - IF NOT min_version('3.2.0') THEN - RETURN QUERY - SELECT skip(1, 'Combinations signature is new on 3.2.0'); - RETURN; - END IF; - PREPARE combinations AS SELECT source, target FROM combinations; diff --git a/pgtap/others/dagShortestPath/types_check.pg b/pgtap/others/dagShortestPath/types_check.pg index 469f474e06..aa1493e773 100644 --- a/pgtap/others/dagShortestPath/types_check.pg +++ b/pgtap/others/dagShortestPath/types_check.pg @@ -17,91 +17,12 @@ 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; - -SELECT plan(13); - -CREATE OR REPLACE FUNCTION types_check() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - - RETURN QUERY SELECT has_function('pgr_dagshortestpath'); - - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'bigint' ]); - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'bigint' ]); - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'anyarray' ]); - RETURN QUERY SELECT has_function('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'anyarray' ]); - - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'bigint' ], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'bigint' ], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'bigint', 'anyarray' ], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_dagshortestpath', ARRAY[ 'text', 'anyarray', 'anyarray' ], 'setof record'); - RETURN QUERY - SELECT CASE - WHEN min_version('3.2.0') THEN - collect_tap( - has_function('pgr_dagshortestpath', ARRAY['text','text']), - function_returns('pgr_dagshortestpath', ARRAY['text','text'], 'setof record') - ) - ELSE - skip(2, 'Combinations functiontionality new on 3.2.0') - END; - - RETURN QUERY - SELECT CASE - WHEN min_version('3.2.0') THEN - collect_tap( - - function_args_eq('pgr_dagshortestpath', - $$VALUES - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","",seq,path_seq,node,edge,cost,agg_cost}'::TEXT[]) - $$ - ), - function_types_eq('pgr_dagshortestpath', - $$VALUES - ('{text,int8,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,int8,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,text,int4,int4,int8,int8,float8,float8}') - $$ - ) - ) - - ELSE - - collect_tap( - - function_args_eq('pgr_dagshortestpath', - $$VALUES - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]) - $$ - ), - function_types_eq('pgr_dagshortestpath', - $$VALUES - ('{text,int8,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,int8,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,int8,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,anyarray,int4,int4,int8,int8,float8,float8}'::TEXT[]) - $$ - ) - ) - END; +BEGIN; -END; -$BODY$ -LANGUAGE plpgsql; +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; -SELECT types_check(); +SELECT single_path_types_check('pgr_dagshortestpath', '{}'::TEXT[], '{}'::TEXT[], standard_v => '4.0.0'); SELECT finish(); ROLLBACK; diff --git a/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg b/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg index 085e982820..d5f9e6b817 100644 --- a/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg +++ b/pgtap/traversal/binaryBreadthFirstSearch/types_check.pg @@ -19,90 +19,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ BEGIN; -SELECT plan (13); +SELECT CASE WHEN min_version('4.0.0') THEN plan(13) WHEN min_version('3.2.0') THEN plan(12) ELSE PLAN(10) END; -CREATE OR REPLACE FUNCTION types_check() -RETURNS SETOF TEXT AS -$BODY$ -BEGIN - - RETURN QUERY - SELECT has_function('pgr_binarybreadthfirstsearch'); - - RETURN QUERY SELECT has_function('pgr_binarybreadthfirstsearch', ARRAY['text','bigint','bigint','boolean']); - RETURN QUERY SELECT has_function('pgr_binarybreadthfirstsearch', ARRAY['text','bigint','anyarray','boolean']); - RETURN QUERY SELECT has_function('pgr_binarybreadthfirstsearch', ARRAY['text','anyarray','bigint','boolean']); - RETURN QUERY SELECT has_function('pgr_binarybreadthfirstsearch', ARRAY['text','anyarray','anyarray','boolean']); - - RETURN QUERY SELECT function_returns('pgr_binarybreadthfirstsearch', ARRAY['text','bigint','bigint','boolean'], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_binarybreadthfirstsearch', ARRAY['text','bigint','anyarray','boolean'], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_binarybreadthfirstsearch', ARRAY['text','anyarray','bigint','boolean'], 'setof record'); - RETURN QUERY SELECT function_returns('pgr_binarybreadthfirstsearch', ARRAY['text','anyarray','anyarray','boolean'], 'setof record'); - - RETURN QUERY - SELECT CASE - WHEN min_version('3.2.0') THEN - collect_tap( - has_function('pgr_binarybreadthfirstsearch', ARRAY['text','text','boolean']), - function_returns('pgr_binarybreadthfirstsearch', ARRAY['text','text','boolean'], 'setof record') - ) - ELSE - skip(2, 'Combinations functiontionality new on 3.2.0') - END; - - RETURN QUERY - SELECT CASE - WHEN min_version('3.2.0') THEN - collect_tap( - - function_args_eq('pgr_binarybreadthfirstsearch', - $$VALUES - ('{"","","","directed","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","seq","path_seq","start_vid","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","seq","path_seq","end_vid","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","seq","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","directed","seq","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[]) - $$ - ), - - function_types_eq('pgr_binarybreadthfirstsearch', - $$VALUES - ('{text,int8,int8,bool,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,int8,anyarray,bool,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,int8,bool,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,anyarray,bool,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]), - ('{text,text,bool,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]) - $$ - ) - ) - ELSE - collect_tap( - - function_args_eq('pgr_binarybreadthfirstsearch', - $$VALUES - ('{"","","","directed","seq","path_seq","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","seq","path_seq","start_vid","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","seq","path_seq","end_vid","node","edge","cost","agg_cost"}'::TEXT[]), - ('{"","","","directed","seq","path_seq","start_vid","end_vid","node","edge","cost","agg_cost"}'::TEXT[]) - $$ - ), - - function_types_eq('pgr_binarybreadthfirstsearch', - $$VALUES - ('{text,int8,int8,bool,int4,int4,int8,int8,float8,float8}'::TEXT[]), - ('{text,int8,anyarray,bool,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,int8,bool,int4,int4,int8,int8,int8,float8,float8}'::TEXT[]), - ('{text,anyarray,anyarray,bool,int4,int4,int8,int8,int8,int8,float8,float8}'::TEXT[]) - $$ - ) - ) - END; - -END; -$BODY$ -LANGUAGE plpgsql; - -SELECT types_check(); +SELECT single_path_types_check('pgr_binarybreadthfirstsearch', standard_v => '4.0.0'); SELECT * FROM finish(); ROLLBACK; diff --git a/sql/breadthFirstSearch/binaryBreadthFirstSearch.sql b/sql/breadthFirstSearch/binaryBreadthFirstSearch.sql index cc44730d11..f57372a3df 100644 --- a/sql/breadthFirstSearch/binaryBreadthFirstSearch.sql +++ b/sql/breadthFirstSearch/binaryBreadthFirstSearch.sql @@ -5,7 +5,7 @@ Copyright (c) 2019 pgRouting developers Mail: project@pgrouting.org Copyright (c) 2019 Gudesa Venkata Sai Akhil -Mail: gvs.akhil1997@gmail.com +Mail: gvs.akhil1997 at gmail.com ------ @@ -24,9 +24,6 @@ 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*/ ---------------- --- pgr_binaryBreadthFirstSearch ---------------- -- ONE to ONE --v3.0 @@ -39,14 +36,16 @@ CREATE FUNCTION pgr_binaryBreadthFirstSearch( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], $4); $BODY$ LANGUAGE sql VOLATILE STRICT; @@ -62,6 +61,7 @@ CREATE FUNCTION pgr_binaryBreadthFirstSearch( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, @@ -69,8 +69,8 @@ CREATE FUNCTION pgr_binaryBreadthFirstSearch( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.end_vid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], $4); $BODY$ LANGUAGE sql VOLATILE STRICT; @@ -87,14 +87,15 @@ CREATE FUNCTION pgr_binaryBreadthFirstSearch( OUT seq INTEGER, OUT path_seq INTEGER, OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.start_vid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], $4); $BODY$ LANGUAGE sql VOLATILE STRICT; @@ -118,8 +119,8 @@ CREATE FUNCTION pgr_binaryBreadthFirstSearch( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.start_vid, a.end_vid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], $4); $BODY$ LANGUAGE sql VOLATILE STRICT; @@ -142,12 +143,11 @@ CREATE FUNCTION pgr_binaryBreadthFirstSearch( OUT agg_cost FLOAT) RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.start_vid, a.end_vid, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), _pgr_get_statement($2), $3) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_binaryBreadthFirstSearch(_pgr_get_statement($1), _pgr_get_statement($2), directed); $BODY$ LANGUAGE SQL VOLATILE STRICT; --- COMMENTS COMMENT ON FUNCTION pgr_binaryBreadthFirstSearch(TEXT, BIGINT, BIGINT, BOOLEAN) IS 'pgr_binaryBreadthFirstSearch(One to One) diff --git a/sql/dagShortestPath/CMakeLists.txt b/sql/dagShortestPath/CMakeLists.txt index 7e0811123e..981d638104 100644 --- a/sql/dagShortestPath/CMakeLists.txt +++ b/sql/dagShortestPath/CMakeLists.txt @@ -1,6 +1,6 @@ SET(LOCAL_FILES - _dagShortestPath.sql + _dagShortestPath.sql dagShortestPath.sql ) diff --git a/sql/dagShortestPath/_dagShortestPath.sql b/sql/dagShortestPath/_dagShortestPath.sql index 9b4756edf4..d2584db4c0 100644 --- a/sql/dagShortestPath/_dagShortestPath.sql +++ b/sql/dagShortestPath/_dagShortestPath.sql @@ -27,57 +27,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ---------------------- ---------------------- --- dagShortestPath ---------------------- ---------------------- - ---------------------------- ---_pgr_dagShortestPath ---------------------------- - ---v3.0 -CREATE FUNCTION _pgr_dagShortestPath( - TEXT, - ANYARRAY, - ANYARRAY, - directed BOOLEAN DEFAULT true, - only_cost BOOLEAN DEFAULT false, +--v4.0 +CREATE FUNCTION _pgr_dagShortestPath_v4( + TEXT, -- edges + + ANYARRAY, -- departures + ANYARRAY, -- arrivals + + BOOLEAN, -- only_cost + BOOLEAN, -- normal OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, OUT agg_cost FLOAT) - RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE c IMMUTABLE STRICT; +LANGUAGE C VOLATILE STRICT; ---v3.2 -CREATE FUNCTION _pgr_dagShortestPath( - TEXT, - TEXT, - directed BOOLEAN DEFAULT true, - only_cost BOOLEAN DEFAULT false, +--v4.0 +CREATE FUNCTION _pgr_dagShortestPath_v4( + TEXT, -- edges + TEXT, -- combinations + + BOOLEAN, -- only_cost OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, OUT agg_cost FLOAT) - RETURNS SETOF RECORD AS 'MODULE_PATHNAME' -LANGUAGE C IMMUTABLE STRICT; +LANGUAGE C VOLATILE STRICT; -- COMMENTS -COMMENT ON FUNCTION _pgr_dagShortestPath(TEXT, ANYARRAY, ANYARRAY, BOOLEAN, BOOLEAN) +COMMENT ON FUNCTION _pgr_dagShortestPath_v4(TEXT, ANYARRAY, ANYARRAY, BOOLEAN, BOOLEAN) IS 'pgRouting internal function'; -COMMENT ON FUNCTION _pgr_dagShortestPath(TEXT, TEXT, BOOLEAN, BOOLEAN) +COMMENT ON FUNCTION _pgr_dagShortestPath_v4(TEXT, TEXT, BOOLEAN) IS 'pgRouting internal function'; diff --git a/sql/dagShortestPath/dagShortestPath.sql b/sql/dagShortestPath/dagShortestPath.sql index 404d30e008..8ce3531c4d 100644 --- a/sql/dagShortestPath/dagShortestPath.sql +++ b/sql/dagShortestPath/dagShortestPath.sql @@ -7,7 +7,7 @@ Mail: project@pgrouting.org Function's developer: Copyright (c) 2018 Sourabh Garg -Mail: sourabh.garg.mat@gmail.com +Mail: sourabh.garg.mat at gmail.com ------ @@ -27,12 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ ----------------------- --- pgr_dagShortestPath ----------------------- - -- ONE to ONE ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) BIGINT, -- from_vid (required) @@ -40,6 +36,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -47,16 +45,14 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], ARRAY[$3]::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- ONE to MANY ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) BIGINT, -- from_vid (required) @@ -64,6 +60,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -71,16 +69,14 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), ARRAY[$2]::BIGINT[], $3::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- MANY to ONE ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) ANYARRAY, -- from_vids (required) @@ -88,6 +84,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -95,16 +93,14 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), $2::BIGINT[], ARRAY[$3]::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- MANY to MANY ---v3.0 +--v4.0 CREATE FUNCTION pgr_dagShortestPath( TEXT, -- edges_sql (required) ANYARRAY, -- from_vids (required) @@ -112,6 +108,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -119,12 +117,10 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), $2::BIGINT[], $3::BIGINT[], false, true); $BODY$ -LANGUAGE sql VOLATILE STRICT -COST 100 -ROWS 1000; +LANGUAGE SQL VOLATILE STRICT; -- COMBINATIONS @@ -135,6 +131,8 @@ CREATE FUNCTION pgr_dagShortestPath( OUT seq INTEGER, OUT path_seq INTEGER, + OUT start_vid BIGINT, + OUT end_vid BIGINT, OUT node BIGINT, OUT edge BIGINT, OUT cost FLOAT, @@ -142,24 +140,23 @@ CREATE FUNCTION pgr_dagShortestPath( RETURNS SETOF RECORD AS $BODY$ - SELECT a.seq, a.path_seq, a.node, a.edge, a.cost, a.agg_cost - FROM _pgr_dagShortestPath(_pgr_get_statement($1), _pgr_get_statement($2), true, false ) AS a; + SELECT seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost + FROM _pgr_dagShortestPath_v4(_pgr_get_statement($1), _pgr_get_statement($2), false); $BODY$ LANGUAGE sql VOLATILE STRICT COST 100 ROWS 1000; --- COMMENTS COMMENT ON FUNCTION pgr_dagShortestPath(TEXT, BIGINT, BIGINT) IS 'pgr_dagShortestPath(One to One) - EXPERIMENTAL - Parameters: - - Edges SQL with columns: id, source, target, cost [,reverse_cost] - - From vertex identifier - - To vertex identifier + - Edges SQL with columns: id, source, target, cost [,reverse_cost] + - From vertex identifier + - To vertex identifier - Documentation: - - ${PROJECT_DOC_LINK}/pgr_dagShortestPath.html + - ${PROJECT_DOC_LINK}/pgr_dagShortestPath.html '; COMMENT ON FUNCTION pgr_dagShortestPath(TEXT, BIGINT, ANYARRAY) diff --git a/sql/scripts/build-extension-update-files.pl b/sql/scripts/build-extension-update-files.pl index 27656d99d3..ef96d1e3dc 100755 --- a/sql/scripts/build-extension-update-files.pl +++ b/sql/scripts/build-extension-update-files.pl @@ -275,6 +275,9 @@ sub generate_upgrade_script { if ($old_minor >= "3.2") { # Out parameters changed names on v4.0.0 + # Experimental functions + push @commands, drop_special_case_function("pgr_dagshortestpath(text,text)"); + # Official functions push @commands, drop_special_case_function("pgr_withpoints(text,text,text,boolean,character,boolean)"); push @commands, drop_special_case_function("pgr_withpointscost(text,text,text,boolean,character)"); @@ -288,6 +291,15 @@ sub generate_upgrade_script { push @commands, drop_special_case_function("pgr_bellmanford(text,anyarray,bigint,boolean)"); push @commands, drop_special_case_function("pgr_bellmanford(text,bigint,anyarray,boolean)"); + push @commands, drop_special_case_function("pgr_binarybreadthfirstsearch(text,bigint,bigint,boolean)"); + push @commands, drop_special_case_function("pgr_binarybreadthfirstsearch(text,anyarray,bigint,boolean)"); + push @commands, drop_special_case_function("pgr_binarybreadthfirstsearch(text,bigint,anyarray,boolean)"); + + push @commands, drop_special_case_function("pgr_dagshortestpath(text,bigint,bigint)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,bigint,anyarray)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,anyarray,bigint)"); + push @commands, drop_special_case_function("pgr_dagshortestpath(text,anyarray,anyarray)"); + push @commands, drop_special_case_function("pgr_edwardmoore(text,bigint,bigint,boolean)"); push @commands, drop_special_case_function("pgr_edwardmoore(text,anyarray,bigint,boolean)"); push @commands, drop_special_case_function("pgr_edwardmoore(text,bigint,anyarray,boolean)"); diff --git a/sql/sigs/pgrouting--4.0.sig b/sql/sigs/pgrouting--4.0.sig index 4a6fd80505..749b9723cd 100644 --- a/sql/sigs/pgrouting--4.0.sig +++ b/sql/sigs/pgrouting--4.0.sig @@ -90,12 +90,12 @@ pgr_contraction(text,boolean,integer[],integer,bigint[]) _pgr_cuthillmckeeordering(text) pgr_cuthillmckeeordering(text) pgr_dagshortestpath(text,anyarray,anyarray) -_pgr_dagshortestpath(text,anyarray,anyarray,boolean,boolean) pgr_dagshortestpath(text,anyarray,bigint) pgr_dagshortestpath(text,bigint,anyarray) pgr_dagshortestpath(text,bigint,bigint) pgr_dagshortestpath(text,text) -_pgr_dagshortestpath(text,text,boolean,boolean) +_pgr_dagshortestpath_v4(text,anyarray,anyarray,boolean,boolean) +_pgr_dagshortestpath_v4(text,text,boolean) pgr_degree(text,boolean) pgr_degree(text,text,boolean) _pgr_depthfirstsearch(text,anyarray,boolean,bigint) diff --git a/src/dagShortestPath/dagShortestPath.c b/src/dagShortestPath/dagShortestPath.c index 74295b2a90..55de4edd6f 100644 --- a/src/dagShortestPath/dagShortestPath.c +++ b/src/dagShortestPath/dagShortestPath.c @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "c_common/time_msg.h" #include "drivers/dagShortestPath/dagShortestPath_driver.h" -PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS); -PG_FUNCTION_INFO_V1(_pgr_dagshortestpath); +PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(_pgr_dagshortestpath_v4); static @@ -48,8 +48,8 @@ process( char* combinations_sql, ArrayType *starts, ArrayType *ends, - bool directed, bool only_cost, + bool normal, Path_rt **result_tuples, size_t *result_count) { pgr_SPI_connect(); @@ -65,8 +65,9 @@ process( combinations_sql, starts, ends, - directed, only_cost, + normal, + result_tuples, result_count, &log_msg, @@ -82,9 +83,9 @@ process( pgr_SPI_finish(); } -PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { +PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; - TupleDesc tuple_desc; + TupleDesc tuple_desc; Path_rt *result_tuples = NULL; size_t result_count = 0; @@ -94,8 +95,6 @@ PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { funcctx = SRF_FIRSTCALL_INIT(); oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - - PGR_DBG("Calling process"); if (PG_NARGS() == 5) { /* * many to many @@ -110,33 +109,27 @@ PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { &result_tuples, &result_count); - } else if (PG_NARGS() == 4) { + } else if (PG_NARGS() == 3) { /* * combinations */ process( text_to_cstring(PG_GETARG_TEXT_P(0)), text_to_cstring(PG_GETARG_TEXT_P(1)), - NULL, - NULL, + NULL, NULL, PG_GETARG_BOOL(2), - PG_GETARG_BOOL(3), + true, &result_tuples, &result_count); } - - - funcctx->max_calls = result_count; - funcctx->user_fctx = result_tuples; if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function returning record called in context " - "that cannot accept type record"))); + errmsg("function returning record called in context that cannot accept type record"))); } funcctx->tuple_desc = tuple_desc; @@ -152,33 +145,34 @@ PGDLLEXPORT Datum _pgr_dagshortestpath(PG_FUNCTION_ARGS) { Datum result; Datum *values; bool* nulls; + size_t call_cntr = funcctx->call_cntr; - - values = palloc(6 * sizeof(Datum)); - nulls = palloc(6 * sizeof(bool)); - + size_t numb = 8; + values = palloc(numb * sizeof(Datum)); + nulls = palloc(numb * sizeof(bool)); size_t i; - for (i = 0; i < 6; ++i) { + for (i = 0; i < numb; ++i) { nulls[i] = false; } - int64_t seq = funcctx->call_cntr == 0? 1 : result_tuples[funcctx->call_cntr - 1].start_id; + int64_t seq = call_cntr == 0? 1 : result_tuples[call_cntr - 1].start_id; - values[0] = Int32GetDatum((int32_t)funcctx->call_cntr + 1); + values[0] = Int32GetDatum((int32_t)call_cntr + 1); values[1] = Int32GetDatum((int32_t)seq); - values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].node); - values[3] = Int64GetDatum(result_tuples[funcctx->call_cntr].edge); - values[4] = Float8GetDatum(result_tuples[funcctx->call_cntr].cost); - values[5] = Float8GetDatum(result_tuples[funcctx->call_cntr].agg_cost); + values[2] = Int64GetDatum(result_tuples[call_cntr].start_id); + values[3] = Int64GetDatum(result_tuples[call_cntr].end_id); + values[4] = Int64GetDatum(result_tuples[call_cntr].node); + values[5] = Int64GetDatum(result_tuples[call_cntr].edge); + values[6] = Float8GetDatum(result_tuples[call_cntr].cost); + values[7] = Float8GetDatum(result_tuples[call_cntr].agg_cost); - result_tuples[funcctx->call_cntr].start_id = result_tuples[funcctx->call_cntr].edge < 0? 1 : seq + 1; + result_tuples[call_cntr].start_id = result_tuples[call_cntr].edge < 0? 1 : seq + 1; tuple = heap_form_tuple(tuple_desc, values, nulls); result = HeapTupleGetDatum(tuple); SRF_RETURN_NEXT(funcctx, result); } else { - PGR_DBG("Clean up code"); SRF_RETURN_DONE(funcctx); } } diff --git a/src/dagShortestPath/dagShortestPath_driver.cpp b/src/dagShortestPath/dagShortestPath_driver.cpp index f595ec001d..e82da570f8 100644 --- a/src/dagShortestPath/dagShortestPath_driver.cpp +++ b/src/dagShortestPath/dagShortestPath_driver.cpp @@ -67,11 +67,10 @@ pgr_do_dagShortestPath( ArrayType *starts, ArrayType *ends, - bool directed, bool only_cost, + bool normal, - Path_rt **return_tuples, - size_t *return_count, + Path_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg) { @@ -84,8 +83,8 @@ pgr_do_dagShortestPath( std::ostringstream log; - std::ostringstream err; std::ostringstream notice; + std::ostringstream err; const char *hint = nullptr; try { @@ -96,7 +95,7 @@ pgr_do_dagShortestPath( pgassert(*return_count == 0); hint = combinations_sql; - auto combinations = get_combinations(combinations_sql, starts, ends, true); + auto combinations = get_combinations(combinations_sql, starts, ends, normal); hint = nullptr; if (combinations.empty() && combinations_sql) { @@ -108,7 +107,7 @@ pgr_do_dagShortestPath( hint = edges_sql; - auto edges = get_edges(std::string(edges_sql), true, false); + auto edges = get_edges(std::string(edges_sql), normal, false); if (edges.empty()) { *notice_msg = to_pg_msg("No edges found"); @@ -118,23 +117,16 @@ pgr_do_dagShortestPath( hint = nullptr; std::deque paths; - if (directed) { - pgrouting::DirectedGraph graph; - graph.insert_edges(edges); - paths = pgr_dagShortestPath(graph, combinations, only_cost); - } else { - pgrouting::UndirectedGraph graph; - graph.insert_edges(edges); - paths = pgr_dagShortestPath(graph, combinations, only_cost); - } + pgrouting::DirectedGraph graph; + graph.insert_edges(edges); + paths = pgr_dagShortestPath(graph, combinations, only_cost); auto count = count_tuples(paths); if (count == 0) { (*return_tuples) = NULL; (*return_count) = 0; - notice << "No paths found"; - *log_msg = to_pg_msg(notice); + *log_msg = to_pg_msg("No paths found"); return; } diff --git a/src/legacy/legacy.c b/src/legacy/legacy.c index 7c31558f74..6fb6f76894 100644 --- a/src/legacy/legacy.c +++ b/src/legacy/legacy.c @@ -56,3 +56,4 @@ PGROUTING_DEPRECATE("4.0.0", _v4trsp) PGROUTING_DEPRECATE("4.0.0", _trsp) PGROUTING_DEPRECATE("4.0.0", _pgr_alphashape) PGROUTING_DEPRECATE("4.0.0", _pgr_withpointsdd) +PGROUTING_DEPRECATE("4.0.0", _pgr_dagshortestpath) diff --git a/src/metrics/bandwidth.c b/src/metrics/bandwidth.c index 65202e8847..2ef9cfbcfb 100644 --- a/src/metrics/bandwidth.c +++ b/src/metrics/bandwidth.c @@ -26,7 +26,7 @@ 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*/ -#if 0 + #include #include "c_common/postgres_connection.h" @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "c_common/e_report.h" #include "c_common/time_msg.h" -#include "drivers/metrics/bandwidth_driver.h" +#include "process/metrics_process.h" PGDLLEXPORT Datum _pgr_bandwidth(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(_pgr_bandwidth); @@ -44,7 +44,6 @@ static void process( char* edges_sql, - bool directed, GraphBandwidth_rt **result_tuples, size_t *result_count) { @@ -54,9 +53,8 @@ process( char* err_msg = NULL; clock_t start_t = clock(); - _pgr_bandwidth( - edges, - directed, + _pgr_process_metrics( + edges_sql, result_tuples, result_count, &log_msg, @@ -132,4 +130,3 @@ _pgr_bandwidth(PG_FUNCTION_ARGS) { } } -#endif \ No newline at end of file diff --git a/src/metrics/metrics_driver.cpp b/src/metrics/metrics_driver.cpp index 50589ae5d4..0e31f91b2d 100644 --- a/src/metrics/metrics_driver.cpp +++ b/src/metrics/metrics_driver.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "cpp_common/base_graph.hpp" #include "metrics/bandwidth.hpp" -#include "c_types/graph_bandwidth_rt.h" // <- Your actual result type +#include "c_types/bandwidth_rt.h" namespace pgrouting::graph { @@ -60,7 +60,7 @@ run_metric(G& graph) { void -pgr_do_metric( +do_metrics( GraphBandwidth_rt **return_tuples, size_t *return_count, char **log_msg, diff --git a/src/metrics/metrics_process.cpp b/src/metrics/metrics_process.cpp index 4381bef0e2..bc76cf1ef8 100644 --- a/src/metrics/metrics_process.cpp +++ b/src/metrics/metrics_process.cpp @@ -35,40 +35,66 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include #include "cpp_common/assert.hpp" +#include "cpp_common/alloc.hpp" +#if 0 #include "cpp_common/base_graph.hpp" #include "cpp_common/pgdata_getters.hpp" #include "cpp_common/pgdata_fetchers.hpp" +#endif #include "cpp_common/get_data.hpp" #include "cpp_common/to_postgres.hpp" -struct Metrics_rt { - int64_t node; - double metric_value; -}; - -std::vector -process_metrics(std::string edges_sql, bool directed, int max_nodes) { - std::vector result; - - if (directed) { - pgrouting::DirectedGraph graph; - auto edges = pgrouting::pgget::get_edges(edges_sql, directed, false); - graph.insert_edges(edges); -} else { - pgrouting::UndirectedGraph graph; - auto edges = pgrouting::pgget::get_edges(edges_sql, directed, false); - graph.insert_edges(edges); +extern "C" { +#include "c_common/postgres_connection.h" +#include "c_common/e_report.h" +#include "c_common/time_msg.h" } +#include "process/metrics_process.h" +#include "drivers/metrics_driver.hpp" +#include "c_types/bandwidth_rt.h" - auto graph_map = pgrouting::graph::get_graph(); +#include "c_types/metrics_rt.h" - for (const auto& node_pair : graph_map) { - Metrics_rt record; - record.node = node_pair.first; - record.metric_value = static_cast(node_pair.second.size()); - result.push_back(record); +void +pgr_process_metrics( + const char* edges_sql, + GraphBandwidth_rt** result_tuples, + size_t* result_count, + char** log_msg, + char** notice_msg) { + + pgassert(!(*result_tuples)); + pgassert(*result_count == 0); + + pgr_SPI_connect(); + + *log_msg = *notice_msg = nullptr; + char* err_msg = nullptr; + + clock_t start_t = clock(); + +#if 0 + + std::vector results = + pgrouting::bandwidth::compute_bandwidth(std::string(edges_sql)); + + if (!results.empty()) { + *result_count = results.size(); + (*result_tuples) = pgrouting::pgr_alloc(*result_count, GraphBandwidth_rt); + + for (size_t i = 0; i < *result_count; ++i) { + (*result_tuples)[i] = results[i]; + } + + time_msg(" processing pgr_bandwidth", start_t, clock()); + } else { + *result_count = 0; + *result_tuples = nullptr; } - return result; +#endif + + pgr_global_report(log_msg, notice_msg, &err_msg); + pgr_SPI_finish(); }