(v, w, ancestor)
| 138336 | // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees. |
| 138337 | // Finally, we add a new thread (if necessary). |
| 138338 | function apportion(v, w, ancestor) { |
| 138339 | if (w) { |
| 138340 | var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift; |
| 138341 | while(vim = nextRight(vim), vip = nextLeft(vip), vim && vip){ |
| 138342 | vom = nextLeft(vom); |
| 138343 | vop = nextRight(vop); |
| 138344 | vop.a = v; |
| 138345 | shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); |
| 138346 | if (shift > 0) { |
| 138347 | moveSubtree(nextAncestor(vim, v, ancestor), v, shift); |
| 138348 | sip += shift; |
| 138349 | sop += shift; |
| 138350 | } |
| 138351 | sim += vim.m; |
| 138352 | sip += vip.m; |
| 138353 | som += vom.m; |
| 138354 | sop += vop.m; |
| 138355 | } |
| 138356 | if (vim && !nextRight(vop)) { |
| 138357 | vop.t = vim; |
| 138358 | vop.m += sim - sop; |
| 138359 | } |
| 138360 | if (vip && !nextLeft(vom)) { |
| 138361 | vom.t = vip; |
| 138362 | vom.m += sip - som; |
| 138363 | ancestor = v; |
| 138364 | } |
| 138365 | } |
| 138366 | return ancestor; |
| 138367 | } |
| 138368 | function sizeNode(node) { |
| 138369 | node.x *= dx; |
| 138370 | node.y = node.depth * dy; |
no test coverage detected