A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
link.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2017 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
33 namespace genesis {
34 namespace tree {
35 
36 // =================================================================================================
37 // Accessors
38 // =================================================================================================
39 
43 size_t TreeLink::index() const
44 {
45  return index_;
46 }
47 
52 {
53  return *next_;
54 }
55 
59 TreeLink const& TreeLink::next() const
60 {
61  return *next_;
62 }
63 
71 {
72  TreeLink* res = this;
73  while( &res->next() != this ) {
74  res = &res->next();
75  }
76  return *res;
77 }
78 
85 TreeLink const& TreeLink::prev() const
86 {
87  TreeLink const* res = this;
88  while( &res->next() != this ) {
89  res = &res->next();
90  }
91  return *res;
92 }
93 
98 {
99  return *outer_;
100 }
101 
105 TreeLink const& TreeLink::outer() const
106 {
107  return *outer_;
108 }
109 
114 {
115  return *edge_;
116 }
117 
121 TreeEdge const& TreeLink::edge() const
122 {
123  return *edge_;
124 }
125 
130 {
131  return *node_;
132 }
133 
137 TreeNode const& TreeLink::node() const
138 {
139  return *node_;
140 }
141 
142 // =================================================================================================
143 // Modifiers
144 // =================================================================================================
145 
147 {
148  index_ = val;
149  return *this;
150 }
151 
153 {
154  next_ = val;
155  return *this;
156 }
157 
159 {
160  outer_ = val;
161  return *this;
162 }
163 
165 {
166  node_ = val;
167  return *this;
168 }
169 
171 {
172  edge_ = val;
173  return *this;
174 }
175 
176 // =================================================================================================
177 // Member Functions
178 // =================================================================================================
179 
183 bool TreeLink::is_leaf() const
184 {
185  return next_ == this;
186 }
187 
191 bool TreeLink::is_inner() const
192 {
193  return next_ != this;
194 }
195 
202 std::string TreeLink::dump() const
203 {
204  return "";
205 }
206 
207 } // namespace tree
208 } // namespace genesis