#NEWLINE# def add_edges_from( self , ebunch , attr_dict = None , **attr ) : #NEWLINE# #INDENT# "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        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 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        " #NEWLINE# if ( attr_dict is None ) : #NEWLINE# #INDENT# attr_dict = attr #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# attr_dict . update ( attr ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise NetworkXError ( 'The attr_dict argument must be a dictionary.' ) #NEWLINE# #UNINDENT# #UNINDENT# for e in key : #NEWLINE# #INDENT# ne = len ( e ) #NEWLINE# if ( ne == 4 ) : #NEWLINE# #INDENT# ( u , v , key , dd ) = e #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ne == 3 ) : #NEWLINE# #INDENT# ( u , v , dd ) = e #NEWLINE# key = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ne == 2 ) : #NEWLINE# #INDENT# ( u , v ) = e #NEWLINE# dd = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# key = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NetworkXError ( ( 'Edge tuple %s must be a 2-tuple, 3-tuple or 4-tuple.' % ( e , ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ddd = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# ddd . update ( attr_dict ) #NEWLINE# ddd . update ( dd ) #NEWLINE# self . add_edge ( u , v , key , ddd )