本文簡要介紹 python 語言中 scipy.sparse.csgraph.csgraph_from_masked
的用法。
用法:
scipy.sparse.csgraph.csgraph_from_masked(graph)#
從掩碼數組構造 CSR-format 圖。
- graph: MaskedArray
輸入圖。形狀應該是(n_nodes,n_nodes)。
- csgraph: csr_matrix
圖的壓縮稀疏表示,
參數 ::
返回 ::
例子:
>>> import numpy as np >>> from scipy.sparse.csgraph import csgraph_from_masked
>>> graph_masked = np.ma.masked_array(data =[ ... [0, 1, 2, 0], ... [0, 0, 0, 1], ... [0, 0, 0, 3], ... [0, 0, 0, 0] ... ], ... mask=[[ True, False, False, True], ... [ True, True, True, False], ... [ True, True, True, False], ... [ True, True, True, True]], ... fill_value = 0)
>>> csgraph_from_masked(graph_masked) <4x4 sparse matrix of type '<class 'numpy.float64'>' with 4 stored elements in Compressed Sparse Row format>
相關用法
- Python SciPy csgraph.csgraph_from_dense用法及代碼示例
- Python SciPy csgraph.csgraph_to_dense用法及代碼示例
- Python SciPy csgraph.csgraph_to_masked用法及代碼示例
- Python SciPy csgraph.csgraph_masked_from_dense用法及代碼示例
- Python SciPy csgraph.connected_components用法及代碼示例
- Python SciPy csgraph.construct_dist_matrix用法及代碼示例
- Python SciPy csgraph.min_weight_full_bipartite_matching用法及代碼示例
- Python SciPy csgraph.minimum_spanning_tree用法及代碼示例
- Python SciPy csgraph.breadth_first_order用法及代碼示例
- Python SciPy csgraph.dijkstra用法及代碼示例
- Python SciPy csgraph.breadth_first_tree用法及代碼示例
- Python SciPy csgraph.floyd_warshall用法及代碼示例
- Python SciPy csgraph.bellman_ford用法及代碼示例
- Python SciPy csgraph.maximum_flow用法及代碼示例
- Python SciPy csgraph.shortest_path用法及代碼示例
- Python SciPy csgraph.reconstruct_path用法及代碼示例
- Python SciPy csgraph.johnson用法及代碼示例
- Python SciPy csgraph.maximum_bipartite_matching用法及代碼示例
- Python SciPy csgraph.depth_first_order用法及代碼示例
- Python SciPy csgraph.reverse_cuthill_mckee用法及代碼示例
- 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.csgraph_from_masked。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。