for j in range(0, len(cluster)): dist1 = ((cluster[j][0] - c[0][0])**2 + (cluster[j][1] - c[0][1])**2 + (cluster[j][2] - c[0][2])**2 + (cluster[j][3] - c[0][3])**2 + (cluster[j][4] - c[0][4])**2) * 0.5 dist2 = ((cluster[j][0] - c[1][0])**2 + (cluster[j][1] - c[1][1])**2 + (cluster[j][2] - c[1][2])**2 + (cluster[j][3] - c[1][3])**2 + (cluster[j][4] - c[1][4])**2) * 0.5 dist3 = ((cluster[j][0] - c[2][0])**2 + (cluster[j][1] - c[2][1])**2 + (cluster[j][2] - c[2][2])**2 + (cluster[j][3] - c[2][3])**2 + (cluster[j][4] - c[2][4])**2) * 0.5 dist4 = ((cluster[j][0] - c[3][0])**2 + (cluster[j][1] - c[3][1])**2 + (cluster[j][2] - c[3][2])**2 + (cluster[j][3] - c[3][3])**2 + (cluster[j][4] - c[3][4])**2) * 0.5 min_dist = HC.median_min(dist1, dist2, dist3, dist4) #print 'Minimum is :', min_dist if min_dist == dist1: phi[j] = 0 cluster1.append(cluster[j]) elif min_dist == dist2: phi[j] = 1 cluster2.append(cluster[j]) elif min_dist == dist3: phi[j] = 2 cluster3.append(cluster[j]) elif min_dist == dist4: phi[j] = 3 cluster4.append(cluster[j])
counter=0 while (1): counter=counter + 1 b=set(c) print 'The set c now is :', c for j in range(0, len(cluster)): dist1=((cluster[j][0]- c[0][0])**2 + (cluster[j][1] - c[0][1])**2 +(cluster[j][2] - c[0][2])**2 + (cluster[j][3] - c[0][3])**2+ (cluster[j][4] - c[0][4])**2)*0.5 dist2=((cluster[j][0]- c[1][0])**2 + (cluster[j][1] - c[1][1])**2 +(cluster[j][2] - c[1][2])**2 + (cluster[j][3] - c[1][3])**2+ (cluster[j][4] - c[1][4])**2)*0.5 dist3=((cluster[j][0]- c[2][0])**2 + (cluster[j][1] - c[2][1])**2 +(cluster[j][2] - c[2][2])**2 + (cluster[j][3] - c[2][3])**2+ (cluster[j][4] - c[2][4])**2)*0.5 dist4=((cluster[j][0]- c[3][0])**2 + (cluster[j][1] - c[3][1])**2 +(cluster[j][2] - c[3][2])**2 + (cluster[j][3] - c[3][3])**2+ (cluster[j][4] - c[3][4])**2)*0.5 min_dist=HC.median_min(dist1,dist2,dist3,dist4) #print 'Minimum is :', min_dist if min_dist==dist1: phi[j]=0 cluster1.append(cluster[j]) elif min_dist==dist2: phi[j]=1 cluster2.append(cluster[j]) elif min_dist==dist3: phi[j]=2 cluster3.append(cluster[j]) elif min_dist==dist4: phi[j]=3 cluster4.append(cluster[j])