It runs once for every edge incident to vi. As each edge is incident to 2 vertices, in the end, each edge is visited twice, and each vertex once. So O(n+2m) = O(n+m) using an adjacency list.
Using an adjacency matrix, to find out which edges are incident to vi, you would need O(n) operations. So the algorithm would be O(n²).