Affinity migration checkpoint

Issue #6
This commit is contained in:
Ian Gulliver
2019-07-13 03:34:34 +00:00
parent 9d46c061c6
commit 2663c64bcd
2 changed files with 25 additions and 10 deletions

View File

@@ -46,15 +46,6 @@ class GraphNode {
const INF = 999999;
for (let node of nodes) {
// Weak affinity full mesh
// Keep unassociated subgroups together
this.addAffinity(node, d => d);
// Keep one space between subgraphs
if (this.subgraph != node.subgraph && this.label != node.label) {
this.addAffinity(node, d => d <= 2 ? -INF : 0);
}
// Am I in any labeled groups that node is not?
// If so, preserve one space above the group
let labeled = new Set(Array.from(this.groups).filter(g => g.label != ''));

View File

@@ -3,7 +3,12 @@ class LayoutNode {
this.graphNode_ = graphNode;
this.nodesByPos_ = nodesByPos;
this.pos = pos;
this.groups = new Set();
this.affinity_ = [];
this.label = this.graphNode_.label;
this.subgraph = this.graphNode_.subgraph;
this.nodesByPos_.set(this.pos, this);
}
@@ -22,8 +27,8 @@ class LayoutNode {
resolveAffinity(nodesByGraphNode) {
const INF = 999999;
// TODO: remove
// Transitional: copy GraphNode affinity
this.affinity_ = [];
for (let aff of this.graphNode_.affinity) {
this.affinity_.push({
node: nodesByGraphNode.get(aff.node),
@@ -32,6 +37,15 @@ class LayoutNode {
}
for (let node of nodesByGraphNode.values()) {
// Weak affinity full mesh
// Keep unassociated subgroups together
this.addAffinity(node, d => d);
// Keep one space between subgraphs
if (this.subgraph != node.subgraph && this.label != node.label) {
this.addAffinity(node, d => d <= 2 ? -INF : 0);
}
for (let group of this.groups) {
// Ensure groups do not overlap
if (group.nodes.has(node)) {
@@ -45,6 +59,16 @@ class LayoutNode {
}
}
addAffinity(node, distanceToWeight) {
if (this == node) {
return;
}
this.affinity_.push({
node: node,
distanceToWeight: distanceToWeight,
});
}
setTension() {
this.vec = [0, 0];
this.tension = 0;