diff --git a/architype.js b/architype.js index 2202b4f..39b408e 100644 --- a/architype.js +++ b/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 {