You are viewing an older version (1.17.1).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 1.17.1 / scipy / sparse / csgraph / _reordering / reverse_cuthill_mckee

cython_function_or_method

scipy.sparse.csgraph._reordering:reverse_cuthill_mckee

Signature

def reverse_cuthill_mckee(graph, symmetric_mode = False)

Summary

Returns the permutation array that orders a sparse CSR or CSC matrix in Reverse-Cuthill McKee ordering.

Extended Summary

It is assumed by default, symmetric_mode=False, that the input matrix is not symmetric and works on the matrix A+A.T. If you are guaranteed that the matrix is symmetric in structure (values of matrix elements do not matter) then set symmetric_mode=True.

Parameters

graph : sparse array or matrix

Input sparse in CSC or CSR sparse array or matrix format.

symmetric_mode : bool, optional

Is input matrix guaranteed to be symmetric.

Returns

perm : ndarray

Array of permuted row and column indices.

Notes

Examples

from scipy.sparse import csr_array
from scipy.sparse.csgraph import reverse_cuthill_mckee
✓
graph = [
[0, 1, 2, 0],
[0, 0, 0, 1],
[2, 0, 0, 3],
[0, 0, 0, 0]
]
graph = csr_array(graph)
✓
print(graph)
✗
reverse_cuthill_mckee(graph)
✓

Aliases

  • scipy.sparse.csgraph.reverse_cuthill_mckee