code: def _connected_components(M):
      """Returns the list of connected vertices of the graph when
      a square matrix is viewed as a weighted graph.
  
      Examples
      ========
  
      >>> from sympy import Matrix
      >>> A = Matrix([
      ...     [66, 0, 0, 68, 0, 0, 0, 0, 67],
      ...     [0, 55, 0, 0, 0, 0, 54, 53, 0],
      ...     [0, 0, 0, 0, 1, 2, 0, 0, 0],
      ...     [86, 0, 0, 88, 0, 0, 0, 0, 87],
      ...     [0, 0, 10, 0, 11, 12, 0, 0, 0],
      ...     [0, 0, 20, 0, 21, 22, 0, 0, 0],
      ...     [0, 45, 0, 0, 0, 0, 44, 43, 0],
      ...     [0, 35, 0, 0, 0, 0, 34, 33, 0],
      ...     [76, 0, 0, 78, 0, 0, 0, 0, 77]])
      >>> A.connected_components()
      [[0, 3, 8], [1, 6, 7], [2, 4, 5]]
  
      Notes
      =====
  
      Even if any symbolic elements of the matrix can be indeterminate
      to be zero mathematically, this only takes the account of the
      structural aspect of the matrix, so they will considered to be
      nonzero.
      """
      if not M.is_square:
          raise NonSquareMatrixError
  
      V = range(M.rows)
      E = sorted(M.todok().keys())
      return connected_components((V, E))
  
imports: from sympy.utilities.iterables import flatten, connected_components, strongly_connected_components
  from .exceptions import NonSquareMatrixError
label_desc: Use image node_id 1 for calling a global function with example usage: _connected_components(M) and returns: connected_components