Don't avoid drawing lines over groups that we're coming to or from.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -6,7 +6,7 @@ class LayoutGroup {
|
||||
this.tension = 0;
|
||||
|
||||
for (let node of nodes) {
|
||||
node.groups.push(this);
|
||||
node.groups.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user