Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用KNN结果快速创建图形(ImageNet)_Python_Graph_Networkx_Knn_Laplacian - Fatal编程技术网

Python 如何使用KNN结果快速创建图形(ImageNet)

Python 如何使用KNN结果快速创建图形(ImageNet),python,graph,networkx,knn,laplacian,Python,Graph,Networkx,Knn,Laplacian,我有KNN的数组,如下所示: [[point0, 1st nearest point of point0,......., kth nearest point of point0]\ [point1, 1st nearest point of point1,......., kth nearest point of point1]\ .....\ [pointN, 1st nearest point of pointN,......., kth nearest point of point

我有KNN的数组,如下所示:

[[point0, 1st nearest point of point0,......., kth nearest point of point0]\
 [point1, 1st nearest point of point1,......., kth nearest point of point1]\
 .....\
 [pointN, 1st nearest point of pointN,......., kth nearest point of pointN]]
例如:
[0,12,1,13]
[1,9,4,76]]
..
[76,2,3,4]]

现在我需要使用这个数组创建一个图,我尝试通过添加节点和边来为网络中的循环创建
,但图的拉普拉斯矩阵与正确答案不匹配。因为我处理的是ImageNet,所以不可能逐个节点检查以找出哪里出了问题

然后我尝试用这个数组从KNN生成一个稀疏邻接矩阵,然后用
nx.from\u scipy\u sparse\u matrix
创建一个图。但即使使用
lil_矩阵
,生成稀疏邻接矩阵仍然非常缓慢

现在我想知道有没有更好更快的方法来实现这一点

PS(根据networkx,曾经我们使用添加边,如
G.add\u edge(1,2)
。我们不需要单独添加此节点,如
G.add\u node(1)
。但在处理我观察到的海量数据时,这是不正确的)