Dijkstra algorithm implemented