Debian Codegraph @

src/dr/evomodel/treedatalikelihood/ProcessOnTreeDelegate.java

raw symbols SCIP
1 /*
2 * ProcessOnTreeDelegate.java
3 *
4 * Copyright (c) 2002-2016 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.evomodel.treedatalikelihood;
27
28 import dr.inference.model.Model;
29
30 import java.util.List;
31
32 /**
33 * DataLikelihoodDelegate - interface for a plugin delegate for the data likelihood.
34 *
35 * @author Andrew Rambaut
36 * @author Marc Suchard
37 * @version $Id$
38 */
39 public interface ProcessOnTreeDelegate {
40
41 TreeTraversal.TraversalType getOptimalTraversalType();
42
43 final class BranchOperation {
44 public BranchOperation(int branchNumber, double branchLength) {
45 this.branchNumber = branchNumber;
46 this.branchLength = branchLength;
47 }
48
49 public int getBranchNumber() {
50 return branchNumber;
51 }
52
53 public double getBranchLength() {
54 return branchLength;
55 }
56
57 public String toString() {
58 return branchNumber + ":" + branchLength;
59 }
60
61 private final int branchNumber;
62 private final double branchLength;
63 }
64
65 final class NodeOperation {
66 public NodeOperation(int nodeNumber, int leftChild, int rightChild) {
67 this.nodeNumber = nodeNumber;
68 this.leftChild = leftChild;
69 this.rightChild = rightChild;
70 }
71
72 public int getNodeNumber() {
73 return nodeNumber;
74 }
75
76 public int getLeftChild() {
77 return leftChild;
78 }
79
80 public int getRightChild() {
81 return rightChild;
82 }
83
84 public String toString() {
85 return nodeNumber + "(" + leftChild + "," + rightChild + ")";
86 }
87
88 private final int nodeNumber;
89 private final int leftChild;
90 private final int rightChild;
91 }
92
93 final class BranchNodeOperation {
94 public BranchNodeOperation(int nodeNumber, int parentNumber, double branchLength) {
95 this.nodeNumber = nodeNumber;
96 this.parentNumber = parentNumber;
97 this.branchLength = branchLength;
98 }
99
100 public int getNodeNumber() {
101 return nodeNumber;
102 }
103
104 public int getParentNumber() { return parentNumber; }
105
106 public double getBranchLength() { return branchLength; }
107
108 public String toString() {
109 return nodeNumber + "(" + parentNumber + "):" + branchLength;
110 }
111
112 private final int nodeNumber;
113 private final int parentNumber;
114 private final double branchLength;
115 }
116
117 final class Utils {
118
119 static <T> String toString(List<T> operations) {
120 StringBuilder sb = new StringBuilder();
121 for (T op : operations) {
122 sb.append(op.toString()).append("\n");
123 }
124 return sb.toString();
125 }
126 }
127 }