def remove(self, node): self._nodes.remove(node) for n in iter(self._nodes): with contextlib.suppress(KeyError): n.edges.remove(node)