在python下安装networkx绘制复杂网络图形,编写的python代码如下:
import networkx as nx import matplotlib.pyplot as plt f = open(\'graph.txt\',\'r\') G = nx.Graph() for linefile in f: list = linefile.split(\'\t\') x=list[0] list[1]=list[1].replace(\'\n\',\'\') y=list[1] print type(x) print type(y) G.add_edge(x,y); nx.draw(G) plt.show()
其中graph.txt是绝对路径名称