33
GraphNode.js
33
GraphNode.js
@@ -3,7 +3,6 @@ class GraphNode {
|
||||
this.links = [];
|
||||
this.linksIn = [];
|
||||
this.groups = new Set();
|
||||
this.affinity = [];
|
||||
this.pageRank = 0;
|
||||
this.subgraph = null;
|
||||
}
|
||||
@@ -41,38 +40,6 @@ class GraphNode {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move this to LayoutNode, item by item
|
||||
setAffinity(nodes) {
|
||||
const INF = 999999;
|
||||
|
||||
for (let node of nodes) {
|
||||
}
|
||||
|
||||
for (let link of this.links) {
|
||||
// Stronger affinity for links
|
||||
// Prefer to move toward the target instance
|
||||
this.addAffinity(link.to, d => d <= 2 ? -INF : d * 11);
|
||||
link.to.addAffinity(this, d => d <= 2 ? -INF : d * 9);
|
||||
}
|
||||
|
||||
// Affinity for groups
|
||||
for (let group of this.groups) {
|
||||
for (let node of group.nodes) {
|
||||
this.addAffinity(node, d => d * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addAffinity(node, distanceToWeight) {
|
||||
if (this == node) {
|
||||
return;
|
||||
}
|
||||
this.affinity.push({
|
||||
node: node,
|
||||
distanceToWeight: distanceToWeight,
|
||||
});
|
||||
}
|
||||
|
||||
static process(item, soft=false) {
|
||||
if (item.label == '') {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user