def _zipf_rv_below(gamma, xmin, threshold):
    """Returns a random value chosen from the Zipf distribution,
    guaranteed to be less than or equal to the value ``threshold``.

    Repeatedly draws values from the Zipf distribution until the
    threshold is met, then returns that value.

    """
    result = nx.utils.zipf_rv(gamma, xmin)
    while result > threshold:
        result = nx.utils.zipf_rv(gamma, xmin)
    return result
dataset/ETHPy150Open networkx/networkx/networkx/algorithms/community/community_generators.py/_zipf_rv_below/original