sequential implementation of dijkstra complete