-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphLink.js
More file actions
44 lines (41 loc) · 969 Bytes
/
GraphLink.js
File metadata and controls
44 lines (41 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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,
id: this.id,
label: this.label,
labelId: this.labelId,
});
to.linksIn.push({
from: from,
id: this.id,
label: this.label,
labelId: this.labelId,
});
}
}
}
setPageRank() {
for (let to of this.to) {
to.incPageRank(new Set());
}
}
static process(item) {
let link = new GraphLink();
link.id = item.id;
link.label = item.label;
link.labelId = item.labelObj ? item.labelObj.id : null;
link.fromLabel = item.from.label;
link.toLabel = item.to.label;
if (link.fromLabel == '' || link.toLabel == '') {
return null;
}
return link;
}
}