本文简要介绍 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。