for i in range(0, len(point)): cluster += [[(x_coord[i], y_coord[i])]] """ Making copies of the cluster list for the 3 variants """ slink_cluster = cluster clink_cluster = cluster meanlink_cluster = cluster """ Mean-link Hierarchical clustering """ while len(meanlink_cluster) != 4: for i in range(0, len(meanlink_cluster)): for j in range(0, len(meanlink_cluster)): if meanlink_cluster[i] == meanlink_cluster[j]: continue else: tdist = HC.mean_link(meanlink_cluster[i], meanlink_cluster[j]) if tdist <= mean: mean = tdist #print 'min at this point is :', min c_cluster1 = meanlink_cluster[i] c_cluster2 = meanlink_cluster[j] meanlink_cluster.remove(c_cluster1) meanlink_cluster.remove(c_cluster2) meanlink_cluster.append(c_cluster1 + c_cluster2) mean = 999 meanlink_cluster1 = meanlink_cluster[0] meanlink_cluster2 = meanlink_cluster[1] meanlink_cluster3 = meanlink_cluster[2] meanlink_cluster4 = meanlink_cluster[3]
""" Making copies of the cluster list for the 3 variants """ slink_cluster=cluster clink_cluster=cluster meanlink_cluster=cluster """ Mean-link Hierarchical clustering """ while len(meanlink_cluster)!=4: for i in range(0,len(meanlink_cluster)): for j in range(0,len(meanlink_cluster)): if meanlink_cluster[i]==meanlink_cluster[j]: continue else: tdist=HC.mean_link(meanlink_cluster[i],meanlink_cluster[j]) if tdist <= mean: mean=tdist #print 'min at this point is :', min c_cluster1=meanlink_cluster[i] c_cluster2=meanlink_cluster[j] meanlink_cluster.remove(c_cluster1) meanlink_cluster.remove(c_cluster2) meanlink_cluster.append(c_cluster1 + c_cluster2) mean=999 meanlink_cluster1=meanlink_cluster[0] meanlink_cluster2=meanlink_cluster[1] meanlink_cluster3=meanlink_cluster[2]