Suppose we have a graph like this:
5 3
A ───────────► B ───────┐
│ │
│ │
│ │
│ ▼
└─────────────────────► C
10
In this situation. Both B and C are added to the priority queue. When B is explored, C gets added to the queue again, because C is B's neighbor. So essentially, each Vertex is added in to the queue as many times as there are edges going into that vertex. So in the worst case scenario, the priority queue can have E number of items in the queue. Adding and removing items take logE cost. This multiplied by the standard BFS cost of O(V + E) should give us a total cost of O((V + E)logE) but in all textbooks and everywhere the cost is mentioned as O((V + E)logV) why is that?
Even here it says that O(logE) is the same as O(logV) and they claim the total cost is O((V + E)logV). Why is logE the same as logV?