Set the node heights from the current branch lengths.
()
| 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 |
no test coverage detected