Usando questo codice creo un grafo

<script type="text/javascript" charset="utf-8">



var w = 1000, h = 700;

var labelDistance = 0;

var vis = d3.select("body").append("svg:svg").attr("width", w).attr("height", h);

var nodes = [];
var labelAnchors = [];
var labelAnchorLinks = [];
var links = [];


var node = {
label : "OFFERTE"
};
nodes.push(node);
labelAnchors.push({
node : node
});
labelAnchors.push({
node : node
});

var n = {
label : "offerta" + 1
};
nodes.push(n);
labelAnchors.push({
node : n
});
labelAnchors.push({
node : n
});

var a = {
label : "offerta" + 2
};
nodes.push(a);
labelAnchors.push({
node : a
});
labelAnchors.push({
node : a
});


var b = {
label : "qualita offeta 1.1"
};
nodes.push(b);
labelAnchors.push({
node : b
});
labelAnchors.push({
node : b
});


var c = {
label : "qualita offeta 1.2"
};
nodes.push(c);
labelAnchors.push({
node : c
});
labelAnchors.push({
node : c
});


var d = {
label : "qualita offeta 2.1"
};
nodes.push(d);
labelAnchors.push({
node : d
});
labelAnchors.push({
node : d
});


var e = {
label : "qualita offeta 2.2"
};
nodes.push(e);
labelAnchors.push({
node : e
});
labelAnchors.push({
node : e
});


var f = {
label : "CORSI"
};
nodes.push(f);
labelAnchors.push({
node : f
});
labelAnchors.push({
node : f
});


var g = {
label : "corso 1"
};
nodes.push(g);
labelAnchors.push({
node : g
});
labelAnchors.push({
node : g
});


var gg = {
label : "corso 2"
};
nodes.push(gg);
labelAnchors.push({
node : gg
});
labelAnchors.push({
node : gg
});


var t = {
label : "qualita corso 1.1"
};
nodes.push(t);
labelAnchors.push({
node : t
});
labelAnchors.push({
node : t
});


var i = {
label : "qualita corso 1.2"
};
nodes.push(i);
labelAnchors.push({
node : i
});
labelAnchors.push({
node : i
});


var m = {
label : "qualita corso 2.1"
};
nodes.push(m);
labelAnchors.push({
node : m
});
labelAnchors.push({
node : m
});


var o = {
label : "qualita corso 2.2"
};
nodes.push(o);
labelAnchors.push({
node : o
});
labelAnchors.push({
node : o
});


var o = {
label : "qualita offerta 1.2"
};
nodes.push(o);
labelAnchors.push({
node : o
});
labelAnchors.push({
node : o
});


var p = {
label : "qualita corso 2.3"
};
nodes.push(p);
labelAnchors.push({
node : p
});
labelAnchors.push({
node : p
});



links.push({
source : 0,
target : 1,
weight : 0.8
});

links.push({
source : 0,
target : 2,
weight : 0.8
});

links.push({
source : 1,
target : 3,
weight : 0.87
});

links.push({
source : 1,
target : 14,
weight : 0.87
});

links.push({
source : 1,
target : 4,
weight : 0.87
});

links.push({
source : 2,
target : 5,
weight : 0.87
});

links.push({
source : 2,
target : 6,
weight : 0.87
});

links.push({
source : 3,
target : 10,
weight : 0.98
});

links.push({
source : 5,
target : 10,
weight : 0.98
});

links.push({
source : 3,
target : 12,
weight : 0.98
});

links.push({
source : 6,
target : 13,
weight : 0.98
});

links.push({
source : 6,
target : 12,
weight : 0.98
});

links.push({
source : 8,
target : 10,
weight : 0.98
});

links.push({
source : 8,
target : 11,
weight : 0.87
});

links.push({
source : 9,
target : 12,
weight : 0.87
});

links.push({
source : 9,
target : 13,
weight : 0.87
});

links.push({
source : 9,
target : 15,
weight : 0.87
});

links.push({
source : 7,
target : 8,
weight : 0.8
});

links.push({
source : 7,
target : 9,
weight : 0.8
});

for(var i = 0; i < nodes.length; i++) {
labelAnchorLinks.push({
source : i * 2,
target : i * 2 + 1,
weight : 1
});
};


var force = d3.layout.force().size([w, h]).nodes(nodes).links(links).gravity(1).linkDistanc e(200).charge(-3000).linkStrength(function(x) {
return x.weight * 10
});
force.start();
var force2 = d3.layout.force().nodes(labelAnchors).links(labelA nchorLinks).gravity(0).linkDistance(0).linkStrengt h(8).charge(-50).size([w, h]);
force2.start();

var link = vis.selectAll("line.link").data(links).enter().app end("svg:line").attr("class", "link").style("stroke", "#ee6363");
var node = vis.selectAll("g.node").data(force.nodes()).enter( ).append("svg:g").attr("class", "node");

node.append("svg:circle").attr("r", 6).style("fill", "#458b74").style("stroke", "#0000ee").style("stroke-width", 1);

var anchorLink = vis.selectAll("line.anchorLink").data(labelAnchorL inks)//.enter().append("svg:line").attr("class", "anchorLink").style("stroke", "#999");

var anchorNode = vis.selectAll("g.anchorNode").data(force2.nodes()) .enter().append("svg:g").attr("class", "anchorNode");
anchorNode.append("svg:circle").attr("r", 0).style("fill", "#FFF");
anchorNode.append("svg:text").text(function(d, i) {
return i % 2 == 0 ? "" : d.node.label
}).style("fill", " #ee1289").style("font-family", "Arial").style("font-size", 14);

var updateLink = function() {
this.attr("x1", function(d) {
return d.source.x;
}).attr("y1", function(d) {
return d.source.y;
}).attr("x2", function(d) {
return d.target.x;
}).attr("y2", function(d) {
return d.target.y;
});

}

var updateNode = function() {
this.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")";
});

}


force.on("tick", function() {

force2.start();

node.call(updateNode);

anchorNode.each(function(d, i) {
if(i % 2 == 0) {
d.x = d.node.x;
d.y = d.node.y;
} else {
var b = this.childNodes[1].getBBox();

var diffX = d.x - d.node.x;
var diffY = d.y - d.node.y;

var dist = Math.sqrt(diffX * diffX + diffY * diffY);

var shiftX = b.width * (diffX - dist) / (dist * 2);
shiftX = Math.max(-b.width, Math.min(0, shiftX));
var shiftY = 5;
this.childNodes[1].setAttribute("transform", "translate(" + shiftX + "," + shiftY + ")");
}
});




anchorNode.call(updateNode);

link.call(updateLink);
anchorLink.call(updateLink);

});

</script>



Volevo sapere come fare per fissare i nodi del grafo.