reworked route contraction algorithm because old one was buggy