fixed bug in shortest path calculation.