CLRS pseudocode:
begin
for each vertex u in G.V - {s}, do
u.color := white
u.d := infinity
u.p := NIL
done
s.color := green
s.d := 0
s.p := NIL
Q := NULL
insert s into Q
while Q is not null, do
u = delete from Q
for each v in adjacent to u, do
if v.color = white
v.color := green
v.d := u.d + 1
v.p := u
insert v into Q
end if
done
u.color = dark_green
done
end`
In the clrs it says that the insertion and deletion operations with the queue require an O (1) time, so the total time of operations with the queue is O (V). (V because each vertex is visited at least once). instead the time to inspect the adjacency list of each node is O (E). Then we have another O (V) for initialization. So the total time is O (V + E) which in the worst case becomes O (V ^ 2), this depends on whether the graph is dense or not.
Now my question is: Since we have two cycles nested the complexity shouldn't be O (V * E), I can't understand why a sum operation is performed instead of multiplying.