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

Method getEdgeLength

src/figtree/treeviewer/ReRootedTree.java:401–417  ·  view source on GitHub ↗

@param node1 @param node2 @return the length of the edge connecting node1 and node2. @throws jebl.evolution.graphs.Graph.NoEdgeException if the nodes are not directly connected by an edge.

(Node node1, Node node2)

Source from the content-addressed store, hash-verified

399 * if the nodes are not directly connected by an edge.
400 */
401 public double getEdgeLength(Node node1, Node node2) throws NoEdgeException {
402 if (((ReRootedNode)node1).getParent() == node2) {
403 if (heightsKnown) {
404 return ((ReRootedNode)node2).getHeight() - ((ReRootedNode)node1).getHeight();
405 } else {
406 return ((ReRootedNode)node1).getLength();
407 }
408 } else if (((ReRootedNode)node2).getParent() == node1) {
409 if (heightsKnown) {
410 return ((ReRootedNode)node1).getHeight() - ((ReRootedNode)node2).getHeight();
411 } else {
412 return ((ReRootedNode)node2).getLength();
413 }
414 } else {
415 throw new NoEdgeException();
416 }
417 }
418
419 /**
420 * Returns an array of 2 nodes which are the nodes at either end of the edge.

Callers 4

ReRootedTreeMethod · 0.80
createNodesMethod · 0.80
rootTreeAtCenterMethod · 0.80
distMethod · 0.80

Calls 3

getParentMethod · 0.45
getHeightMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected