knn_weights takes a weight vector w and sets the ith
component w[i] to zero if either of the two corresponding nodes
is not among the other's k nearest neighbors.
knn_weights(w, k, n)w[i] denotes the weight used between the ith pair of centroids. The weights are in dictionary order.