

def add_edge(self, u, v, key=None, attr_dict=None, **attr):
    "Add an edge between u and v.\n\n        The nodes u and v will be automatically added if they are\n        not already in the graph.\n\n        Edge attributes can be specified with keywords or by providing\n        a dictionary with key/value pairs.  See examples below.\n\n        Parameters\n        ----------\n        u,v : nodes\n            Nodes can be, for example, strings or numbers.\n            Nodes must be hashable (and not None) Python objects.\n        key : hashable identifier, optional (default=lowest unused integer)\n            Used to distinguish multiedges between a pair of nodes.\n        attr_dict : dictionary, optional (default= no attributes)\n            Dictionary of edge attributes.  Key/value pairs will\n            update existing data associated with the 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_edges_from : add a collection of edges\n\n        Notes\n        -----\n        To replace/update edge data, use the optional key argument\n        to identify a unique edge.  Otherwise a new edge will be created.\n\n        NetworkX algorithms designed for weighted graphs cannot use\n        multigraphs directly because it is not clear how to handle\n        multiedge weights.  Convert to Graph using edge attribute\n        'weight' to enable weighted graph algorithms.\n\n        Examples\n        --------\n        The following all add the edge e=(1,2) to graph G:\n\n        >>> G = nx.MultiDiGraph()\n        >>> e = (1,2)\n        >>> G.add_edge(1, 2)           # explicit two-node form\n        >>> G.add_edge(*e)             # single edge as tuple of two nodes\n        >>> G.add_edges_from( [(1,2)] ) # add edges from iterable container\n\n        Associate data to edges using keywords:\n\n        >>> G.add_edge(1, 2, weight=3)\n        >>> G.add_edge(1, 2, key=0, weight=4)   # update data for key=0\n        >>> G.add_edge(1, 3, weight=7, capacity=15, length=342.7)\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.')
    if (u not in self.succ):
        self.succ[u] = {
            
        }
        self.pred[u] = {
            
        }
        self.node[u] = {
            
        }
    if (v not in self.succ):
        self.succ[v] = {
            
        }
        self.pred[v] = {
            
        }
        self.node[v] = {
            
        }
    if (keydict in self.succ[u]):
        keydict = self.adj[u][v]
        if (key is None):
            key = len(keydict)
            while (key in keydict):
                key += 1
        datadict = keydict.get(key, {
            
        })
        datadict.update(attr_dict)
        keydict[key] = datadict
    else:
        if (key is None):
            key = 0
        datadict = {
            
        }
        datadict.update(attr_dict)
        keydict = {
            key: datadict,
        }
        self.succ[u][v] = keydict
        self.pred[v][u] = keydict

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingMultiDiGraph.add_edge/VarMisuse@170/951 `v`->`keydict`