# pgRouting Manual (3.6)

## pgr_cuthillMckeeOrdering - Experimental

# `pgr_cuthillMckeeOrdering` - Experimental

`pgr_cuthillMckeeOrdering` — Returns the reverse Cuthill-Mckee ordering of an undirected graphs

Boost Graph Inside

Warning

Possible server crash

- These functions might create a server crash

Warning

Experimental functions

- They are not officially of the current release.

- They likely will not be officially be part of the next release:

  - The functions might not make use of ANY-INTEGER and ANY-NUMERICAL

  - Name might change.

  - Signature might change.

  - Functionality might change.

  - pgTap tests might be missing.

  - Might need c/c++ coding.

  - May lack documentation.

  - Documentation if any might need to be rewritten.

  - Documentation examples might need to be automatically generated.

  - Might need a lot of feedback from the comunity.

  - Might depend on a proposed function of pgRouting

  - Might depend on a deprecated function of pgRouting

Availability

- Version 3.4.0

  - New experimental function

## Description

In numerical linear algebra, the Cuthill-McKee algorithm (CM), named after Elizabeth Cuthill and James McKee, is an algorithm to permute a sparse matrix that has a symmetric sparsity pattern into a band matrix form with a small bandwidth.

The vertices are basically assigned a breadth-first search order, except that at each step, the adjacent vertices are placed in the queue in order of increasing degree.

The main Characteristics are:

- The implementation is for undirected graphs.

- The bandwidth minimization problems are considered NP-complete problems.

- The running time complexity is: \(O(m log(m)|V|)\)

  - where \(|V|\) is the number of vertices,

  - \(m\) is the maximum degree of the vertices in the graph.

## Signatures

pgr_cuthillMckeeOrdering(Edges SQL)
Returns set of `(seq, node)`
OR EMPTY SET

Example:

  Graph ordering of pgRouting Sample Data

    SELECT * FROM pgr_cuthillMckeeOrdering(
      'SELECT id, source, target, cost, reverse_cost FROM edges'
      );
     seq | node
    -----+------
       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
    (17 rows)

## Parameters

Parameter | Type | Description
--- | --- | ---
Edges SQL | `TEXT` | Edges SQL as described below.

## Inner Queries

### Edges SQL

Column | Type | Default | Description
--- | --- | --- | ---
`id` | ANY-INTEGER |  | Identifier of the edge.
`source` | ANY-INTEGER |  | Identifier of the first end point vertex of the edge.
`target` | ANY-INTEGER |  | Identifier of the second end point vertex of the edge.
`cost` | ANY-NUMERICAL |  | Weight of the edge (`source`, `target`)

`reverse_cost`

ANY-NUMERICAL

-1

Weight of the edge (`target`, `source`)

- When negative: edge (`target`, `source`) does not exist, therefore it’s not part of the graph.

Where:

ANY-INTEGER:

  `SMALLINT`, `INTEGER`, `BIGINT`

ANY-NUMERICAL:

  `SMALLINT`, `INTEGER`, `BIGINT`, `REAL`, `FLOAT`

## 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

- The queries use the Sample Data network.

- Boost: Cuthill-McKee Ordering

- Wikipedia: Cuthill-McKee Ordering

Indices and tables

- Index

- Search Page