From 271d999f0e2d1aa4e5260eaeef64ab2391d53207 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 22 Jun 2019 06:51:07 +0000 Subject: [PATCH] s/tree/graph/ --- architype.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/architype.js b/architype.js index 2796b2d..96366e3 100644 --- a/architype.js +++ b/architype.js @@ -22,56 +22,56 @@ class Architype { } onEdit(e) { - this.tree_ = this.buildTree(); - console.log(this.tree_); + this.graph_ = this.buildGraph(); + console.log(this.graph_); } - buildTree() { - let tree = { + buildGraph() { + let graph = { targetsByLabel: new Map(), groups: [], }; - this.buildTreeInt(tree, this.editor_.getEntries()); - return tree; + this.buildGraphInt(graph, this.editor_.getEntries()); + return graph; } - buildTreeInt(tree, entries) { + buildGraphInt(graph, entries) { for (let entry of entries) { if (entry instanceof Node) { - this.buildTreeNode(tree, entry); + this.buildGraphNode(graph, entry); } else if (entry instanceof Group) { - this.buildTreeGroup(tree, entry); + this.buildGraphGroup(graph, entry); } else if (entry instanceof Link) { - this.buildTreeLink(tree, entry); + this.buildGraphLink(graph, entry); } } } - buildTreeTarget(tree, label, target) { + buildGraphTarget(graph, label, target) { if (label == '') { return; } - let targets = tree.targetsByLabel.get(label) || []; + let targets = graph.targetsByLabel.get(label) || []; targets.push(target); - tree.targetsByLabel.set(label, targets); + graph.targetsByLabel.set(label, targets); } - buildTreeNode(tree, node) { + buildGraphNode(graph, node) { node.clear(); - this.buildTreeTarget(tree, node.getLabel(), node); + this.buildGraphTarget(graph, node.getLabel(), node); } - buildTreeGroup(tree, group) { + buildGraphGroup(graph, group) { group.clear(); - tree.groups.push(group); - this.buildTreeTarget(tree, group.getLabel(), group); - this.buildTreeInt(tree, group.getNodes()); + graph.groups.push(group); + this.buildGraphTarget(graph, group.getLabel(), group); + this.buildGraphInt(graph, group.getNodes()); } - buildTreeLink(tree, link) { + buildGraphLink(graph, link) { link.clear(); - this.buildTreeTarget(tree, link.getLabel(), link); - this.buildTreeInt(tree, [link.getFrom(), link.getTo()]); + this.buildGraphTarget(graph, link.getLabel(), link); + this.buildGraphInt(graph, [link.getFrom(), link.getTo()]); // TODO: record link information on source node } }