def flood(stepFunction, fullSet, initSet, relevant=None):
 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)

def flood ( stepFunction , fullSet , initSet , relevant = None ) : 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 )
returns a list of elements of fullset linked to some element of initset through the neighborhood-setfunction .