nan_search(self) function in nan.py
while(flag == 0):
for i in range(len(self.data)):
knn = self.findKNN(self.data[i], r, tree)
n = knn[-1]
self.knn[i].add(n)
if(i in self.knn[n] and (i, n) not in self.nan_edges):
self.nan_edges.add((i, n))
self.nan_edges.add((n, i))
self.nan_num[i] += 1
self.nan_num[n] += 1
The judge branch "if i in self.knn[n] and (i, n) not in self.nan_edges" determines whether instance i and instance n are nearest neighbors of each other may be problematic, because "self.findKNN(self.data[i], r, tree)" obtains the rth nearest neighbor of instance i; at this point, the nearest neighbor of the instances with instance n may not have been calculated yet. Neighbors may not have been computed yet, the rth nearest neighbor of all instances should be computed at once first; e.g. knn_idxs = self.kdtree.query(self.data, [r + 1])[1] # Get the kth nearest neighbor index of the rth round;
Looking foward to your reply.
nan_search(self) function in nan.py
while(flag == 0):
for i in range(len(self.data)):
knn = self.findKNN(self.data[i], r, tree)
n = knn[-1]
self.knn[i].add(n)
if(i in self.knn[n] and (i, n) not in self.nan_edges):
self.nan_edges.add((i, n))
self.nan_edges.add((n, i))
self.nan_num[i] += 1
self.nan_num[n] += 1
The judge branch "if i in self.knn[n] and (i, n) not in self.nan_edges" determines whether instance i and instance n are nearest neighbors of each other may be problematic, because "self.findKNN(self.data[i], r, tree)" obtains the rth nearest neighbor of instance i; at this point, the nearest neighbor of the instances with instance n may not have been calculated yet. Neighbors may not have been computed yet, the rth nearest neighbor of all instances should be computed at once first; e.g. knn_idxs = self.kdtree.query(self.data, [r + 1])[1] # Get the kth nearest neighbor index of the rth round;
Looking foward to your reply.