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()