findNumberVillagesConnected algorithm