Files
architype/GraphLink.js

45 lines
946 B
JavaScript
Raw Normal View History

2019-07-03 03:22:42 +00:00
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) {
2019-07-10 17:17:17 +00:00
from.links.push({
to: to,
2019-07-11 05:12:08 +00:00
id: this.id,
2019-07-10 17:17:17 +00:00
label: this.label,
labelId: this.labelId,
2019-07-10 17:17:17 +00:00
});
to.linksIn.push({
from: from,
2019-07-11 05:12:08 +00:00
id: this.id,
2019-07-10 17:17:17 +00:00
label: this.label,
labelId: this.labelId,
2019-07-10 17:17:17 +00:00
});
2019-07-03 03:22:42 +00:00
}
}
}
setPageRank() {
for (let to of this.to) {
to.incPageRank(new Set());
}
}
static process(item) {
let link = new GraphLink();
2019-07-11 05:12:08 +00:00
link.id = item.id;
2019-07-03 03:22:42 +00:00
link.label = item.label;
link.labelId = item.labelObj.id;
2019-07-03 03:22:42 +00:00
link.fromLabel = item.from.label;
link.toLabel = item.to.label;
if (link.fromLabel == '' || link.toLabel == '') {
return null;
}
return link;
}
}