Using a priority queue, implemented dijstra