def cs_graph_components(x):
 try:
  shape = x.shape
 except AttributeError:
  raise ValueError(_msg0)
 if (not ((len(x.shape) == 2) and (x.shape[0] == x.shape[1]))):
  raise ValueError((_msg1 % x.shape))
 if isspmatrix(x):
  x = x.tocsr()
 else:
  x = csr_matrix(x)
 label = np.empty((shape[0],), dtype=x.indptr.dtype)
 n_comp = _cs_graph_components(shape[0], x.indptr, x.indices, label)
 return (n_comp, label)

def cs_graph_components ( x ) : try : shape = x . shape except AttributeError : raise ValueError ( _msg0 ) if ( not ( ( len ( x . shape ) == 2 ) and ( x . shape [ 0 ] == x . shape [ 1 ] ) ) ) : raise ValueError ( ( _msg1 % x . shape ) ) if isspmatrix ( x ) : x = x . tocsr ( ) else : x = csr_matrix ( x ) label = np . empty ( ( shape [ 0 ] , ) , dtype = x . indptr . dtype ) n_comp = _cs_graph_components ( shape [ 0 ] , x . indptr , x . indices , label ) return ( n_comp , label )
determine connected components of a graph stored as a compressed sparse row or column matrix .