code: def dbscan(points, eps, minpts):
      
      next_label = 0
      n = len(points)
      labels = [None] * n
  
      distance_matrix = compute_distance_matrix(points)
      neighbors = [get_neighbors(distance_matrix, i, eps) for i in range(n)]
  
      for i in range(n):
          if labels[i] is not None:
              continue
  
          if len(neighbors[i]) < minpts:
              continue
  
          labels[i] = next_label
          candidates = [i]
          while len(candidates) > 0:
              c = candidates.pop()
  
              for j in neighbors[c]:
                  if labels[j] is None:
                      labels[j] = next_label
                      if len(neighbors[j]) >= minpts:
                          candidates.append(j)
  
          next_label += 1
  
      return labels
docs: Implementation of [DBSCAN]_ (*A density-based algorithm for discovering
      clusters in large spatial databases with noise*). It accepts a list of
      points (lat, lon) and returns the labels associated with the points.
  
      References
      ----------
      .. [DBSCAN] Ester, M., Kriegel, H. P., Sander, J., & Xu, X. (1996, August).
          A density-based algorithm for discovering clusters in large
          spatial databases with noise. In Kdd (Vol. 96, No. 34, pp. 226-231).