Working version for Neighbors.getCyclesCount function.