scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
reverse_cuthill_mckee(graph, symmetric_mode=False)

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 .

Notes

versionadded

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.

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

Examples

>>> from scipy.sparse import csr_matrix
... 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_matrix(graph)
... print(graph) (0, 1) 1 (0, 2) 2 (1, 3) 1 (2, 0) 2 (2, 3) 3
>>> reverse_cuthill_mckee(graph)
array([3, 2, 1, 0], dtype=int32)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse.csgraph._reordering.reverse_cuthill_mckee

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : None#None
type: <class 'builtin_function_or_method'>
Commit: