<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def invalidate(self, key):
 """Remove the given data item along with all items that depend on it in the graph."""

        if key not in self.data:
            return
        del self.data[key]

        # Find all components that used it and invalidate their results
        for cname in self.components:
            if key in self.depends[cname]:
                for downstream_key in self.provides[cname]:
                    self.invalidate(downstream_key)