network定制顶点颜色

import networkx as nx
import matplotlib.pyplot as plt
#添加顶点和边
plt.figure(figsize=(10, 10))
G_test = nx.Graph();
G_test.add_node('A')
G_test.add_node('B')
G_test.add_node('C')
G_test.add_node('D')
G_test.add_edge('A','B',weight=1)
G_test.add_edge('C','B',weight=1)
G_test.add_edge('B','D',weight=30)
#添加顶点列表及对应的颜色列表
nx.draw_networkx(G_test, nodelist=['A', 'B', 'C', 'D'], font_size=20, width=2,
                node_size=[1000, 1000, 2000, 3000],
                node_color=["g", "b", "r", "#FFFF00"])

绘制图像如下,

network定制顶点颜色_第1张图片

你可能感兴趣的:(自学,networkx)