SciPy

scipy.sparse.csgraph.reverse_cuthill_mckee

scipy.sparse.csgraph.reverse_cuthill_mckee(graph, symmetric_mode=False)

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

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 matrix

Input sparse in CSC or CSR sparse matrix format.

symmetric_mode : bool, optional

Is input matrix guaranteed to be symmetric.

Returns:

perm : ndarray

Array of permuted row and column indices.

Notes

New in version 0.15.0.

References

E. Cuthill and J. McKee, “Reducing the Bandwidth of Sparse Symmetric Matrices”, ACM ‘69 Proceedings of the 1969 24th national conference, (1969).