From c9cc43126d41d152bb3860e07f79446c2dd5bdf7 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Tue, 16 Jul 2019 18:31:28 +0000 Subject: [PATCH] Fix bug in LayoutGroup.restorePos() and reduce group count --- Layout.js | 9 +++++++++ LayoutGroup.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/Layout.js b/Layout.js index cc5674d..bd28d57 100644 --- a/Layout.js +++ b/Layout.js @@ -56,15 +56,24 @@ class Layout { resolveGroups() { this.groups_ = []; for (let group of this.graph_.groups) { + if (group.length < 2) { + continue; + } let nodes = this.nodesFromGraphNodes(group.nodes); this.groups_.push(new LayoutGroup(group, this.nodesByPos_, nodes, 'group')); } for (let subgraph of this.graph_.nodesBySubgraph.values()) { + if (subgraph.length < 2) { + continue; + } let nodes = this.nodesFromGraphNodes(subgraph); this.groups_.push(new LayoutGroup(null, this.nodesByPos_, nodes, 'subgraph')); } for (let labelGroup of this.graph_.nodesByLabel.values()) { + if (labelGroup.length < 2) { + continue; + } let nodes = this.nodesFromGraphNodes(labelGroup); this.groups_.push(new LayoutGroup(null, this.nodesByPos_, nodes, 'labelgroup')); diff --git a/LayoutGroup.js b/LayoutGroup.js index 0ff7c9f..189b663 100644 --- a/LayoutGroup.js +++ b/LayoutGroup.js @@ -40,6 +40,10 @@ class LayoutGroup { restorePos() { this.vec = this.savedVec_; + // Fix up nodesByPos, as intra-group collisions may have corrupted it + for (let node of this.nodes) { + this.nodesByPos_.set(node.pos, node); + } } moveBy(offset) {