

def add_edges_from(self, ebunch, attr_dict=None, **attr):
    "Add all the edges in ebunch.\n\n        Parameters\n        ----------\n        ebunch : container of edges\n            Each edge given in the container will be added to the\n            graph. The edges can be:\n\n                - 2-tuples (u,v) or\n                - 3-tuples (u,v,d) for an edge attribute dict d, or\n                - 4-tuples (u,v,k,d) for an edge identified by key k\n\n        attr_dict : dictionary, optional  (default= no attributes)\n            Dictionary of edge attributes.  Key/value pairs will\n            update existing data associated with each edge.\n        attr : keyword arguments, optional\n            Edge data (or labels or objects) can be assigned using\n            keyword arguments.\n\n\n        See Also\n        --------\n        add_edge : add a single edge\n        add_weighted_edges_from : convenient way to add weighted edges\n\n        Notes\n        -----\n        Adding the same edge twice has no effect but any edge data\n        will be updated when each duplicate edge is added.\n\n        Edge attributes specified in edges as a tuple take precedence\n        over attributes specified generally.\n\n        Examples\n        --------\n        >>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc\n        >>> G.add_edges_from([(0,1),(1,2)]) # using a list of edge tuples\n        >>> e = zip(range(0,3),range(1,4))\n        >>> G.add_edges_from(e) # Add the path graph 0-1-2-3\n\n        Associate data to edges\n\n        >>> G.add_edges_from([(1,2),(2,3)], weight=3)\n        >>> G.add_edges_from([(3,4),(1,4)], label='WN2898')\n        "
    if (attr_dict is None):
        attr_dict = attr
    else:
        try:
            attr_dict.update(attr)
        except AttributeError:
            raise NetworkXError('The attr_dict argument must be a dictionary.')
    for e in ebunch:
        ne = len(e)
        if (ne == 4):
            (u, v, key, dd) = e
        elif (ne == 3):
            (u, v, dd) = e
            key = None
        elif (ne == 2):
            (u, v) = e
            dd = {
                
            }
            key = None
        else:
            raise NetworkXError(('Edge tuple %s must be a 2-tuple, 3-tuple or 4-tuple.' % (e,)))
        if (u in self.adj):
            keydict = self.adj[u].get(v, {
                
            })
        else:
            keydict = {
                
            }
        if (key is None):
            key = len(keydict)
            while (key in keydict):
                key += 1
        datadict = keydict.get(key, {
            
        })
        datadict.update(attr_dict)
        datadict.update(dd)
        self.add_edge(u, v, key=key, attr_dict=datadict)

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingMultiGraph.add_edges_from/original