def flood(stepFunction, fullSet, initSet, relevant=None):
    """ Returns a list of elements of fullSet linked to some element of initSet
    through the neighborhood-setFunction (which must be defined on all elements of fullSet).

    :key relevant: (optional) list of relevant elements: stop once all relevant elements are found.
    """
    if fullSet is None:
        flooded = set(initSet)
    else:
        full = set(fullSet)
        flooded = full.intersection(set(initSet))
        if relevant is None:
            relevant = full.copy()
    if relevant:
        relevant = set(relevant)

    change = flooded.copy()
    while len(change)>0:
        new = set()
        for m in change:
            if fullSet is None:
                new.update(stepFunction(m))
            else:
                new.update(full.intersection(stepFunction(m)))
        change = new.difference(flooded)
        flooded.update(change)
        if relevant is not None and relevant.issubset(flooded):
            break
    return list(flooded)
dataset/ETHPy150Open pybrain/pybrain/pybrain/utilities.py/flood/original