networkx 对图进行可视化

networkx 对图进行可视化

import networkx as nx
import matplotlib.pyplot as plt
 
g = nx.Graph()
g.add_edge('1', '2')
g.add_edge('2', '3')
g.add_edge('1', '4')
g.add_edge('2', '4')
fig, ax = plt.subplots()
nx.draw(g, ax=ax)
plt.show()

fig, ax = plt.subplots()
nx.draw(g, ax=ax)
plt.show()

posted @ 2022-07-22 14:44  bH1pJ  阅读(29)  评论(0编辑  收藏  举报