A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bipartition.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_BIPARTITION_BIPARTITION_H_
2 #define GENESIS_TREE_BIPARTITION_BIPARTITION_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include "genesis/tree/tree.hpp"
36 
37 namespace genesis {
38 namespace tree {
39 
40 // =============================================================================
41 // Bipartition
42 // =============================================================================
43 
45 {
46 public:
47 
48  // -------------------------------------------------------------
49  // Declarations and Constructor
50  // -------------------------------------------------------------
51 
52  Bipartition() = default;
53 
55  : link_( &link )
56  , leaf_nodes_( leaf_nodes )
57  {}
58 
59  ~Bipartition() = default;
60 
61  Bipartition( Bipartition const& ) = default;
62  Bipartition( Bipartition&& ) = default;
63 
64  Bipartition& operator= ( Bipartition const& ) = default;
65  Bipartition& operator= ( Bipartition&& ) = default;
66 
67  // -------------------------------------------------------------
68  // Member Functions
69  // -------------------------------------------------------------
70 
71  TreeLink const& link() const
72  {
73  return *link_;
74  }
75 
77  {
78  return leaf_nodes_;
79  }
80 
82  {
83  return leaf_nodes_;
84  }
85 
86  void invert()
87  {
89  link_ = &link_->outer();
90  }
91 
92  bool empty() const
93  {
94  return link_ == nullptr;
95  }
96 
97  // -------------------------------------------------------------
98  // Member Variables
99  // -------------------------------------------------------------
100 
101 protected:
102 
103  TreeLink const* link_ = nullptr;
105 
106 };
107 
108 } // namespace tree
109 } // namespace genesis
110 
111 #endif // include guard
Bipartition(TreeLink const &link, utils::Bitvector const &leaf_nodes)
Definition: bipartition.hpp:54
Bipartition & operator=(Bipartition const &)=default
TreeLink const & link() const
Definition: bipartition.hpp:71
utils::Bitvector & bitvector()
Definition: bipartition.hpp:76
void negate()
Flip all bits.
Definition: bitvector.cpp:224
utils::Bitvector const & leaf_nodes() const
Definition: bipartition.hpp:81
utils::Bitvector leaf_nodes_
Header of Tree class.