Let $G=(V,E)$ be graph, I know that $\Sigma_{v\in V}d(v)=O(|V|+|E|)$.
In my algorithm I go over each $v$ and for each $v$ I look at all of his neighbors and their neighbors and I do constant time work on each of them.
There are $d(v)$ neighbors for $v$, and if $v'$ is a neighbor of $v$ then he have $d(v')$ neighbors. This gives the sum $\Sigma_{v\in V}(d(v)(\Sigma_{v'}d(v'))$ where $v'$ in the index of the second sum goes over all the neighbors of $v$.
What is the time complexity of my algorithm ? what is a tight bound for the above sum ?
What is the time complexity of my algorithm when the graph is directed ? now we have $d_{out}$ wherever we had $d$ in the above sum