get_node_attributes#

get_node_attributes(G, name)[源代码]#

从图中获取节点属性

参数
G网络X图表
name字符串

属性名称

返回
按节点设置关键字的属性字典。

实例

>>> G = nx.Graph()
>>> G.add_nodes_from([1, 2, 3], color="red")
>>> color = nx.get_node_attributes(G, "color")
>>> color[1]
'red'