Set initial node positions

This commit is contained in:
Ian Gulliver
2019-06-26 04:44:23 +00:00
parent 64d60ac5c8
commit d1cac0f3af

View File

@@ -143,6 +143,7 @@ class Architype {
this.manifestNodes(graph);
this.setPageRank(graph);
this.bucketByPageRank(graph);
this.setInitialPositions(graph);
return graph;
}
@@ -270,6 +271,17 @@ class Architype {
bucket.sort(cmp);
}
}
setInitialPositions(graph) {
let ranks = Array.from(graph.nodesByPageRank.keys());
ranks.sort((a, b) => a - b);
for (let r = 0; r < ranks.length; ++r) {
let nodes = graph.nodesByPageRank.get(ranks[r]);
for (let n = 0; n < nodes.length; ++n) {
nodes[n].pos = [r, 0 - Math.floor(nodes.length / 2) + n];
}
}
}
}
class ListenUtils {