Don't avoid drawing lines over groups that we're coming to or from.

This commit is contained in:
Ian Gulliver
2019-07-10 08:27:07 +00:00
parent 01542d67f6
commit 75bc85919c
4 changed files with 10 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ class Layout {
this.graph_ = graph;
this.nodes_ = [];
// TODO: value should be a set, not a single value, for groups
this.nodesByPos_ = new StringMap();
this.nodesByGraphNode_ = new Map();
this.linksByPos_ = new StringMap();

View File

@@ -6,7 +6,7 @@ class LayoutGroup {
this.tension = 0;
for (let node of nodes) {
node.groups.push(this);
node.groups.add(this);
}
}

View File

@@ -117,7 +117,13 @@ class LayoutLink {
// arguments. That means that any costs applied to nodes must be applied
// whether the node is from or to. Traversal is double-charged.
for (let pos of [from, to]) {
if (this.nodesByPos_.has(pos)) {
let taken = this.nodesByPos_.get(pos);
if (taken instanceof LayoutGroup &&
(this.from_.groups.has(taken) ||
this.to_.groups.has(taken))) {
// We're going to or from this group, so traversing it is fine.
continue;
} else if (taken) {
// Traversing nodes has higher cost
cost += 5;
};

View File

@@ -3,7 +3,7 @@ class LayoutNode {
this.graphNode_ = graphNode;
this.nodesByPos_ = nodesByPos;
this.pos = pos;
this.groups = [];
this.groups = new Set();
this.nodesByPos_.set(this.pos, this);
}