Tag object

Fixes #1
This commit is contained in:
Ian Gulliver
2019-07-14 20:44:07 +00:00
parent d47cec70c1
commit 07e26a2a6c
11 changed files with 248 additions and 3 deletions

View File

@@ -6,12 +6,14 @@ class Graph {
this.groups = [];
this.links = [];
this.nodes = [];
this.tags = [];
this.label = null;
this.processList(def.editor);
this.removeSoftNodes();
this.resolveLinks();
this.resolveGroups();
this.resolveTags();
this.flattenNodes();
this.setPageRank();
this.setSubgraph();
@@ -41,6 +43,10 @@ class Graph {
case 'node':
this.processNode(item, soft);
break;
case 'tag':
this.processTag(item);
break;
}
}
@@ -79,6 +85,15 @@ class Graph {
getOrSet(this.nodesByLabel, node.label, []).push(node);
}
processTag(item) {
let tag = GraphTag.process(item);
if (!tag) {
return;
}
this.tags.push(tag);
this.processList(item.members, true);
}
removeSoftNodes() {
for (let nodes of this.nodesByLabel.values()) {
for (let i = nodes.length - 1; i >= 0 && nodes.length > 1; --i) {
@@ -101,6 +116,12 @@ class Graph {
}
}
resolveTags() {
for (let tag of this.tags) {
tag.resolve(this.nodesByLabel);
}
}
flattenNodes() {
for (let nodes of this.nodesByLabel.values()) {
this.nodes.push(...nodes);
@@ -139,3 +160,4 @@ class Graph {
<!--# include file="GraphGroup.js" -->
<!--# include file="GraphLink.js" -->
<!--# include file="GraphNode.js" -->
<!--# include file="GraphTag.js" -->