我已經找到解決方案:
D =[x][y] #two dimencion array with distances between x and y
sorted_distance = sorted_distance(D) # all values apears in D, delete duplicates and sort from max to min value
for distance in sorted_distance:
V = D.keys()
E = []
for x in V:
for y in V:
if x==y: continue
if D[x][y]<=distance:
E.append((x,y))
G = Grapth(V,E)
connected_components = get_connected_components(G)
if len(connected_components)>1: # this value could be increase if result is not rewarding
return connected_components
可能與http://stats.stackexchange.com/questions/2717/clustering-with-a-distance-matrix – gdlmx
複製在我的問題importent是距離不是Euklides,更不用說我對距離有什麼想法。 K均值算法和我發現谷歌需要Euklides點之間的距離。 –