You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating the k-nearest neighbors graph for the k-nn approximation of the Fermat distance, we compute the k-nn of each node and create the graph by doing
def create_adj_matrix(self, distances):
k = self.k
n = distances.shape[0]
rows = []
columns = []
values = []
for i in range(n):
smallest_values_and_columns = heapq.nsmallest(k, zip(distances[i].tolist(), list(range(n))))
vs, cs = zip(*smallest_values_and_columns)
rows.extend([i]*k)
columns.extend(cs)
values.extend(vs)
return csr_matrix((values+values, (rows+columns, columns+rows)), shape=(n, n))
The last line of the code, after the return statement, duplicates some of the edges that results in not a redundant edge, but instead add both weights in the same edge. For example,
When creating the k-nearest neighbors graph for the k-nn approximation of the Fermat distance, we compute the k-nn of each node and create the graph by doing
The last line of the code, after the
return
statement, duplicates some of the edges that results in not a redundant edge, but instead add both weights in the same edge. For example,will return a distance matrix with a
2
for the distance between the first two nodes, since the first and second node are both 2-nn of the other.I currently solve this issue by replacing
by
This change corresponds to commit 2aac722
The text was updated successfully, but these errors were encountered: