Skip to content
Merged
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
3 changes: 2 additions & 1 deletion doc/_static/page_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function createInfo(file, newat, altnames = '', removedat = '') {
this.removedat = removedat;
}

const versionsArr = ['3.8','3.7', '3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0'];
const versionsArr = ['4.0', '3.8','3.7', '3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0'];
var unsuportedArr = ['2.6', '2.5', '2.4', '2.3', '2.2', '2.1', '2.0'];
var titles = [
{k: 'en', v: ['Supported versions', 'Unsupported versions']},
Expand All @@ -15,6 +15,7 @@ var titles = [


var newpages = [
{v: '4.0', pages: ['pgr_sloanOrdering']},
{v: '3.8', pages: ['pgr_contractionDeadEnd', 'pgr_contractionLinear', 'pgr_separateCrossing',
'pgr_separateTouching']},

Expand Down
1 change: 1 addition & 0 deletions doc/ordering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SET(LOCAL_FILES
ordering-family.rst
pgr_cuthillMckeeOrdering.rst
pgr_topologicalSort.rst
pgr_sloanOrdering.rst
)

foreach (f ${LOCAL_FILES})
Expand Down
2 changes: 2 additions & 0 deletions doc/ordering/ordering-family.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Ordering - Family of functions
* :doc:`pgr_cuthillMckeeOrdering` - Return reverse Cuthill-McKee ordering of an undirected graph.
* :doc:`pgr_topologicalSort` - Linear ordering of the vertices for directed
acyclic graph.
* :doc:`pgr_sloanOrdering` - Returns the sloan ordering of an undirected graph.

.. official-end

Expand All @@ -32,6 +33,7 @@ Ordering - Family of functions

pgr_cuthillMckeeOrdering
pgr_topologicalSort
pgr_sloanOrdering

See Also
-------------------------------------------------------------------------------
Expand Down
101 changes: 101 additions & 0 deletions doc/ordering/pgr_sloanOrdering.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
..
****************************************************************************
pgRouting Manual
Copyright(c) pgRouting Contributors

This documentation is licensed under a Creative Commons Attribution-Share
Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
****************************************************************************

.. index::
single: Ordering Family ; pgr_sloanOrdering
single: pgr_sloanOrdering - Experimental on v4.0

|

``pgr_sloanOrdering`` - Experimental
===============================================================================

``pgr_sloanOrdering`` — Returns the sloan ordering of an undirected
graph

.. include:: experimental.rst
:start-after: warning-begin
:end-before: end-warning

.. rubric:: Availability

* Version 4.0.0

* New experimental function.


Description
-------------------------------------------------------------------------------

TBD

Signatures
------------------------------------------------------------------------------

.. index::
single: sloanOrdering - Experimental on v4.0

.. admonition:: \ \
:class: signatures

| pgr_sloanOrdering(`Edges SQL`_)

| Returns set of |result_node_order|
| OR EMPTY SET

:Example: Graph ordering of pgRouting :doc:`sampledata`

.. literalinclude:: sloanOrdering.queries
:start-after: -- q1
:end-before: -- q2

.. Parameters, Inner Queries & result columns

Parameters
-------------------------------------------------------------------------------

.. include:: pgRouting-concepts.rst
:start-after: only_edge_param_start
:end-before: only_edge_param_end

Inner Queries
-------------------------------------------------------------------------------

Edges SQL
...............................................................................

.. include:: pgRouting-concepts.rst
:start-after: basic_edges_sql_start
:end-before: basic_edges_sql_end

Result columns
-------------------------------------------------------------------------------

Returns set of ``(seq, node)``

=============== =========== ======================================
Column Type Description
=============== =========== ======================================
``seq`` ``BIGINT`` Sequence of the order starting from 1.
``node`` ``BIGINT`` New ordering in reverse order.
=============== =========== ======================================

See Also
-------------------------------------------------------------------------------

* :doc:`sampledata`
* `Boost: Sloan Ordering
<https://www.boost.org/libs/graph/doc/sloan_ordering.html>`__

.. rubric:: Indices and tables

* :ref:`genindex`
* :ref:`search`


57 changes: 2 additions & 55 deletions pgtap/ordering/sloan/edge_cases.pg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
BEGIN;

UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost);
SELECT CASE WHEN NOT min_version('4.0.0') THEN plan(1) ELSE plan(11) END;
SELECT CASE WHEN NOT min_version('4.0.0') THEN plan(1) ELSE plan(5) END;


CREATE OR REPLACE FUNCTION edge_cases()
Expand Down Expand Up @@ -58,6 +58,7 @@ SELECT * FROM pgr_sloanOrdering('SELECT id, source, target, cost, reverse_cost F
RETURN QUERY
SELECT set_eq('q3', $$VALUES (1,3), (2,7)$$, '3 -- 7 -- 3; Does not matter if 7 comes first or 3');


PERFORM todo_start('Its the same graph but giving different results');
-- 7 -- 3 -- 7; 2 vertices test (connected)

Expand All @@ -83,60 +84,6 @@ RETURN QUERY
SELECT set_eq('q5', $$VALUES (1, 3), (2, 7)$$, 'Should have both vertices');
PERFORM todo_end();

-- 3 vertices test

PREPARE q6 AS
SELECT id, source, target, cost, reverse_cost
FROM edges
WHERE id <= 2;

RETURN QUERY
SELECT set_eq('q9', $$VALUES (2, 6, 10, -1, 1), (1, 5, 6, 1, 1)$$, 'q9: Graph with three vertices 1, 2 and 3');

PREPARE r10 AS
SELECT *
FROM pgr_sloanOrdering('q9');

RETURN QUERY
SELECT set_eq('r10', $$VALUES (1, 5), (2, 6), (3, 10)$$, 'Basic test');


-- pgRouting sample data

CREATE TABLE expected_result (
seq BIGINT,
node BIGINT);

INSERT INTO expected_result (seq, node) VALUES
(1, 13),
(2, 14),
(3, 2),
(4, 4),
(5, 1),
(6, 9),
(7, 3),
(8, 8),
(9, 5),
(10, 7),
(11, 12),
(12, 6),
(13, 11),
(14, 17),
(15, 10),
(16, 16),
(17, 15);

PREPARE q11 AS
SELECT * FROM pgr_sloanOrdering(
'SELECT id, source, target, cost, reverse_cost FROM edges');

PREPARE r11 AS
SELECT * FROM expected_result;

IF version() LIKE '%SQL 14%' THEN
PERFORM todo('test failing with postgres 14',1);
END IF;
RETURN QUERY SELECT set_eq('q11','r11','sample data graph of pgRouting');

END;
$BODY$
Expand Down