distances[(clust[i].id,clust[j].id)]=distance(clust[i].vec,clust[j].vec)
distances - a dictionary where the keys are tuples , probably integers, and the value is the distance measured between them by the distance function. in the second line:
d=distances[(clust[i].id,clust[j].id)]
the d variable is simply assigned to this distance, getting the dictionary value just assigned. other answers contain a summary of the dictionary.
source share