Note
Go to the end to download the full example code.
边缘颜色映射#
使用matplotlib绘制图形,并对边进行着色。
import matplotlib.pyplot as plt
import networkx as nx
G = nx.star_graph(20)
pos = nx.spring_layout(G, seed=63) # 设定布局种子以确保可重复性
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()
Total running time of the script: (0 minutes 0.024 seconds)