||
不同节点不同显示颜色
G.node[0][’color’] = ’red’
G.add_nodes_from([0,1],color='red')设置节点颜色
node_color=[G.node[v]['color'] for v in G]#获得G中各个节点的设置值;
nx.draw_networkx(G, node_color=node_color)画出颜色
s3=[0, 1, 2, 3, 7, 9, 11, 12, 13, 17, 19, 21]
>>> for i in range(len(s3)):
g2.node[s3[i]]['color'] = 'yellow'
Zachary's karate club network
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-3 02:14
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社