|
| 1 | +.. |
| 2 | + **************************************************************************** |
| 3 | + pgRouting Manual |
| 4 | + Copyright(c) pgRouting Contributors |
| 5 | +
|
| 6 | + This documentation is licensed under a Creative Commons Attribution-Share |
| 7 | + Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/ |
| 8 | + **************************************************************************** |
| 9 | + |
| 10 | +.. index:: |
| 11 | + single: Ordering Family ; pgr_kingOrdering |
| 12 | + single: kingOrdering - Experimental on v4.0 |
| 13 | + |
| 14 | +| |
| 15 | +
|
| 16 | +``pgr_kingOrdering`` - Experimental |
| 17 | +=============================================================================== |
| 18 | + |
| 19 | +``pgr_kingOrdering`` — Returns the King ordering of an undirected graphs |
| 20 | + |
| 21 | +.. include:: experimental.rst |
| 22 | + :start-after: warning-begin |
| 23 | + :end-before: end-warning |
| 24 | + |
| 25 | +.. rubric:: Version 4.0.0 |
| 26 | + |
| 27 | + * New experimental function. |
| 28 | + |
| 29 | +Description |
| 30 | +------------------------------------------------------------------------------- |
| 31 | + |
| 32 | +In numerical linear algebra and graph theory, the King ordering algorithm |
| 33 | +is a heuristic designed to reorder the vertices of a graph so as to reduce |
| 34 | +its bandwidth. |
| 35 | + |
| 36 | +The method follows a breadth-first search (BFS) traversal,but with a refinement: |
| 37 | +at each step, the unvisited neighbors of the current vertex are inserted into |
| 38 | +the queue in ascending order of their pseudo-degree, where the pseudo-degree of |
| 39 | +a vertex is the number of edges connecting it to yet-unvisited vertices. This |
| 40 | +prioritization often yields a smaller bandwidth compared to simpler BFS orderings. |
| 41 | + |
| 42 | +**The main characteristics are:** |
| 43 | + |
| 44 | +- The implementation targets undirected graphs. |
| 45 | +- Bandwidth minimization is an NP-complete problem; King ordering provides a practical local minimization approach. |
| 46 | +- The time complexity is: :math:`O(m^2 \log(m)|E|)` |
| 47 | + |
| 48 | + - where :math:`|E|` is the number of edges, |
| 49 | + - :math:`m` is the maximum degree among all vertices. |
| 50 | + |
| 51 | +|Boost| Boost Graph Inside |
| 52 | + |
| 53 | +Signatures |
| 54 | +------------------------------------------------------------------------------ |
| 55 | + |
| 56 | +.. index:: |
| 57 | + single: kingOrdering - Experimental on v4.0 |
| 58 | + |
| 59 | +.. admonition:: \ \ |
| 60 | + :class: signatures |
| 61 | + |
| 62 | + | pgr_kingOrdering(`Edges SQL`_) |
| 63 | +
|
| 64 | + | Returns set of |result_node_order| |
| 65 | + | OR EMPTY SET |
| 66 | +
|
| 67 | +:Example: Graph ordering of pgRouting :doc:`sampledata` |
| 68 | + |
| 69 | +.. literalinclude:: kingOrdering.queries |
| 70 | + :start-after: -- q1 |
| 71 | + :end-before: -- q2 |
| 72 | + |
| 73 | +Parameters |
| 74 | +------------------------------------------------------------------------------- |
| 75 | + |
| 76 | +.. include:: pgRouting-concepts.rst |
| 77 | + :start-after: only_edge_param_start |
| 78 | + :end-before: only_edge_param_end |
| 79 | + |
| 80 | +Inner Queries |
| 81 | +------------------------------------------------------------------------------- |
| 82 | + |
| 83 | +Edges SQL |
| 84 | +............................................................................... |
| 85 | + |
| 86 | +.. include:: pgRouting-concepts.rst |
| 87 | + :start-after: basic_edges_sql_start |
| 88 | + :end-before: basic_edges_sql_end |
| 89 | + |
| 90 | +Result columns |
| 91 | +------------------------------------------------------------------------------- |
| 92 | + |
| 93 | +.. include:: pgr_cuthillMckeeOrdering.rst |
| 94 | + :start-after: node_ordering_start |
| 95 | + :end-before: node_ordering_end |
| 96 | + |
| 97 | +Additional Examples |
| 98 | +------------------------------------------------------------------------------- |
| 99 | + |
| 100 | +.. graphviz:: |
| 101 | + |
| 102 | + graph G { |
| 103 | + node [shape=circle, style=filled, fillcolor=white, color=black, fontcolor=black, fontsize=10]; |
| 104 | + edge [color=black, penwidth=1]; |
| 105 | + |
| 106 | + 4 -- 7; |
| 107 | + 7 -- 9; |
| 108 | + 7 -- 0; |
| 109 | + 0 -- 2; |
| 110 | + 2 -- 5; |
| 111 | + 5 -- 9; |
| 112 | + 9 -- 8; |
| 113 | + 9 -- 1; |
| 114 | + 5 -- 1; |
| 115 | + 9 -- 6; |
| 116 | + 6 -- 3; |
| 117 | + 1 -- 3; |
| 118 | + |
| 119 | + {rank=same; 4; 8; 6;} |
| 120 | + {rank=same; 7; 9; 3;} |
| 121 | + {rank=same; 0; 2; 5; 1;} |
| 122 | + } |
| 123 | + |
| 124 | +.. literalinclude:: kingOrdering.queries |
| 125 | + :start-after: -- q2 |
| 126 | + :end-before: -- q3 |
| 127 | + |
| 128 | +See Also |
| 129 | +------------------------------------------------------------------------------- |
| 130 | + |
| 131 | +* :doc:`sampledata` |
| 132 | +* `Boost: King Ordering |
| 133 | + <https://www.boost.org/libs/graph/doc/king_ordering.html>`__ |
| 134 | + |
| 135 | +.. rubric:: Indices and tables |
| 136 | + |
| 137 | +* :ref:`genindex` |
| 138 | +* :ref:`search` |
| 139 | + |
0 commit comments