我有一个图的邻接矩阵如下:我想将此矩阵保存为csv或txt文件,我应该怎么做?我尝试了以下链接
https://stackoverflow.com/questions/46462487/how-to-write-an-adjacency-matrix-to-a-file-and-read-from-the-file-you-have-writt Gives me error
其他人没有给我正确的输出求你了,我需要你的帮助非常感谢。
slhcrj9b1#
干得好:
import numpy as np # create random adjacency matrix A = np.random.randint(0,2,(10,10)) A[np.arange(10),np.arange(10)] = 1 # save to .txt file filename='adjacency_matrix.txt' np.savetxt(filename,A)
1条答案
按热度按时间slhcrj9b1#
干得好: