docs: def add_edge(self, u, v, key=None, attr_dict=None, **attr):
          """Version of add_edge that only writes to the database once."""
          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.node:
              self.node[u] = {}
          if v not in self.node:
              self.node[v] = {}
          if v 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
          return key