nodes: 0, module; 1, function_definition; 2, function_name:connected_sets; 3, parameters; 4, block; 5, identifier:C; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:directed; 10, True; 11, comment:r"""Compute connected sets of microstates.
  
      Connected components for a directed graph with edge-weights
      given by the count 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
      -------
      cc : list of arrays of integers
          Each entry is an array containing all vertices (states) in the
          corresponding connected component. The list is sorted
          according to the size of the individual components. The
          largest connected set is the first entry in the list, lcc=cc[0].
  
      Notes
      -----
      Viewing the count matrix as the adjacency matrix of a (directed) graph
      the connected components are given by the connected components of that
      graph. Connected components of a graph can be efficiently computed
      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 connected_sets
  
      >>> C = np.array([[10, 1, 0], [2, 0, 3], [0, 0, 4]])
      >>> cc_directed = connected_sets(C)
      >>> cc_directed
      [array([0, 1]), array([2])]
  
      >>> cc_undirected = connected_sets(C, directed=False)
      >>> cc_undirected
      [array([0, 1, 2])]
  
      """; 12, call; 13, block; 14, else_clause; 15, identifier:isdense; 16, argument_list; 17, return_statement; 18, block; 19, identifier:C; 20, call; 21, return_statement; 22, attribute; 23, argument_list; 24, call; 25, attribute; 26, identifier:connected_sets; 27, call; 28, keyword_argument; 29, attribute; 30, argument_list; 31, identifier:sparse; 32, identifier:connectivity; 33, identifier:csr_matrix; 34, argument_list; 35, identifier:directed; 36, identifier:directed; 37, attribute; 38, identifier:connected_sets; 39, identifier:C; 40, keyword_argument; 41, identifier:C; 42, identifier:sparse; 43, identifier:connectivity; 44, identifier:directed; 45, identifier:directed
code: def connected_sets(C, directed=True):
      r"""Compute connected sets of microstates.
  
      Connected components for a directed graph with edge-weights
      given by the count 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
      -------
      cc : list of arrays of integers
          Each entry is an array containing all vertices (states) in the
          corresponding connected component. The list is sorted
          according to the size of the individual components. The
          largest connected set is the first entry in the list, lcc=cc[0].
  
      Notes
      -----
      Viewing the count matrix as the adjacency matrix of a (directed) graph
      the connected components are given by the connected components of that
      graph. Connected components of a graph can be efficiently computed
      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 connected_sets
  
      >>> C = np.array([[10, 1, 0], [2, 0, 3], [0, 0, 4]])
      >>> cc_directed = connected_sets(C)
      >>> cc_directed
      [array([0, 1]), array([2])]
  
      >>> cc_undirected = connected_sets(C, directed=False)
      >>> cc_undirected
      [array([0, 1, 2])]
  
      """
      if isdense(C):
          return sparse.connectivity.connected_sets(csr_matrix(C), directed=directed)
      else:
          return sparse.connectivity.connected_sets(C, directed=directed)