import networkx as nx import matplotlib.pyplot as plt # 创建图 G = nx.Graph()
时间: 2023-12-09 11:05:49 浏览: 125
Python Matplotlib 基于networkx画关系网络图
# 添加节点
G.add_node(1)
G.add_node(2)
G.add_node(3)
# 添加边
G.add_edge(1, 2)
G.add_edge(2, 3)
G.add_edge(3, 1)
# 绘制图形
nx.draw(G, with_labels=True)
plt.show()
阅读全文