cupyx.scipy.sparse.csgraph.connected_components#
- cupyx.scipy.sparse.csgraph.connected_components(csgraph, directed=True, connection='weak', return_labels=True)[source]#
Analyzes the connected components of a sparse graph
- Parameters
csgraph (cupy.ndarray of cupyx.scipy.sparse.csr_matrix) – The adjacency matrix representing connectivity among nodes.
directed (bool) – If
True
, it operates on a directed graph. IfFalse
, it operates on an undirected graph.connection (str) –
'weak'
or'strong'
. For directed graphs, the type of connection to use. Nodes i and j are “strongly” connected only when a path exists both from i to j and from j to i. Ifdirected
isFalse
, this argument is ignored.return_labels (bool) – If
True
, it returns the labels for each of the connected components.
- Returns
If
return_labels
==True
, returns a tuple(n, labels)
, wheren
is the number of connected components andlabels
is labels of each connected components. Otherwise, returnsn
.- Return type