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) wh
(self, ebunch_to_add, weight="weight", **attr)
| 977 | self._clear_cache() |
| 978 | |
| 979 | def add_weighted_edges_from(self, ebunch_to_add, weight="weight", **attr): |
| 980 | """Add weighted edges in `ebunch_to_add` with specified weight attr |
| 981 | |
| 982 | Parameters |
| 983 | ---------- |
| 984 | ebunch_to_add : container of edges |
| 985 | Each edge given in the list or container will be added |
| 986 | to the graph. The edges must be given as 3-tuples (u, v, w) |
| 987 | where w is a number. |
| 988 | weight : string, optional (default= 'weight') |
| 989 | The attribute name for the edge weights to be added. |
| 990 | attr : keyword arguments, optional (default= no attributes) |
| 991 | Edge attributes to add/update for all edges. |
| 992 | |
| 993 | See Also |
| 994 | -------- |
| 995 | add_edge : add a single edge |
| 996 | add_edges_from : add multiple edges |
| 997 | |
| 998 | Notes |
| 999 | ----- |
| 1000 | Adding the same edge twice for Graph/DiGraph simply updates |
| 1001 | the edge data. For MultiGraph/MultiDiGraph, duplicate edges |
| 1002 | are stored. |
| 1003 | |
| 1004 | Examples |
| 1005 | -------- |
| 1006 | >>> G = eg.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc |
| 1007 | >>> G.add_weighted_edges_from([(0, 1, 3.0), (1, 2, 7.5)]) |
| 1008 | """ |
| 1009 | self.add_edges_from(((u, v, {weight: d}) for u, v, d in ebunch_to_add), **attr) |
| 1010 | |
| 1011 | def add_weighted_edges_from(self, ebunch_to_add, weight="weight", **attr): |
| 1012 | """Add weighted edges in `ebunch_to_add` with specified weight attr |