title: How can I calculate the degree of nodes in D3 v5?
body: <p>I am learning D3 and trying to scale the radius of nodes based on its degree in D3 v5. My code is like</p>
  
  <pre><code> nodes.forEach(function(d){
          d.degree=0;});
  links.forEach(function(d){
          nodes[d.source].degree += 1;
          nodes[d.target].degree += 1;});
  </code></pre>
  
  <p>It returns error that </p>
  
  <pre><code>Uncaught TypeError: nodes.forEach is not a function
  </code></pre>
  
  <p>Anyone can provide a good solution? </p>