File: multitree.hpp

package info (click to toggle)
iqtree 2.0.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 14,620 kB
  • sloc: cpp: 142,571; ansic: 57,789; sh: 275; python: 242; makefile: 95
file content (80 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef MULTITREE_HPP
#define MULTITREE_HPP

#include "trees_impl.hpp"

#include <terraces/bigint.hpp>

namespace terraces {

enum class multitree_node_type {
	base_single_leaf,
	base_two_leaves,
	base_unconstrained,
	inner_node,
	alternative_array,
	unexplored,
};

struct multitree_node;

namespace multitree_nodes {
struct two_leaves {
	index left_leaf;
	index right_leaf;
};
struct unconstrained {
	index* begin;
	index* end;
	index num_leaves() const;
};
struct inner_node {
	multitree_node* left;
	multitree_node* right;
};
struct alternative_array {
	multitree_node* begin;
	multitree_node* end;
	index num_alternatives() const;
};
struct unexplored {
	index* begin;
	index* end;
	index num_leaves() const;
};
}

struct multitree_node {
	multitree_node_type type;
	index num_leaves;
	big_integer num_trees;
	union {
		index single_leaf;
		multitree_nodes::two_leaves two_leaves;
		multitree_nodes::unconstrained unconstrained;
		multitree_nodes::inner_node inner_node;
		multitree_nodes::alternative_array alternative_array;
		multitree_nodes::unexplored unexplored;
	};
};

struct newick_multitree_t {
	const multitree_node* root;
	const name_map* names;
};

std::ostream& operator<<(std::ostream& stream, newick_multitree_t tree);

inline newick_multitree_t as_newick(const multitree_node* root, const name_map& names) {
	return {root, &names};
}

inline index multitree_nodes::alternative_array::num_alternatives() const {
	return (index)(end - begin);
}
inline index multitree_nodes::unexplored::num_leaves() const { return (index)(end - begin); }
inline index multitree_nodes::unconstrained::num_leaves() const { return (index)(end - begin); }

} // namespace terraces

#endif // MULTITREE_HPP