A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bipartition_set.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_BIPARTITION_BIPARTITION_SET_H_
2 #define GENESIS_TREE_BIPARTITION_BIPARTITION_SET_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
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 <string>
35 #include <unordered_set>
36 #include <vector>
37 
39 
40 namespace genesis {
41 namespace tree {
42 
44 {
45 public:
46 
47  // -------------------------------------------------------------
48  // Declarations and Constructor
49  // -------------------------------------------------------------
50 
51  BipartitionSet (Tree& tree) : tree_(tree) {};
52 
53  // -------------------------------------------------------------
54  // Member Functions
55  // -------------------------------------------------------------
56 
57  void make();
58  void make_index();
59 
60  Bipartition* find_smallest_subtree ( std::vector<TreeNode*> nodes );
61  std::unordered_set<size_t> get_subtree_edges( TreeLink* subtree );
62 
63  bool validate();
64  std::string dump();
65 
66  // -------------------------------------------------------------
67  // Member Variables
68  // -------------------------------------------------------------
69 
70 protected:
71 
73 
74  std::vector<int> node_to_leaf_map_;
75  std::vector<size_t> leaf_to_node_map_;
76 
77  std::vector<Bipartition> bipartitions_;
78 
79 };
80 
81 } // namespace tree
82 } // namespace genesis
83 
84 #endif // include guard
std::vector< int > node_to_leaf_map_
std::vector< Bipartition > bipartitions_
Bipartition * find_smallest_subtree(std::vector< TreeNode * > nodes)
Finds the smallest subtree (measured in number of nodes) that contains all given nodes.
std::vector< size_t > leaf_to_node_map_
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:95
std::unordered_set< size_t > get_subtree_edges(TreeLink *subtree)