implement k-shortest paths