Try to preserve pagerank left-to-right flow

This commit is contained in:
Ian Gulliver
2019-07-09 05:36:32 +00:00
parent d4f90eb91d
commit cda3cad6f9
2 changed files with 16 additions and 3 deletions

View File

@@ -36,10 +36,17 @@ class LayoutNode {
// Avoid calling sqrt(), since the results are used relatively
let distanceSquared = vec[0] * vec[0] + vec[1] * vec[1];
let weight = aff.distanceToWeight(distanceSquared, vec);
for (let i of [0, 1]) {
this.vec[i] += (weight * vec[i]) / vecsum;
if (weight instanceof Array) {
for (let i of [0, 1]) {
this.vec[i] += weight[i];
this.tension += Math.abs(weight[i]);
}
} else {
for (let i of [0, 1]) {
this.vec[i] += (weight * vec[i]) / vecsum;
}
this.tension += Math.abs(weight);
}
this.tension += Math.abs(weight);
}
}