code: def connected_components(G):
      
      G = asgraph(G)
      N = G.shape[0]
  
      components = np.empty(N, G.indptr.dtype)
  
      fn = amg_core.connected_components
      fn(N, G.indptr, G.indices, components)
  
      return components
docs: Compute the connected components of a graph.
  
      The connected components of a graph G, which is represented by a
      symmetric sparse matrix, are labeled with the integers 0,1,..(K-1) where
      K is the number of components.
  
      Parameters
      ----------
      G : symmetric matrix, preferably in sparse CSR or CSC format
          The nonzeros of G represent the edges of an undirected graph.
  
      Returns
      -------
      components : ndarray
          An array of component labels for each vertex of the graph.
  
      Notes
      -----
      If the nonzero structure of G is not symmetric, then the
      result is undefined.
  
      Examples
      --------
      >>> from pyamg.graph import connected_components
      >>> print connected_components( [[0,1,0],[1,0,1],[0,1,0]] )
      [0 0 0]
      >>> print connected_components( [[0,1,0],[1,0,0],[0,0,0]] )
      [0 0 1]
      >>> print connected_components( [[0,0,0],[0,0,0],[0,0,0]] )
      [0 1 2]
      >>> print connected_components( [[0,1,0,0],[1,0,0,0],[0,0,0,1],[0,0,1,0]] )
      [0 0 1 1]