Calculating shortest path using simple Dijkstra