code: def merge_size_fill(tsize = 8, tfill = 8):
      
      assert tsize >= 0, "tsize must be nonnegative"
      assert tfill >= 0, "tfill must be nonnegative"
      
      def fmerge(ccp,cck,np,nk):
          """
          Supernodal merge heuristic.
  
             d = fmerge(Jp, Jk, Np, Nk)
  
          PURPOSE
          Returns true if either (i) supernode k and supernode par(k)
          are both of size at most %i, or (ii), merging supernodes
          par(k) and k induces at most %i edges.
  
          ARGUMENTS
          Jp        integer; size of parent clique
  
          Jk        integer; size of child clique
  
          Np        integer; size of parent supernode 
  
          Nk        integer; size of child supernode
           
          RETURNS
          d         boolean
          """
          fill = (ccp - (cck - nk))*nk
          if fill <= tfill or (nk <= tsize and np <= tsize):
              return True
          else:
              return False
      # insert parameters into docstring of fmerge and return fmerge
      fmerge.__doc__ %= (tsize, tfill)
      return fmerge
docs: Simple heuristic for supernodal amalgamation (clique
      merging). 
  
      Returns a function that returns `True` if either (i) supernode k and
      supernode par(k) are both of size at most `tsize`, or (ii),
      merging supernodes par[k] and k induces at most `tfill` nonzeros
      in the lower triangular part of the sparsity pattern.
  
      :param tsize:   nonnegative integer; threshold for merging based on supernode sizes
      :param tfill:   nonnegative integer; threshold for merging based on induced fill