getLinkage method
Calculate linkage between 2 clusters
Clusters contains index of dataset
Implementation
double getLinkage(List<int> cluster1, List<int> cluster2) {
String hash = cluster1.length > cluster2.length
? "$cluster1-$cluster2"
: "$cluster2-$cluster1";
if (_cache.containsKey(hash)) return _cache[hash]!;
List<double> distanceList = [];
for (int i = 0; i < cluster1.length; i++) {
for (int j = 0; j < cluster2.length; j++) {
//get dataset index from the cluster
distanceList.add(getDistance(cluster1[i], cluster2[j]));
}
}
return _cache[hash] = linkageMeasure!(distanceList);
}