Agglomerative clustering starts with every point in its own cluster and repeatedly merges the two closest clusters. The linkage defines the distance between two clusters:
"single": the closest pair of points (finds long chains)"complete": the farthest pair of points (finds compact blobs)"average": the mean distance over all pairsImplement agglomerative(X, n_clusters, linkage="single") with Euclidean distances, returning integer labels. Keep the clusters in a list ordered by their smallest member index. At each step, merge the closest pair; break ties by choosing the pair (i, j) that comes first in that list order. Number the final clusters 0, 1, … in order of their smallest member.
Also return the merge history: implement merge_distances(X, linkage), the list of linkage distances of the n − 1 merges, in order.