def distance(cluster, method = 0)
      d = 0
      norm = 0

      cluster.lengths.each do |elem1|
        lengths.each do |elem2|
          if method == 1
            d += elem1[1] * elem2[1] * (elem1[0] - elem2[0]).abs
            norm += elem1[1] * elem2[1]
          else
            d += (elem1[0] - elem2[0]).abs
            norm = cluster.lengths.length * lengths.length
          end
        end
      end

      # group average distance
      d /= (norm + 0.0)
      d.round(4)
    end
def distance(cluster, method = 0)
      d = 0
      norm = 0

      cluster.lengths.each do |elem1|
        lengths.each do |elem2|
          if method == 1
            d += elem1[1] * elem2[1] * (elem1[0] - elem2[0]).abs
            norm += elem1[1] * elem2[1]
          else
            d += (elem1[0] - elem2[0]).abs
            norm = cluster.lengths.length * lengths.length
          end
        end
      end

      # group average distance
      d /= (norm + 0.0)
      d.round(4)
    end
Returns the euclidian distance between the current cluster and the one
 given as parameter
 Params:
 +cluster+: Cluster object
 +method+: 0 or 1
 method = 0: do not into condseideration duplicate values
 method = 1: average linkage clusterization