networkx.DiGraph.add_weighted_edges_from¶

DiGraph.
add_weighted_edges_from
(ebunch_to_add, weight='weight', **attr)¶ Add weighted edges in
ebunch_to_add
with specified weight attrParameters:  ebunch_to_add (container of edges) – Each edge given in the list or container will be added to the graph. The edges must be given as 3tuples (u, v, w) where w is a number.
 weight (string, optional (default= ‘weight’)) – The attribute name for the edge weights to be added.
 attr (keyword arguments, optional (default= no attributes)) – Edge attributes to add/update for all edges.
See also
add_edge()
 add a single edge
add_edges_from()
 add multiple edges
Notes
Adding the same edge twice for Graph/DiGraph simply updates the edge data. For MultiGraph/MultiDiGraph, duplicate edges are stored.
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_weighted_edges_from([(0, 1, 3.0), (1, 2, 7.5)])