use isBijection to check both direction.