This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
set_edge_attributes(G, name, values)¶
Set edge attributes from dictionary of edge tuples and values.
- G (NetworkX Graph) –
- name (string) – Attribute name
- values (dict) – Dictionary of attribute values keyed by edge (tuple). For multigraphs, the keys tuples must be of the form (u, v, key). For non-multigraphs, the keys must be tuples of the form (u, v). If is not a dictionary, then it is treated as a single attribute value that is then applied to every edge in .
>>> G = nx.path_graph(3) >>> bb = nx.edge_betweenness_centrality(G, normalized=False) >>> nx.set_edge_attributes(G, 'betweenness', bb) >>> G['betweenness'] 2.0