scipy.sparse.csgraph.connected_components函数

scipy.sparse.csgraph.connected_components(csgraph, directed=True, connection='weak', return_labels=True)

Parameters:
csgrapharray_like or sparse matrix
The N x N matrix representing the compressed sparse graph. The input csgraph will be converted to csr format for the calculation.
N x N矩阵表示压缩的稀疏图。
输入的csgraph将转换为csr格式进行计算。
directedbool, optional
If True (default), then operate on a directed graph: only move from point i to point j along paths csgraph[i, j]. If False, then find the shortest path on an undirected graph: the algorithm can progress from point i to j along csgraph[i, j] or csgraph[j, i].
如果为True(默认值),则对有向图进行操作:仅沿路径csgraph [i,j]从点i移至点j。
如果为False,则在无向图上找到最短路径:该算法可以从点i沿csgraph [i,j]或csgraph [j,i]前进到j。
connectionstr, optional
[‘weak’|’strong’]. For directed graphs, the type of connection to use. Nodes i and j are strongly connected if a path exists both from i to j and from j to i. A directed graph is weakly connected if replacing all of its directed edges with undirected edges produces a connected (undirected) graph. If directed == False, this keyword is not referenced.
[‘weak’|’strong’]
对于有向图,使用的连接类型。
如果同时存在从i到j以及从j到i的路径,则节点i和j将牢固连接。
如果将所有有向边替换为无向边,则有向图是弱连接的,从而产生一个连通(无向)图。
如果== False,则不引用此关键字。
return_labelsbool, optional
If True (default), then return the labels for each of the connected components.
如果为True(默认),则返回每个已连接组件的标签。

Returns:
n_components: int
The number of connected components.
连通域个数
labels: ndarray
The length-N array of labels of the connected components.

参考https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.connected_components.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值