code: def is_connected(C, directed=True):
      
      if isdense(C):
          return sparse.connectivity.is_connected(csr_matrix(C), directed=directed)
      else:
          return sparse.connectivity.is_connected(C, directed=directed)
docs: Check connectivity of the given matrix.
  
      Parameters
      ----------
      C : scipy.sparse matrix
          Count matrix specifying edge weights.
      directed : bool, optional
         Whether to compute connected components for a directed or
         undirected graph. Default is True.
  
      Returns
      -------
      is_connected: bool
          True if C is connected, False otherwise.
  
      See also
      --------
      largest_connected_submatrix
  
      Notes
      -----
      A count matrix is connected if the graph having the count matrix
      as adjacency matrix has a single connected component. Connectivity
      of a graph can be efficiently checked using Tarjan's algorithm.
  
      References
      ----------
      .. [1] Tarjan, R E. 1972. Depth-first search and linear graph
          algorithms. SIAM Journal on Computing 1 (2): 146-160.
  
      Examples
      --------
  
      >>> import numpy as np
      >>> from msmtools.estimation import is_connected
  
      >>> C = np.array([[10, 1, 0], [2, 0, 3], [0, 0, 4]])
      >>> is_connected(C)
      False
  
      >>> is_connected(C, directed=False)
      True