def METHOD_NAME(self, source, target, weight=None):
    if (source, target) not in self._edges:
        self._edges.append((source, target))
        self.out_mapping[source][target] = weight
        self.in_mapping[target][source] = weight
    if (
        not self.directed
        and (source != target)
        and (target, source) not in self._edges
    ):
        self._edges.append((target, source))
        self.out_mapping[target][source] = weight
        self.in_mapping[source][target] = weight