十三.Csgraph子模块
2.内容
(4)其他:
分析稀疏图中的"连通分量"(Connected Component):[<n_components>,<labels>=]scipy.sparse.csgraph.connected_components(<csgraph>[,directed=True,connection='weak',return_labels=True])
#参数说明:
csgraph:指定稀疏图;为N×N sparse matrix/N×N ndarray/N×N dense matrix
directed:指定<csgraph>是否为有向图;为bool
connection:指定有向图使用的连通类型;为"weak"/"strong"
#Nodes i and j are strongly connected if a path exists both from i to j and from j to i
#对无向图(directed=False时)无效
return_labels:指定是否返回<labels>;为bool
n_components:返回图中的连通分量数;为int
labels:返回连通分量的标签;为1×N ndarray
######################################################################################################################
求稀疏有向图的"拉普拉斯矩阵"(Laplacian Matrix):[<lap>,<diag>=]scipy.sparse.csgraph.laplacian(<csgraph>[,normed=False,return_diag=False,use_out_degree=False])
#参数说明:<csgraph>同scipy.sparse.csgraph.connected_components()
normed:为True,则求"对称正规化拉普拉斯矩阵"(Symmetric Normalized Laplacian Matrix)
return_diag:指定是否返回<diag>;为bool
use_out_degree:为True,使用"出度"(Out-Degree)
为False,使用"入度"(In-Degree)
#仅当<csgraph>非对称时有效
lap:返回拉普拉斯矩阵;为N×N sparse matrix/N×N ndarray
diag:返回<lap>的对角线;为1×N ndarray
######################################################################################################################
求"最小生成树"(Minimum Spanning Tree):[<span_tree>=]scipy.sparse.csgraph.minimum_spanning_tree(<csgraph>[,overwrite=False])
#参数说明:其他参数同scipy.sparse.csgraph.shortest_path()
span_tree:返回最小生成树;为N×N CSR sparse matrix
######################################################################################################################
执行"RCM算法"(Reverse-Cuthill McKee Algorithm):[<perm>=]scipy.sparse.csgraph.reverse_cuthill_mckee(<graph>[,symmetric_mode=False])
#参数说明:
graph:指定原稀疏图;为CSC sparse matrix/CSR sparse matrix
symmetric_mode:指定<graph>是否保证对称;为bool
perm:返回置换矩阵;为ndarray
######################################################################################################################
求解"最大流问题"(Maximum Flow Problem):[<res>=]scipy.sparse.csgraph.maximum_flow(<csgraph>,<source>,<sink>)
#参数说明:
csgraph:指定原稀疏图;为CSR sparse matrix
source:指定"源点"/"发点"(Source Vertex);为int
sink:指定"汇点"/"收点"(Sink Vertex);为int
res:返回最大流;为MaximumFlowResult
######################################################################################################################
Returns a matching of a bipartite graph whose cardinality is as least that of any given matching of the graph:[<perm>=]scipy.sparse.csgraph.maximum_bipartite_matching(<graph>[,perm_type='row'])
######################################################################################################################
Returns the minimum weight full matching of a bipartite graph:[<row_ind>,<col_ind>=]scipy.sparse.csgraph.min_weight_full_bipartite_matching(<biadjacency_matrix>[,maximize=False])
######################################################################################################################
求"Structural Rank":[<rank>=]scipy.sparse.csgraph.structural_rank(<graph>)
#参数说明:其他参数同scipy.sparse.csgraph.breadth_first_order()
graph:指定稀疏矩阵;为sparse matrix
rank:返回结果;为int
十四.Linalg子模块
1.简介:
其中定义