I believe Lars is correct. Based on the last response from the link he provided, I added this code to one of my force graphs and it worked fine:

var path = svg.append("g").selectAll(".link")
    .attr("id",function(d,i) { return "linkId_" + i; })

var labelText = svg.selectAll(".labelText")
    .attr("xlink:href",function(d,i) { return "#linkId_" + i;})
    .text(function(d,i) { return "text for link " + i;});

Related Query

More Query from same tag