def collapse(df, d, limit):

  enum = df.get_enum()
  rnd = random(enum)
  rndmask = (rnd<limit).nonzero()[0]
  for e in rndmask:

    l = df.get_edge_length(e)
    if l<d:
      try:
        df.collapse_edge(e)
      except __HOLE__:
        pass
dataset/ETHPy150Open inconvergent/differential-line/modules/growth.py/collapse