Adding random contraction algorithm.