Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

set_edge_attributes

set_edge_attributes(G, name, values)[source]

Set edge attributes from dictionary of edge tuples and values.

Parameters :

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 \(values\) is not a dictionary, then it is treated as a single attribute value that is then applied to every edge in \(G\).

Examples

>>> G = nx.path_graph(3)
>>> bb = nx.edge_betweenness_centrality(G, normalized=False)
>>> nx.set_edge_attributes(G, 'betweenness', bb)
>>> G[1][2]['betweenness']
2.0