的文档
我有一个边列表文件。如何在networkx中将这个边表绘制为一个网络?我需要把它想象成一个像节点和边一样的网络图。有人知道吗?
基本模式如下:
In [1]: import networkx as nx
In [2]: import matplotlib.pyplot as plt
In [3]: G = nx.Graph() # create empty graph
In [4]: G.add_edges_from([(1,2),(1,3),(1,4),(4,5)]) # or use nx.read_edgelist("path")
In [5]: nx.draw(G)
In [6]: plt.show()
如果您正在从文件中读取边列表,那么使用:G=nx.read_edgelist("test.edgelist")
并替换步骤4中的边列表路径。更多关于read_edgelist()