@@ -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 != ''));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user