Accepted answer

You can add labels just as you add the paths for the links themselves. All you need to do is calculate the position according to the positions of the two nodes the link connects. The code would look something like this.

   .attr("x", function(d) { return d.source.x + ( - d.source.x)/2; })
   .attr("y", function(d) { return d.source.y + ( - d.source.y)/2; })
   .text(function(d) { return d.something; });

Note that in your tick function, you would also need to update the position of the labels.

Related Query