Debian Codegraph @

src/dr/evolution/tree/Tree.java

raw symbols SCIP
1 /*
2 * Tree.java
3 *
4 * Copyright (c) 2002-2015 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.evolution.tree;
27
28 import dr.evolution.util.Taxon;
29 import dr.evolution.util.TaxonList;
30 import dr.evolution.util.Units;
31 import dr.util.Attributable;
32 import dr.util.Identifiable;
33 import jebl.evolution.graphs.Node;
34 import jebl.evolution.trees.SimpleRootedTree;
35
36 import java.text.NumberFormat;
37 import java.util.*;
38
39 /**
40 * Interface for a phylogenetic or genealogical tree.
41 *
42 * @author Andrew Rambaut
43 * @author Alexei Drummond
44 * @version $Id: Tree.java,v 1.59 2006/09/08 17:34:23 rambaut Exp $
45 */
46 public interface Tree extends TaxonList, Units, Identifiable, Attributable {
47
48 /**
49 * @return root node of this tree.
50 */
51 NodeRef getRoot();
52
53 /**
54 * @return a count of the number of nodes (internal + external) in this
55 * tree, currently connected from the root node.
56 */
57 int getNodeCount();
58
59 /**
60 * @param i node index, terminal nodes are first
61 * @return the ith node.
62 */
63 NodeRef getNode(int i);
64
65 /**
66 * @param i index of an internal node
67 * @return the ith internal node.
68 */
69 NodeRef getInternalNode(int i);
70
71 /**
72 * @param i the index of an external node
73 * @return the ith external node.
74 */
75 NodeRef getExternalNode(int i);
76
77 /**
78 * @return a count of the number of external nodes (tips) in this
79 * tree, currently connected from the root node.
80 */
81 int getExternalNodeCount();
82
83 /**
84 * @return a count of the number of internal nodes in this
85 * tree, currently connected from the root node.
86 */
87 int getInternalNodeCount();
88
89 /**
90 * @param node the node to retrieve the taxon of
91 * @return the taxon of this node.
92 */
93 Taxon getNodeTaxon(NodeRef node);
94
95 /**
96 * @return whether this tree has known node heights.
97 */
98 boolean hasNodeHeights();
99
100 /**
101 * @param node the node to retrieve height of
102 * @return the height of node in the tree.
103 */
104 double getNodeHeight(NodeRef node);
105
106 /**
107 * @return whether this tree has known branch lengths.
108 */
109 boolean hasBranchLengths();
110
111 /**
112 * @param node the node to retrieve the length of branch to parent
113 * @return the length of the branch from node to its parent.
114 */
115 double getBranchLength(NodeRef node);
116
117 /**
118 * @param node the node to retrieve the rate of
119 * @return the rate of node in the tree.
120 */
121 double getNodeRate(NodeRef node);
122
123 /**
124 * @param node the node whose attribute is being fetched.
125 * @param name the name of the attribute of interest.
126 * @return an object representing the named attributed for the given node.
127 */
128 Object getNodeAttribute(NodeRef node, String name);
129
130 /**
131 * @param node the node whose attribute is being fetched.
132 * @return an interator of attribute names available for this node.
133 */
134 Iterator getNodeAttributeNames(NodeRef node);
135
136 /**
137 * @param node the node to test if external
138 * @return whether the node is external.
139 */
140 boolean isExternal(NodeRef node);
141
142 /**
143 * @param node the node to test if root
144 * @return whether the node is the root.
145 */
146 boolean isRoot(NodeRef node);
147
148 /**
149 * @param node the node to get child count of
150 * @return the number of children of node.
151 */
152 int getChildCount(NodeRef node);
153
154 /**
155 * @param node the node to get jth child of
156 * @param j the index of child to retrieve
157 * @return the jth child of node
158 */
159 NodeRef getChild(NodeRef node, int j);
160
161 NodeRef getParent(NodeRef node);
162
163 /**
164 * @return a clone of this tree
165 */
166 public Tree getCopy();
167
168 }