Added the random contraction algorithm