def traverse(vertex, mergeDict):
	"""
	Given a vertex and a dictionaty of merges, returns the id of the cluster
	the vertex belongs to.
	"""
	while vertex in mergeDict:
		vertex = mergeDict[vertex]
	return vertex