def equivalence_enumeration( iterable, relation ):
	"""Partitions a set of objects into equivalence classes
	
	Same as equivalence_partition() but also numbers the classes.
	
	Args:
		iterable: collection of objects to be partitioned
		relation: equivalence relation. I.e. relation(o1,o2) evaluates to True
			if and only if o1 and o2 are equivalent
			
	Returns: classes, partitions, ids
		classes: A sequence of sets. Each one is an equivalence class
		partitions: A dictionary mapping objects to equivalence classes
		ids: A dictionary mapping objects to the indices of their equivalence classes
	"""
	classes, partitions = equivalence_partition( iterable, relation )
	ids = { }
	for i, c in enumerate( classes ):
		for o in c:
			ids[o] = i
	return classes, partitions, ids
Partitions a set of objects into equivalence classes
	
	Same as equivalence_partition() but also numbers the classes.
	
	Args:
		iterable: collection of objects to be partitioned
		relation: equivalence relation. I.e. relation(o1,o2) evaluates to True
			if and only if o1 and o2 are equivalent
			
	Returns: classes, partitions, ids
		classes: A sequence of sets. Each one is an equivalence class
		partitions: A dictionary mapping objects to equivalence classes
		ids: A dictionary mapping objects to the indices of their equivalence classes
	
recipes/Python/499354_Equivalence_partition/recipe-499354.py