@@ -25,18 +25,9 @@ class LayoutNode {
|
||||
}
|
||||
}
|
||||
|
||||
resolveAffinity(nodesByGraphNode) {
|
||||
setAffinity(nodesByGraphNode) {
|
||||
const INF = 999999;
|
||||
|
||||
// TODO: remove
|
||||
// Transitional: copy GraphNode affinity
|
||||
for (let aff of this.graphNode_.affinity) {
|
||||
this.affinity_.push({
|
||||
node: nodesByGraphNode.get(aff.node),
|
||||
distanceToWeight: aff.distanceToWeight,
|
||||
});
|
||||
}
|
||||
|
||||
for (let node of nodesByGraphNode.values()) {
|
||||
// Weak affinity full mesh
|
||||
// Keep unassociated subgroups together
|
||||
@@ -78,6 +69,23 @@ class LayoutNode {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (let link of this.links) {
|
||||
// Stronger affinity for links
|
||||
// Prefer to move toward the target instance
|
||||
this.addAffinity(link.to, d => d <= 2 ? -INF : d * 11);
|
||||
link.to.addAffinity(this, d => d <= 2 ? -INF : d * 9);
|
||||
}
|
||||
|
||||
// Affinity for groups
|
||||
for (let group of this.groups) {
|
||||
if (!group.hasGraphGroup()) {
|
||||
continue;
|
||||
}
|
||||
for (let node of group.nodes) {
|
||||
this.addAffinity(node, d => d * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addAffinity(node, distanceToWeight) {
|
||||
|
||||
Reference in New Issue
Block a user