score:-1

In your attr("r") function, you are doing d.weight = 5; after computing it dynamically, which will set every node to a weight of 5. You can remove that line to get the computed weight working:

  node.append("circle")
      .attr("r", function(d) {
         d.weight = links.filter(function(l) {
           return l.source.index == d.index || l.target.index == d.index
         }).size();
         var minRadius = 10;
         return minRadius + (d.weight * 2);
       });

score:1

I figured it out. In the example stack overflow post, it was using size() I'm not sure how that worked, but I used length instead and it is working.

node.append("circle")
      .attr("r", function(d) {
         d.weight = links.filter(function(l) {
           return l.source.index == d.index || l.target.index == d.index
         }).length;
         console.log("d weight", d.weight)
         var minRadius = 10;
         return minRadius + (d.weight * 2);
       });

Related Query