Skip to content

Commit a0c0c0f

Browse files
authored
Merge pull request #456 from Saloni-2005/week-4-bandwidth
Week 4 bandwidth
2 parents a424afc + cd62ce5 commit a0c0c0f

File tree

18 files changed

+201
-361
lines changed

18 files changed

+201
-361
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ Standardize output columns of functions with different output columns within ove
101101

102102
* Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
103103

104+
* [#2908](https://github.com/pgRouting/pgrouting/issues/2908)
105+
pgr_binaryBreadthFirstSearch
106+
107+
* Output columns standardized to ``(seq, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
108+
104109
* [#2910](https://github.com/pgRouting/pgrouting/issues/2910)
105110
pgr_edwardMoore
106111

doc/src/migration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ types.
8181
- `Migration of single path functions`_
8282
* - .. versionchanged:: 4.0.0 :doc:`pgr_bellmanFord` [3]_
8383
- `Migration of single path functions`_
84+
* - .. versionchanged:: 4.0.0 :doc:`pgr_binaryBreadthFirstSearch` [3]_
85+
- `Migration of single path functions`_
8486
* - .. versionchanged:: 4.0.0 :doc:`pgr_dagShortestPath` [3]_
8587
- `Migration of single path functions`_
8688
* - .. versionchanged:: 4.0.0 :doc:`pgr_edwardMoore` [3]_

doc/src/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ Standardize output columns of functions with different output columns within ove
122122
:start-after: Version 4.0.0
123123
:end-before: .. rubric
124124

125+
* `#2908 <https://github.com/pgRouting/pgrouting/issues/2908>`__
126+
pgr_binaryBreadthFirstSearch
127+
128+
.. include:: pgr_binaryBreadthFirstSearch.rst
129+
:start-after: Version 4.0.0
130+
:end-before: .. rubric
131+
125132
* `#2910 <https://github.com/pgRouting/pgrouting/issues/2910>`__
126133
pgr_edwardMoore
127134

doc/traversal/pgr_binaryBreadthFirstSearch.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ non-negative integer, is termed as a 'binary graph'.
2929

3030
.. rubric:: Availability
3131

32-
* Version 3.2.0
32+
.. rubric:: Version 4.0.0
3333

34-
* New experimental signature:
34+
* Output columns standardized to |short-generic-result|
3535

36-
* pgr_binaryBreadthFirstSearch(Combinations)
36+
.. rubric:: Version 3.2.0
3737

38-
* Version 3.0.0
38+
* New experimental signature:
3939

40-
* New experimental function.
40+
* pgr_binaryBreadthFirstSearch(Combinations)
41+
42+
.. rubric:: Version 3.0.0
43+
44+
* New experimental function.
4145

4246
Description
4347
-------------------------------------------------------------------------------
@@ -47,7 +51,7 @@ vertices can be found using Breadth First Search in :math:`O(|E|)` in an
4751
unweighted graph, i.e. the distance is the minimal number of edges that you
4852
need to traverse from the source to another vertex. We can interpret such a
4953
graph also as a weighted graph, where every edge has the weight :math:`1`.
50-
If not alledges in graph have the same weight, that we need a more general
54+
If not all edges in graph have the same weight, that we need a more general
5155
algorithm, like Dijkstra's Algorithm which runs in :math:`O(|E|log|V|)` time.
5256

5357
However if the weights are more constrained, we can use a faster algorithm.
@@ -87,7 +91,7 @@ Signatures
8791
| pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vids**, **end vids**, [``directed``])
8892
| pgr_binaryBreadthFirstSearch(`Edges SQL`_, `Combinations SQL`_, [``directed``])
8993
90-
| Returns set of |old-generic-result|
94+
| Returns set of |short-generic-result|
9195
| OR EMPTY SET
9296
9397
**Note:** Using the :doc:`sampledata` Network as all weights are same (i.e
@@ -104,7 +108,7 @@ One to One
104108

105109
| pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vid**, **end vid**, [``directed``])
106110
107-
| Returns set of |result-1-1|
111+
| Returns set of |short-generic-result|
108112
| OR EMPTY SET
109113
110114
:Example: From vertex :math:`6` to vertex :math:`10` on a **directed** graph
@@ -124,7 +128,7 @@ One to Many
124128

125129
| pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vid**, **end vids**, [``directed``])
126130
127-
| Returns set of |result-1-m|
131+
| Returns set of |short-generic-result|
128132
| OR EMPTY SET
129133
130134
:Example: From vertex :math:`6` to vertices :math:`\{10, 17\}` on a **directed**
@@ -145,7 +149,7 @@ Many to One
145149

146150
| pgr_binaryBreadthFirstSearch(`Edges SQL`_, **start vids**, **end vid**, [``directed``])
147151
148-
| Returns set of |result-m-1|
152+
| Returns set of |short-generic-result|
149153
| OR EMPTY SET
150154
151155
:Example: From vertices :math:`\{6, 1\}` to vertex :math:`17` on a **directed**

docqueries/traversal/binaryBreadthFirstSearch.result

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,52 @@ SET
66
SELECT * FROM pgr_binaryBreadthFirstSearch(
77
'SELECT id, source, target, cost, reverse_cost from edges',
88
6, 10, true);
9-
seq | path_seq | node | edge | cost | agg_cost
10-
-----+----------+------+------+------+----------
11-
1 | 1 | 6 | 4 | 1 | 0
12-
2 | 2 | 7 | 8 | 1 | 1
13-
3 | 3 | 11 | 9 | 1 | 2
14-
4 | 4 | 16 | 16 | 1 | 3
15-
5 | 5 | 15 | 3 | 1 | 4
16-
6 | 6 | 10 | -1 | 0 | 5
9+
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
10+
-----+----------+-----------+---------+------+------+------+----------
11+
1 | 1 | 6 | 10 | 6 | 4 | 1 | 0
12+
2 | 2 | 6 | 10 | 7 | 8 | 1 | 1
13+
3 | 3 | 6 | 10 | 11 | 9 | 1 | 2
14+
4 | 4 | 6 | 10 | 16 | 16 | 1 | 3
15+
5 | 5 | 6 | 10 | 15 | 3 | 1 | 4
16+
6 | 6 | 6 | 10 | 10 | -1 | 0 | 5
1717
(6 rows)
1818

1919
/* -- q2 */
2020
SELECT * FROM pgr_binaryBreadthFirstSearch(
2121
'SELECT id, source, target, cost, reverse_cost from edges',
2222
6, ARRAY[10, 17]);
23-
seq | path_seq | end_vid | node | edge | cost | agg_cost
24-
-----+----------+---------+------+------+------+----------
25-
1 | 1 | 10 | 6 | 4 | 1 | 0
26-
2 | 2 | 10 | 7 | 8 | 1 | 1
27-
3 | 3 | 10 | 11 | 9 | 1 | 2
28-
4 | 4 | 10 | 16 | 16 | 1 | 3
29-
5 | 5 | 10 | 15 | 3 | 1 | 4
30-
6 | 6 | 10 | 10 | -1 | 0 | 5
31-
7 | 1 | 17 | 6 | 4 | 1 | 0
32-
8 | 2 | 17 | 7 | 8 | 1 | 1
33-
9 | 3 | 17 | 11 | 11 | 1 | 2
34-
10 | 4 | 17 | 12 | 13 | 1 | 3
35-
11 | 5 | 17 | 17 | -1 | 0 | 4
23+
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
24+
-----+----------+-----------+---------+------+------+------+----------
25+
1 | 1 | 6 | 10 | 6 | 4 | 1 | 0
26+
2 | 2 | 6 | 10 | 7 | 8 | 1 | 1
27+
3 | 3 | 6 | 10 | 11 | 9 | 1 | 2
28+
4 | 4 | 6 | 10 | 16 | 16 | 1 | 3
29+
5 | 5 | 6 | 10 | 15 | 3 | 1 | 4
30+
6 | 6 | 6 | 10 | 10 | -1 | 0 | 5
31+
7 | 1 | 6 | 17 | 6 | 4 | 1 | 0
32+
8 | 2 | 6 | 17 | 7 | 8 | 1 | 1
33+
9 | 3 | 6 | 17 | 11 | 11 | 1 | 2
34+
10 | 4 | 6 | 17 | 12 | 13 | 1 | 3
35+
11 | 5 | 6 | 17 | 17 | -1 | 0 | 4
3636
(11 rows)
3737

3838
/* -- q3 */
3939
SELECT * FROM pgr_binaryBreadthFirstSearch(
4040
'SELECT id, source, target, cost, reverse_cost from edges',
4141
ARRAY[6, 1], 17);
42-
seq | path_seq | start_vid | node | edge | cost | agg_cost
43-
-----+----------+-----------+------+------+------+----------
44-
1 | 1 | 1 | 1 | 6 | 1 | 0
45-
2 | 2 | 1 | 3 | 7 | 1 | 1
46-
3 | 3 | 1 | 7 | 8 | 1 | 2
47-
4 | 4 | 1 | 11 | 11 | 1 | 3
48-
5 | 5 | 1 | 12 | 13 | 1 | 4
49-
6 | 6 | 1 | 17 | -1 | 0 | 5
50-
7 | 1 | 6 | 6 | 4 | 1 | 0
51-
8 | 2 | 6 | 7 | 8 | 1 | 1
52-
9 | 3 | 6 | 11 | 11 | 1 | 2
53-
10 | 4 | 6 | 12 | 13 | 1 | 3
54-
11 | 5 | 6 | 17 | -1 | 0 | 4
42+
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
43+
-----+----------+-----------+---------+------+------+------+----------
44+
1 | 1 | 1 | 17 | 1 | 6 | 1 | 0
45+
2 | 2 | 1 | 17 | 3 | 7 | 1 | 1
46+
3 | 3 | 1 | 17 | 7 | 8 | 1 | 2
47+
4 | 4 | 1 | 17 | 11 | 11 | 1 | 3
48+
5 | 5 | 1 | 17 | 12 | 13 | 1 | 4
49+
6 | 6 | 1 | 17 | 17 | -1 | 0 | 5
50+
7 | 1 | 6 | 17 | 6 | 4 | 1 | 0
51+
8 | 2 | 6 | 17 | 7 | 8 | 1 | 1
52+
9 | 3 | 6 | 17 | 11 | 11 | 1 | 2
53+
10 | 4 | 6 | 17 | 12 | 13 | 1 | 3
54+
11 | 5 | 6 | 17 | 17 | -1 | 0 | 4
5555
(11 rows)
5656

5757
/* -- q4 */

include/c_types/bandwidth_rt.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

include/drivers/metrics_driver.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3838
#include <string>
3939
#include <cstdint>
4040

41-
#include "c_types/metrics_rt.h"
41+
#include "c_types/iid_t_rt.h"
4242
void
4343
do_metrics(
4444
std::string,
4545
bool, int,
4646

47-
Metrics_rt**, size_t*,
47+
IID_t_rt**, size_t*,
4848
char**, char**);
4949

50-
#endif // INCLUDE_DRIVERS_METRICS_DRIVER_HPP_
50+
#endif // INCLUDE_DRIVERS_METRICS_DRIVER_HPP_

include/process/metrics_process.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3636
#include <stdbool.h>
3737
#endif
3838

39-
#include "c_types/bandwidth_rt.h"
39+
#include "c_types/iid_t_rt.h"
4040

4141
#ifdef __cplusplus
4242
extern "C" {
4343
#endif
4444

4545
void pgr_process_metrics(
4646
const char* edges_sql,
47-
GraphBandwidth_rt** result_tuples,
47+
IID_t_rt** result_tuples,
4848
size_t* result_count,
4949
char** log_msg,
5050
char** notice_msg

locale/en/LC_MESSAGES/pgrouting_doc_strings.po

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: pgRouting v3.8\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-06-14 12:05+0000\n"
11+
"POT-Creation-Date: 2025-06-16 16:56+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -4047,6 +4047,11 @@ msgid ""
40474047
"pgr_bellmanFord"
40484048
msgstr ""
40494049

4050+
msgid ""
4051+
"`#2908 <https://github.com/pgRouting/pgrouting/issues/2908>`__ "
4052+
"pgr_binaryBreadthFirstSearch"
4053+
msgstr ""
4054+
40504055
msgid ""
40514056
"`#2910 <https://github.com/pgRouting/pgrouting/issues/2910>`__ "
40524057
"pgr_edwardMoore"
@@ -4495,6 +4500,9 @@ msgstr ""
44954500
msgid ":doc:`pgr_bellmanFord` [3]_"
44964501
msgstr ""
44974502

4503+
msgid ":doc:`pgr_binaryBreadthFirstSearch` [3]_"
4504+
msgstr ""
4505+
44984506
msgid ":doc:`pgr_dagShortestPath` [3]_"
44994507
msgstr ""
45004508

@@ -8994,9 +9002,9 @@ msgid ""
89949002
"in an unweighted graph, i.e. the distance is the minimal number of edges "
89959003
"that you need to traverse from the source to another vertex. We can "
89969004
"interpret such a graph also as a weighted graph, where every edge has the"
8997-
" weight :math:`1`. If not alledges in graph have the same weight, that we"
8998-
" need a more general algorithm, like Dijkstra's Algorithm which runs in "
8999-
":math:`O(|E|log|V|)` time."
9005+
" weight :math:`1`. If not all edges in graph have the same weight, that "
9006+
"we need a more general algorithm, like Dijkstra's Algorithm which runs in"
9007+
" :math:`O(|E|log|V|)` time."
90009008
msgstr ""
90019009

90029010
#, python-brace-format
@@ -9049,15 +9057,6 @@ msgid ""
90499057
"(i.e :math:`1``)"
90509058
msgstr ""
90519059

9052-
msgid "Returns set of |result-1-1|"
9053-
msgstr ""
9054-
9055-
msgid "Returns set of |result-1-m|"
9056-
msgstr ""
9057-
9058-
msgid "Returns set of |result-m-1|"
9059-
msgstr ""
9060-
90619060
msgid ""
90629061
"`Boost: Breadth First Search "
90639062
"<https://www.boost.org/libs/graph/doc/breadth_first_search.html>`__"

locale/pot/pgrouting_doc_strings.pot

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: pgRouting v4.0\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-06-14 12:05+0000\n"
11+
"POT-Creation-Date: 2025-06-16 16:56+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -3628,6 +3628,9 @@ msgstr ""
36283628
msgid "`#2907 <https://github.com/pgRouting/pgrouting/issues/2907>`__ pgr_bellmanFord"
36293629
msgstr ""
36303630

3631+
msgid "`#2908 <https://github.com/pgRouting/pgrouting/issues/2908>`__ pgr_binaryBreadthFirstSearch"
3632+
msgstr ""
3633+
36313634
msgid "`#2910 <https://github.com/pgRouting/pgrouting/issues/2910>`__ pgr_edwardMoore"
36323635
msgstr ""
36333636

@@ -4003,6 +4006,9 @@ msgstr ""
40034006
msgid ":doc:`pgr_bellmanFord` [3]_"
40044007
msgstr ""
40054008

4009+
msgid ":doc:`pgr_binaryBreadthFirstSearch` [3]_"
4010+
msgstr ""
4011+
40064012
msgid ":doc:`pgr_dagShortestPath` [3]_"
40074013
msgstr ""
40084014

@@ -7744,7 +7750,7 @@ msgstr ""
77447750
msgid "pgr_binaryBreadthFirstSearch(Combinations)"
77457751
msgstr ""
77467752

7747-
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."
7753+
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."
77487754
msgstr ""
77497755

77507756
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."
@@ -7774,15 +7780,6 @@ msgstr ""
77747780
msgid "**Note:** Using the :doc:`sampledata` Network as all weights are same (i.e :math:`1``)"
77757781
msgstr ""
77767782

7777-
msgid "Returns set of |result-1-1|"
7778-
msgstr ""
7779-
7780-
msgid "Returns set of |result-1-m|"
7781-
msgstr ""
7782-
7783-
msgid "Returns set of |result-m-1|"
7784-
msgstr ""
7785-
77867783
msgid "`Boost: Breadth First Search <https://www.boost.org/libs/graph/doc/breadth_first_search.html>`__"
77877784
msgstr ""
77887785

0 commit comments

Comments
 (0)