contraction algorithm. final.