Dijkstra's algorithm (Not heap based)