fix k shortest path algorithm

There are still some memory leaks.....