请用python写一段绘制网络拓扑图的程序

以下为Python代码:import networkx as nx

import matplotlib.pyplot as pltG = nx.Graph() G.add_nodes_from([1,2,3,4,5]) G.add_edges_from([(1,2),(1,3),(2,4),(3,4),(3,5),(4,5)]) nx.draw(G, with_labels=True) plt.show()

猜你喜欢

转载自blog.csdn.net/weixin_35751412/article/details/129500836
今日推荐