Skip to content

Commit aa4d7ef

Browse files
authored
Merge pull request pgRouting#479 from bipashabg/week-10-sloanordering
week 10 sloan ordering
2 parents 2b41355 + cae1294 commit aa4d7ef

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

doc/ordering/pgr_sloanOrdering.rst

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
..
22
****************************************************************************
3-
pgRouting Manual
4-
Copyright(c) pgRouting Contributors
3+
pgRouting Manual
4+
Copyright(c) pgRouting Contributors
55
6-
This documentation is licensed under a Creative Commons Attribution-Share
7-
Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
6+
This documentation is licensed under a Creative Commons Attribution-Share
7+
8+
Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
89
****************************************************************************
910

1011
.. index::
@@ -33,10 +34,17 @@ graph
3334
Description
3435
-------------------------------------------------------------------------------
3536

36-
TBD
37+
The Sloan ordering algorithm reorders the vertices of a graph to reduce bandwidth, profile, and wavefront properties, which is particularly useful for sparse matrix computations and finite element analysis.
38+
*Finds a pseudoperipheral vertex pair to determine good starting points
39+
*Uses a priority-based algorithm that balances vertex degree and distance from the start vertex.
40+
*Aims to mininimize bandwidth (maximum difference between connected vertex indices.
41+
*The implementation is for undirected graphs
42+
*Typically produces better orderings than simple breadth-first approaches.
43+
|Boost| Boost Graph inside
3744
3845
Signatures
3946
------------------------------------------------------------------------------
47+
..rubric::Summary
4048

4149
.. index::
4250
single: sloanOrdering - Experimental on v4.0
@@ -49,7 +57,7 @@ Signatures
4957
| Returns set of |result_node_order|
5058
| OR EMPTY SET
5159
52-
:Example: Graph ordering of pgRouting :doc:`sampledata`
60+
:Example : Sloan ordering without specifying start vertex
5361

5462
.. literalinclude:: sloanOrdering.queries
5563
:start-after: -- q1
@@ -83,9 +91,46 @@ Returns set of ``(seq, node)``
8391
Column Type Description
8492
=============== =========== ======================================
8593
``seq`` ``BIGINT`` Sequence of the order starting from 1.
86-
``node`` ``BIGINT`` New ordering in reverse order.
94+
``node`` ``BIGINT`` New sloan ordering order.
8795
=============== =========== ======================================
8896

97+
Additional Examples
98+
99+
:Example: Sloan ordering of Original graph from Boost example (vertices 0-9).
100+
101+
..graphviz::
102+
103+
graph G{
104+
node[shape=circle, style=filled, fillcolor=lightblue, color=black, fontcolor=black, fontsize=12];
105+
edge[color=black, penwidth=1.5];
106+
107+
0 -- 3;
108+
0 -- 5;
109+
1 -- 2;
110+
1 -- 4;
111+
1 -- 6;
112+
1 -- 9;
113+
2 -- 3;
114+
2 -- 4;
115+
3 -- 5;
116+
3 -- 8;
117+
4 -- 6;
118+
5 -- 6;
119+
5 -- 7;
120+
6 -- 7;
121+
122+
{rank=same; 0; 8;}
123+
{rank=same; 3; 5; 7;}
124+
{rank=same; 2; 4; 6;}
125+
{rank=same; 1; 9;}
126+
127+
}
128+
129+
..literalinclude::sloanOrdering.queries
130+
:start-after: --q3
131+
:end-before: --q4
132+
133+
89134
See Also
90135
-------------------------------------------------------------------------------
91136

pgtap/ordering/sloan/edge_cases.pg

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
BEGIN;
2121

2222
UPDATE edges SET cost = sign(cost), reverse_cost = sign(reverse_cost);
23-
SELECT CASE WHEN NOT min_version('4.0.0') THEN plan(1) ELSE plan(5) END;
23+
SELECT CASE WHEN NOT min_version('4.0.0') THEN plan(1) ELSE plan(6) END;
2424

2525

2626
CREATE OR REPLACE FUNCTION edge_cases()
@@ -60,6 +60,7 @@ SELECT set_eq('q3', $$VALUES (1,3), (2,7)$$, '3 -- 7 -- 3; Does not matter if 7
6060

6161

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

6566
PREPARE q4 AS
@@ -84,6 +85,14 @@ RETURN QUERY
8485
SELECT set_eq('q5', $$VALUES (1, 3), (2, 7)$$, 'Should have both vertices');
8586
PERFORM todo_end();
8687

88+
-- 3 vertices test (connected)
89+
90+
PREPARE q6 AS
91+
SELECT *
92+
FROM pgr_sloanOrdering('SELECT id, source, target, cost, reverse_cost FROM edges WHERE id <= 2');
93+
94+
RETURN QUERY
95+
SELECT set_eq('q6', $$VALUES (6, 1), (7, 3), (4, 6)$$, 'Ordering of three connected vertices');
8796

8897
END;
8998
$BODY$

0 commit comments

Comments
 (0)