def bordaScores(instance):
	""" Computes the total Borda scores of all the alternatives of the instance. Within an indifference class, all
		alternatives are assigned the smallest score one alternative from the class would have gotten, had the order
		been strict. For instance, for the order ({a1}, {a2, a3}, {a4}), a1 gets score 3, a2 and a3 score 1 and a4 
		score 0.

		:param instance: The instance.
		:type instance: preflibtools.instance.preflibinstance.PreflibInstance

		:return: A dictionary mapping every instance to their Borda score.
		:rtype: dict
	"""
	if instance.dataType not in ("toc, soc"):
		raise TypeError("You are trying to compute the Borda scores of an instance of type " +
			str(instance.dataType) + ", this is not possible.")
	res = dict([])
	for order in instance.orders:
		i = instance.nbAlternatives
		for indifClass in order:
			i -= len(indifClass)
			for alt in indifClass:
				if alt not in res:
					res[alt] = i
				else:
					res[alt] += i
	return res