Link: optimize so that no link {} is used, less than half the ram used
This commit is contained in:
@@ -8,17 +8,28 @@ function startLinkSimulation() {
|
||||
manualStop = true;
|
||||
simulation.stop();
|
||||
p1 = performance.now();
|
||||
let links = [];
|
||||
let links = [], force;
|
||||
|
||||
// Initialize link array.
|
||||
nodes = simulation.nodes();
|
||||
for (i = nodes.length-1; i >= 1; i--) {
|
||||
for (j = i-1; j >= 0; j--) {
|
||||
links.push({
|
||||
source: nodes[i],
|
||||
target: nodes[j],
|
||||
});
|
||||
if (tweakedVerOfLink) {
|
||||
force = d3.forceLinkTweaked()
|
||||
.distance(function (n) {
|
||||
return distanceFunction(n.source, n.target, props, norm);
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (i = nodes.length-1; i >= 1; i--) {
|
||||
for (j = i-1; j >= 0; j--) {
|
||||
links.push({
|
||||
source: nodes[i],
|
||||
target: nodes[j],
|
||||
});
|
||||
}
|
||||
}
|
||||
force = d3.forceLink()
|
||||
.distance(function (n) {
|
||||
return distanceFunction(n.source, n.target, props, norm);
|
||||
})
|
||||
.links(links);
|
||||
}
|
||||
|
||||
/* Add force
|
||||
@@ -33,11 +44,6 @@ function startLinkSimulation() {
|
||||
* The full pre-calculation will then occur once when the force is being
|
||||
* initialized by the simulation.
|
||||
*/
|
||||
let force = tweakedVerOfLink ? d3.forceLinkTweaked() : d3.forceLink();
|
||||
force.distance(function (n) {
|
||||
return distanceFunction(n.source, n.target, props, norm);
|
||||
})
|
||||
.links(links);
|
||||
|
||||
simulation
|
||||
.alphaDecay(0)
|
||||
|
||||
Reference in New Issue
Block a user