Skip to content

Week 3 king and minimumdegree ordering #452

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: wifi-2025
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ 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

Expand Down
2 changes: 2 additions & 0 deletions doc/src/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ 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]_
Expand Down
7 changes: 7 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ Standardize output columns of functions with different output columns within ove
:start-after: Version 4.0.0
:end-before: .. rubric

* `#2908 <https://github.com/pgRouting/pgrouting/issues/2908>`__
pgr_binaryBreadthFirstSearch

.. include:: pgr_binaryBreadthFirstSearch.rst
:start-after: Version 4.0.0
:end-before: .. rubric

* `#2910 <https://github.com/pgRouting/pgrouting/issues/2910>`__
pgr_edwardMoore

Expand Down
24 changes: 14 additions & 10 deletions doc/traversal/pgr_binaryBreadthFirstSearch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------------------------------------------
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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**
Expand All @@ -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**
Expand Down
7 changes: 7 additions & 0 deletions docqueries/ordering/kingOrdering.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- CopyRight(c) pgRouting developers
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
/* -- q1 */
SELECT * FROM pgr_kingOrdering(
'SELECT id, source, target, cost, reverse_cost FROM edges'
);
/* -- q2 */
Empty file.
7 changes: 7 additions & 0 deletions docqueries/ordering/minDegreeOrdering.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- CopyRight(c) pgRouting developers
-- Creative Commons Attribution-Share Alike 3.0 License : https://creativecommons.org/licenses/by-sa/3.0/
/* -- q1 */
SELECT * FROM pgr_minDegreeOrdering(
'SELECT id, source, target, cost, reverse_cost FROM edges'
);
/* -- q2 */
Empty file.
2 changes: 2 additions & 0 deletions docqueries/ordering/test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
'files' => [qw(
cuthillMckeeOrdering.pg
topologicalSort.pg
minDegreeOrdering.pg
kingOrdering.pg
)]
},

Expand Down
68 changes: 34 additions & 34 deletions docqueries/traversal/binaryBreadthFirstSearch.result
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 3 additions & 5 deletions include/drivers/ordering_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ using II_t_rt = struct II_t_rt;

void
do_ordering(
const Edge_t*, size_t,

int64_t, int64_t,

const char*,
int64_t,
II_t_rt**, size_t*,
char **, char **);
char **, char **, char **);


#endif // INCLUDE_DRIVERS_ORDERING_DRIVER_HPP_
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*PGR-GNU*****************************************************************
File: minimumDegreeOrdering.hpp
File: minDegreeOrdering.hpp
Generated with Template by:
Copyright (c) 2025 pgRouting developers
Expand Down Expand Up @@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/

#ifndef INCLUDE_ORDERING_MINIMUMDEGREEORDERING_HPP_
#define INCLUDE_ORDERING_MINIMUMDEGREEORDERING_HPP_
#ifndef INCLUDE_ORDERING_MINDEGREEORDERING_HPP_
#define INCLUDE_ORDERING_MINDEGREEORDERING_HPP_
#pragma once

#include <algorithm>
Expand All @@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include "c_types/ii_t_rt.h"

/** @file minimumDegreeOrdering.hpp
/** @file minDegreeOrdering.hpp
* @brief The main file which calls the respective boost function.
*
* Contains actual implementation of the function and the calling
Expand All @@ -61,20 +61,20 @@ namespace pgrouting {
namespace functions {

template <class G>
class MinimumDegreeOrdering : public Pgr_messages {
class MinDegreeOrdering : public Pgr_messages {
public:
typedef typename G::V V;
typedef typename G::E E;
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph;
typedef boost::graph_traits<Graph>::vertices_size_type size_type;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;

/** @name MinimumDegreeOrdering
/** @name MinDegreeOrdering
* @{
*
*/

/** @brief minimumDegreeOrdering function
/** @brief minDegreeOrdering function
*
* It does all the processing and returns the results.
*
Expand All @@ -87,7 +87,7 @@ class MinimumDegreeOrdering : public Pgr_messages {
*/

std::vector<II_t_rt>
minimumDegreeOrdering(G &graph) {
minDegreeOrdering(G &graph) {
std::vector<II_t_rt>results;

// map which store the indices with their nodes.
Expand Down Expand Up @@ -156,4 +156,4 @@ class MinimumDegreeOrdering : public Pgr_messages {
} // namespace functions
} // namespace pgrouting

#endif // INCLUDE_ORDERING_MINIMUMDEGREEORDERING_HPP_
#endif // INCLUDE_ORDERING_MINDEGREEORDERING_HPP_
4 changes: 1 addition & 3 deletions include/process/ordering_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <cstddef>
#include <cstdint>
#include <stdbool.h>
using Edge_t = struct Edge_t;
using II_t_rt = struct II_t_rt;
#else
#include <stddef.h>
#include <stdint.h>
typedef struct Edge_t Edge_t;
typedef struct II_t_rt II_t_rt;
#endif

#ifdef __cplusplus
extern "C" {
#endif

void pgr_process_ordering(const Edge_t*, size_t, int64_t, int64_t, II_t_rt **, size_t *);
void pgr_process_ordering(const char*, int64_t, II_t_rt **, size_t *);

#ifdef __cplusplus
}
Expand Down
25 changes: 12 additions & 13 deletions locale/en/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pgRouting v3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-14 12:05+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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -4044,6 +4044,11 @@ msgid ""
"pgr_bellmanFord"
msgstr ""

msgid ""
"`#2908 <https://github.com/pgRouting/pgrouting/issues/2908>`__ "
"pgr_binaryBreadthFirstSearch"
msgstr ""

msgid ""
"`#2910 <https://github.com/pgRouting/pgrouting/issues/2910>`__ "
"pgr_edwardMoore"
Expand Down Expand Up @@ -4490,6 +4495,9 @@ msgstr ""
msgid ":doc:`pgr_bellmanFord` [3]_"
msgstr ""

msgid ":doc:`pgr_binaryBreadthFirstSearch` [3]_"
msgstr ""

msgid ":doc:`pgr_dagShortestPath` [3]_"
msgstr ""

Expand Down Expand Up @@ -8952,9 +8960,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
Expand Down Expand Up @@ -9007,15 +9015,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 "
"<https://www.boost.org/libs/graph/doc/breadth_first_search.html>`__"
Expand Down
Loading
Loading