Implementation of Dijkstra algorithm for finding shortest paths in a graph