my implementation of Dijkstra's algorithm