code: def maximal_independent_set(G, algo='serial', k=None):
      
      G = asgraph(G)
      N = G.shape[0]
  
      mis = np.empty(N, dtype='intc')
      mis[:] = -1
  
      if k is None:
          if algo == 'serial':
              fn = amg_core.maximal_independent_set_serial
              fn(N, G.indptr, G.indices, -1, 1, 0, mis)
          elif algo == 'parallel':
              fn = amg_core.maximal_independent_set_parallel
              fn(N, G.indptr, G.indices, -1, 1, 0, mis, sp.rand(N), -1)
          else:
              raise ValueError('unknown algorithm (%s)' % algo)
      else:
          fn = amg_core.maximal_independent_set_k_parallel
          fn(N, G.indptr, G.indices, k, mis, sp.rand(N), -1)
  
      return mis
docs: Compute a maximal independent vertex set for a graph.
  
      Parameters
      ----------
      G : sparse matrix
          Symmetric matrix, preferably in sparse CSR or CSC format
          The nonzeros of G represent the edges of an undirected graph.
      algo : {'serial', 'parallel'}
          Algorithm used to compute the MIS
              * serial   : greedy serial algorithm
              * parallel : variant of Luby's parallel MIS algorithm
  
      Returns
      -------
      S : array
          S[i] = 1 if vertex i is in the MIS
          S[i] = 0 otherwise
  
      Notes
      -----
      Diagonal entries in the G (self loops) will be ignored.
  
      Luby's algorithm is significantly more expensive than the
      greedy serial algorithm.