Clean up initial positioning code

This commit is contained in:
Ian Gulliver
2019-07-09 18:45:48 +00:00
parent 15c55d0b8d
commit b7d51417d6

View File

@@ -30,13 +30,12 @@ class Layout {
ranks.sort((a, b) => a - b);
for (let r = 0; r < ranks.length; ++r) {
let nodes = this.graph_.nodesByPageRank.get(ranks[r]);
let x = r * SPACING;
let yRankOffset = 0 - ((nodes.length / 2) * SPACING);
for (let n = 0; n < nodes.length; ++n) {
let node = nodes[n];
let pos = [
r * SPACING,
Math.floor((nodes.length / 2) * SPACING) + (n * SPACING) +
(node.subgraph * SPACING * maxRankNodes),
];
let ySubgraphOffset = (node.subgraph * SPACING * maxRankNodes);
let pos = [x, (n * SPACING) + yRankOffset + ySubgraphOffset];
let layoutNode = new LayoutNode(node, this.nodesByPos_, pos);
this.nodes_.push(layoutNode);
this.nodesByGraphNode_.set(node, layoutNode);