Split classes out of Graph.js
This commit is contained in:
32
GraphLink.js
Normal file
32
GraphLink.js
Normal file
@@ -0,0 +1,32 @@
|
||||
class GraphLink {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
resolve(nodesByLabel) {
|
||||
this.from = nodesByLabel.get(this.fromLabel);
|
||||
this.to = nodesByLabel.get(this.toLabel);
|
||||
for (let from of this.from) {
|
||||
for (let to of this.to) {
|
||||
from.links.push(to);
|
||||
to.linksIn.push(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setPageRank() {
|
||||
for (let to of this.to) {
|
||||
to.incPageRank(new Set());
|
||||
}
|
||||
}
|
||||
|
||||
static process(item) {
|
||||
let link = new GraphLink();
|
||||
link.label = item.label;
|
||||
link.fromLabel = item.from.label;
|
||||
link.toLabel = item.to.label;
|
||||
if (link.fromLabel == '' || link.toLabel == '') {
|
||||
return null;
|
||||
}
|
||||
return link;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user