title: counting the sum of the degrees in an undirected graph
body: <p>here is my pseudocode:</p>
  
  <pre><code>for all u in V:
    degree[u]=0
    for all (u,w) in E:
      degree[u] = degree[u]+1
  for all u in V:
    twodegree[u]=0
    for all (u,w) in E:
      twodegree[u]=twodegree[u]+degree[w]
  </code></pre>
  
  <p>this code attempts to count the sum of the degrees (degrees - # of neighbors u has or the # of edges incident upon it) of u's neighbors in an undirected graph. however i am having trouble understanding the two for loops can someone please explain what exactly is  degree[u] = degree[u]+1 and twodegree[u] = twodegree[u]+degree[w] doing, (i know its counting the sum of the degrees, but i just don't see it how) can someone please explain how this algorithm works in terms of u and w?</p>