Warning

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

Graph.add_weighted_edges_from(ebunch_to_add, weight='weight', **attr)[source]

Add weighted edges in ebunch_to_add with specified weight attr

Parameters: 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 3-tuples (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.

add_edge()
add_edges_from()
>>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc