NetworkX

Previous topic

networkx.MultiGraph.add_edges_from

Next topic

networkx.MultiGraph.remove_edge

networkx.MultiGraph.add_weighted_edges_from

MultiGraph.add_weighted_edges_from(ebunch, **attr)

Add all the edges in ebunch as weighted edges with specified weights.

Parameters:

ebunch : 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.

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 has no effect but any edge data will be updated when each duplicate edge is added.

Examples

>>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_weighted_edges_from([(0,1,3.0),(1,2,7.5)])