Understanding time complexity of a while loop that will look over all vertices and edges I need a little clarification on differing time complexities. My analysis for the below algorithm was $O(n +nm)$, but the correct analysis would be $O(n+m)$. I know that Color takes $O(n)$ time to initialize and the inner for loop takes $\mathrm{deg}(v)$ time, which by the handshaking lemma, wouldn't the inner for loop then be $O(m)$ and since the outside while loop iterates over all vertices in worse case so shouldn't that be $O(n)$, Giving $O(n) + O(nm)$?
Because each edge contributes to two degrees, we have
$$\sum_v\mathrm{deg}(v)=2m.$$

The time taken by the whole loop is $O(m)$.

Your analysis is of course correct, but since you replace $\mathrm{deg}(v)$ with the upper bound $m$, you get a loose bound finally.

By the way this is BFS if you ignore the "color" action.