code: def HEM_one_level(rr, cc, vv, rid, weights):
      nnz = rr.shape[0]
      N = rr[nnz - 1] + 1
  
      marked = np.zeros(N, np.bool_)
      rowstart = np.zeros(N, np.int32)
      rowlength = np.zeros(N, np.int32)
      cluster_id = np.zeros(N, np.int32)
  
      oldval = rr[0]
      count = 0
      clustercount = 0
  
      for ii in range(nnz):
          rowlength[count] = rowlength[count] + 1
          if rr[ii] > oldval:
              oldval = rr[ii]
              rowstart[count + 1] = ii
              count = count + 1
  
      for ii in range(N):
          tid = rid[ii]
          if not marked[tid]:
              wmax = 0.0
              rs = rowstart[tid]
              marked[tid] = True
              bestneighbor = -1
              for jj in range(rowlength[tid]):
                  nid = cc[rs + jj]
                  if marked[nid]:
                      tval = 0.0
                  else:
                      # First approach
                      if 2 == 1:
                          tval = vv[rs + jj] * (
                              1.0 / weights[tid] + 1.0 / weights[nid]
                          )
  
                      # Second approach
                      if 1 == 1:
                          Wij = vv[rs + jj]
                          Wii = vv[rowstart[tid]]
                          Wjj = vv[rowstart[nid]]
                          di = weights[tid]
                          dj = weights[nid]
                          tval = (
                              (2.0 * Wij + Wii + Wjj)
                              * 1.0
                              / (di + dj + 1e-9)
                          )
  
                  if tval > wmax:
                      wmax = tval
                      bestneighbor = nid
  
              cluster_id[tid] = clustercount
  
              if bestneighbor > -1:
                  cluster_id[bestneighbor] = clustercount
                  marked[bestneighbor] = True
  
              clustercount += 1
  
      return cluster_id
  
file_path: dgl/examples/pytorch/model_zoo/geometric/coarsening.py
imports: import numpy
  import scipy.sparse
  import sklearn.metrics
label_desc: Use image node_id 6 for calling a global function with example usage: HEM_one_level(rr, cc, vv, rid, weights) and returns: cluster_id