cupyx.scipy.sparse.csgraph.connected_components#
- cupyx.scipy.sparse.csgraph.connected_components(csgraph, directed=True, connection='weak', return_labels=True)[源代码][源代码]#
分析稀疏图的连通分量
- 参数:
csgraph (cupy.ndarray of cupyx.scipy.sparse.csr_matrix) – 表示节点之间连接性的邻接矩阵。
directed (bool) – 如果
True,它在一个有向图上操作。如果False,它在一个无向图上操作。connection (str) –
'weak'或'strong'。对于有向图,使用的连接类型。节点 i 和 j 只有在从 i 到 j 和从 j 到 i 都存在路径时才被“强”连接。如果directed为False,则忽略此参数。return_labels (bool) – 如果
True,它返回每个连接组件的标签。
- 返回:
如果
return_labels==True,返回一个元组(n, labels),其中n是连通分量的数量,而labels是每个连通分量的标签。否则,返回n。- 返回类型: