This commit is contained in:
Ian Gulliver
2019-07-13 05:10:56 +00:00
parent cbe56098da
commit a3cc7ad048
3 changed files with 2 additions and 14 deletions

View File

@@ -27,9 +27,6 @@ class LayoutLink {
bfs() {
let bestByPos = new StringMap();
// shortcut to save the lookup
let cheapestCostToGoal = null;
// BFS work queue
let queue = new MinHeap((a) => a.cost);
queue.push(...[
@@ -132,7 +129,7 @@ class LayoutLink {
} else if (taken) {
// Traversing nodes has higher cost
cost += 5;
};
}
}
// Overlapping links have cost, but not if they are from or to the same

View File

@@ -106,7 +106,7 @@ class LayoutNode {
for (let i of [0, 1]) {
vec[i] = aff.node.pos[i] - this.pos[i];
vecsum += Math.abs(vec[i]);
};
}
// 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, aff.node.pos);

View File

@@ -7,15 +7,6 @@ function getOrSet(container, key, newValue) {
return val;
}
function intersects(set1, set2) {
for (let item of set1) {
if (set2.has(item)) {
return true;
}
}
return false;
}
function asymDifference(set1, set2) {
let ret = new Set();
for (let item of set1) {