我有网络文字文件。 这是网络文件格式。 的(源,目标,重量) (2,167480,2) (2,257789,1) (2,1838,1)
网络文件有403915个节点(源)。
这是我的代码
# -*- coding: utf-8 -*-
import networkx as nx
import matplotlib.pyplot as plt
f = open("C:\\Users\\UrbanLab-4\\Desktop\\exercise\\remake3.txt",'r')
f_1 = f.read().split()
i = []
G = nx.Graph()
for lineF in f_1:
i = lineF.split(',',2)
G.add_nodes_from(i)
pos = nx.spring_layout(G)
nx.draw_networkx_nodes(G,pos, cmap=plt, node_color = 'values')
nx.draw_networkx_edges(G,pos,arrows=True)
plt.show()
然后我有这个错误..
Traceback (most recent call last):
File "C:/Users/UrbanLab-4/PycharmProjects/untitled/net.py", line 12, in <module>
pos = nx.spring_layout(G)
File "C:\Python27\lib\site-packages\networkx\drawing\layout.py", line 287, in fruchterman_reingold_layout
A = nx.to_numpy_matrix(G, weight=weight)
File "C:\Python27\lib\site-packages\networkx\convert_matrix.py", line 369, in to_numpy_matrix
M = np.zeros((nlen,nlen), dtype=dtype, order=order) + np.nan
MemoryError
如何解决这个问题?