注意
跳转到末尾下载完整示例代码。
边颜色映射#
使用 matplotlib 绘制图,并为边着色。

import matplotlib.pyplot as plt
import networkx as nx
G = nx.star_graph(20)
pos = nx.spring_layout(G, seed=63) # Seed layout for reproducibility
colors = range(20)
options = {
"node_color": "#A0CBE2",
"edge_color": colors,
"width": 4,
"edge_cmap": plt.cm.Blues,
"with_labels": False,
}
nx.draw(G, pos, **options)
plt.show()
脚本总运行时间: (0 分钟 0.044 秒)