Set initial node positions
This commit is contained in:
12
architype.js
12
architype.js
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user