src/main/java/it/uniroma2/dicii/sabd/covidproject/Query3.java
/*
    * Given a trend coefficient value and a vector of centroids, identify the index of the centroid at minimum distance
    * */
Given a trend coefficient value and a vector of centroids, identify the index of the centroid at minimum distance
Given a trend coefficient value and a vector of centroids identify the index of the centroid at minimum distance
private static Tuple2<Integer, RegionData> assignRegionToCluster(Tuple2<Double,RegionData> trendRegion, Double[] centroids) {
        int minDistanceCentroid = 0;
        double minDistance = Double.MAX_VALUE;
        for (int i = 0; i < centroids.length; i++) {
            double distance = Math.abs(centroids[i] - trendRegion._1);
            if (distance < minDistance) {
                minDistance = distance;
                minDistanceCentroid = i;
            }
        }
        /*RegionData regionData = new RegionData();
        regionData.setName(trendRegion._2.getName());
        regionData.setTrendLineCoefficient(trendRegion._1);*/
        return new Tuple2<>(minDistanceCentroid, trendRegion._2);
    }
private static Tuple2 < Integer , RegionData > assignRegionToCluster ( Tuple2 < Double , RegionData > trendRegion , Double [ ] centroids ) { int minDistanceCentroid = 0 ; double minDistance = Double . MAX_VALUE ; for ( int i = 0 ; i < centroids . length ; i ++ ) { double distance = Math . abs ( centroids [ i ] - trendRegion . _1 ) ; if ( distance < minDistance ) { minDistance = distance ; minDistanceCentroid = i ; } } /*RegionData regionData = new RegionData();
        regionData.setName(trendRegion._2.getName());
        regionData.setTrendLineCoefficient(trendRegion._1);*/ return new Tuple2 < > ( minDistanceCentroid , trendRegion . _2 ) ; }
Given a trend coefficient value and a vector of centroids, identify the index of the centroid at minimum distance
Given a trend coefficient value and a vector of centroids identify the index of the centroid at minimum distance