MCPcopy Create free account
hub / github.com/rambaut/figtree / calculateNodeHeights

Method calculateNodeHeights

src/figtree/treeviewer/ReRootedTree.java:502–522  ·  view source on GitHub ↗

Set the node heights from the current branch lengths.

()

Source from the content-addressed store, hash-verified

500 * Set the node heights from the current branch lengths.
501 */
502 private void calculateNodeHeights() {
503
504 if (!lengthsKnown) {
505 throw new IllegalArgumentException("Can't calculate node heights because branch lengths not known");
506 }
507
508 nodeLengthsToHeights(rootNode, 0.0);
509
510 double maxHeight = 0.0;
511 for (Node externalNode : getExternalNodes()) {
512 if (((ReRootedNode)externalNode).getHeight() > maxHeight) {
513 maxHeight = ((ReRootedNode)externalNode).getHeight();
514 }
515 }
516
517 for (Node node : getNodes()) {
518 ((ReRootedNode)node).setHeight(maxHeight - ((ReRootedNode)node).getHeight());
519 }
520
521 heightsKnown = true;
522 }
523
524 /**
525 * Set the node heights from the current node branch lengths. Actually

Callers 1

getHeightMethod · 0.95

Calls 5

nodeLengthsToHeightsMethod · 0.95
getExternalNodesMethod · 0.95
getNodesMethod · 0.95
getHeightMethod · 0.45
setHeightMethod · 0.45

Tested by

no test coverage detected