reverse_cuthill_mckee#
- scipy.sparse.csgraph.reverse_cuthill_mckee(graph, symmetric_mode=False)#
Gibt das Permutationsarray zurück, das eine spärliche CSR- oder CSC-Matrix in Reverse-Cuthill-McKee-Reihenfolge sortiert.
Standardmäßig, bei
symmetric_mode=False, wird angenommen, dass die Eingabematrix nicht symmetrisch ist und die MatrixA+A.Tverarbeitet wird. Wenn Sie sicher sind, dass die Matrix strukturell symmetrisch ist (die Werte der Matrixelemente spielen keine Rolle), setzen Siesymmetric_mode=True.- Parameter:
- graphspärliches Array oder spärliche Matrix
Eingabe im spärlichen CSC- oder CSR-Array- oder Matrixformat.
- symmetric_modebool, optional
Ist garantiert, dass die Eingabematrix symmetrisch ist.
- Rückgabe:
- permndarray
Array von permotierten Zeilen- und Spaltenindizes.
Hinweise
Hinzugefügt in Version 0.15.0.
Referenzen
E. Cuthill und J. McKee, „Reducing the Bandwidth of Sparse Symmetric Matrices“, ACM ‘69 Proceedings of the 1969 24th national conference, (1969).
Beispiele
>>> 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) <Compressed Sparse Row sparse array of dtype 'int64' with 5 stored elements and shape (4, 4)> Coords Values (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)