@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)
| 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. |
no test coverage detected