本文簡要介紹 python 語言中 scipy.sparse.csgraph.reverse_cuthill_mckee
的用法。
用法:
scipy.sparse.csgraph.reverse_cuthill_mckee(graph, symmetric_mode=False)#
返回按 Reverse-Cuthill McKee 順序對稀疏 CSR 或 CSC 矩陣進行排序的排列數組。
默認情況下,
symmetric_mode=False
假設輸入矩陣不是對稱的並且適用於矩陣A+A.T
。如果保證矩陣在結構上是對稱的(矩陣元素的值無關緊要),則設置symmetric_mode=True
。- graph: 稀疏矩陣
以 CSC 或 CSR 稀疏矩陣格式輸入稀疏。
- symmetric_mode: 布爾型,可選
輸入矩陣是否保證對稱。
- perm: ndarray
排列的行和列索引數組。
參數 ::
返回 ::
注意:
參考:
E. Cuthill 和 J. McKee,“減少稀疏對稱矩陣的帶寬”,ACM '69 1969 年第 24 屆全國會議論文集,(1969 年)。
例子:
>>> 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)
相關用法
- Python SciPy csgraph.reconstruct_path用法及代碼示例
- Python SciPy csgraph.csgraph_to_dense用法及代碼示例
- Python SciPy csgraph.min_weight_full_bipartite_matching用法及代碼示例
- Python SciPy csgraph.minimum_spanning_tree用法及代碼示例
- Python SciPy csgraph.breadth_first_order用法及代碼示例
- Python SciPy csgraph.connected_components用法及代碼示例
- Python SciPy csgraph.dijkstra用法及代碼示例
- Python SciPy csgraph.breadth_first_tree用法及代碼示例
- Python SciPy csgraph.csgraph_from_dense用法及代碼示例
- Python SciPy csgraph.floyd_warshall用法及代碼示例
- Python SciPy csgraph.bellman_ford用法及代碼示例
- Python SciPy csgraph.csgraph_to_masked用法及代碼示例
- Python SciPy csgraph.maximum_flow用法及代碼示例
- Python SciPy csgraph.csgraph_masked_from_dense用法及代碼示例
- Python SciPy csgraph.shortest_path用法及代碼示例
- Python SciPy csgraph.johnson用法及代碼示例
- Python SciPy csgraph.maximum_bipartite_matching用法及代碼示例
- Python SciPy csgraph.depth_first_order用法及代碼示例
- Python SciPy csgraph.csgraph_from_masked用法及代碼示例
- Python SciPy csgraph.construct_dist_matrix用法及代碼示例
- Python SciPy csgraph.depth_first_tree用法及代碼示例
- Python SciPy csgraph.laplacian用法及代碼示例
- Python SciPy csgraph.structural_rank用法及代碼示例
- Python SciPy csc_array.diagonal用法及代碼示例
- Python SciPy csc_matrix.nonzero用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.sparse.csgraph.reverse_cuthill_mckee。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。