cpp implementation of dijkstra algorithm