Implementation of Dijkstra algorithm to find the shortest path