NetworkX

Previous topic

edges_iter

Next topic

get_node_attributes

set_node_attributes

set_node_attributes(G, name, attributes)[source]

Set node attributes from dictionary of nodes and values

Parameters :

G : NetworkX Graph

name : string

Attribute name

attributes: dict :

Dictionary of attributes keyed by node.

Examples

>>> G=nx.path_graph(3)
>>> bb=nx.betweenness_centrality(G)
>>> nx.set_node_attributes(G,'betweenness',bb)
>>> G.node[1]['betweenness']
1.0