dijkstra algorithm implemented with heap