22
Graph.js
22
Graph.js
@@ -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" -->
|
||||
|
||||
Reference in New Issue
Block a user