@classmethod
	def filter_dependency_graph(cls, requirements, items):

		keptitems = set(filter(lambda i: unbound(i.predicate)(requirements), items))
		droppeditems = set(items).difference(keptitems)

		for survivor in keptitems:
			# Drop references to filtered instances
			survivor.depends = tuple(dep for dep in survivor.depends if dep in keptitems)
			# Do the same for groups
			if hasattr(survivor,'contains'):
				survivor.contains = tuple(k for k in survivor.contains if k in keptitems)

		# Drop references from filtered instances
		# Although this shouldn't matter, it actually does help make subtle errors more obvious
		# if this code itself is broken
		for dropped in droppeditems: 
			dropped.depends = None

		assert keptitems.isdisjoint(droppeditems)
		return keptitems
filter items in the dependency graph INPLACE based on the supplied requirements
dataset/ETHPy150Open anchor/make-magic/core/deptools.py/SimpleDependencyStrategy.filter_dependency_graph