Why priority queue is not used?

why priority queue is not used???
since we have to remove and insert so it can be also done in priority queue

hello @codingblockscpp
u can use priority queue as well.

  1. Initialize distances of all vertices as infinite.

  2. Create an empty priority_queue pq. Every item
    of pq is a pair (weight, vertex). Weight (or
    distance) is used used as first item of pair
    as first item is by default used to compare
    two pairs

  3. Insert source vertex into pq and make its
    distance as 0.

  4. While either pq doesn’t become empty
    a) Extract minimum distance vertex from pq.
    Let the extracted vertex be u.
    b) Loop through all adjacent of u and do
    following for every vertex v.

        // If there is a shorter path to v
        // through u. 
        If dist[v] > dist[u] + weight(u, v)
    
            (i) Update distance of v, i.e., do
                  dist[v] = dist[u] + weight(u, v)
            (ii) Insert v into the pq (Even if v is
                 already there)
    
  5. Print distance array dist[] to print all shortest
    paths.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.