src/main/java/pt/it/av/tnav/ml/clustering/partition/Kmedoids.java
private static <D extends Distance<D>> int closestCluster(final D dp, final List<D> centers) {
    int rv = 0;
    double d = centers.get(0).distanceTo(dp);

    for (int i = 1; i < centers.size(); i++) {
      final double tmp = centers.get(i).distanceTo(dp);
      if (tmp < d) {
        d = tmp;
        rv = i;
      }
    }

    return rv;
  }
/**
   * Returns the index of the closest {@link Cluster}.
   * 
   * @param dp      data point
   * @param centers {@list} of cluster centers
   * @param <D>     {@link Distance}
   * @return the index of the closest cluster
   */
Returns the index of the closest  Cluster.

@param dp      data point
@param centers  of cluster centers
@param       Distance
@return the index of the closest cluster
Returns the index of the closest Cluster . @param dp data point @param centers of cluster centers @param Distance @return the index of the closest cluster
private static <D extends Distance<D>> int closestCluster(final D dp, final List<D> centers) {
    int rv = 0;
    double d = centers.get(0).distanceTo(dp);
    for (int i = 1; i < centers.size(); i++) {
      final double tmp = centers.get(i).distanceTo(dp);
      if (tmp < d) {
        d = tmp;
        rv = i;
      }
    }
    return rv;
  }
private static < D extends Distance < D > > int closestCluster ( final D dp , final List < D > centers ) { int rv = 0 ; double d = centers . get ( 0 ) . distanceTo ( dp ) ; for ( int i = 1 ; i < centers . size ( ) ; i ++ ) { final double tmp = centers . get ( i ) . distanceTo ( dp ) ; if ( tmp < d ) { d = tmp ; rv = i ; } } return rv ; }
Returns the index of the closest {@link Cluster}.
Returns the index of the closest { @link Cluster } .