File: Tree.h

package info (click to toggle)
proda 1.0-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 584 kB
  • sloc: cpp: 8,549; xml: 163; makefile: 109; sh: 12
file content (78 lines) | stat: -rw-r--r-- 1,874 bytes parent folder | download | duplicates (4)
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
//////////////////////////////////////////////////////////////////////
// Tree.h
//////////////////////////////////////////////////////////////////////

#ifndef TREE_H
#define TREE_H

#include <vector>
#include "Matrix.h"
#include "MultiSequence.h"

//////////////////////////////////////////////////////////////////////
// Expected accuracy tree
//////////////////////////////////////////////////////////////////////

typedef std::vector<int> IVECT;
class Tree {

 public:

  //////////////////////////////////////////////////////////////////////
  // Tree node struct
  //////////////////////////////////////////////////////////////////////
  
  class TreeNode {
    
    bool isLeaf;
    int numSequences;
    MultiSequence *seqs;
    
    TreeNode *leftChild;
    TreeNode *rightChild;

  public:
	  void UpdateIDs(int *used);
	  void GetIDs(IVECT &ids);

    // constructor and destructor
    TreeNode (bool isLeaf, int numSequences, MultiSequence *seqs,
	      TreeNode *leftChild, TreeNode *rightChild);
    ~TreeNode ();
    
    // getters
    const bool GetIsLeaf() const;
    const int GetNumSequences() const;
    const MultiSequence *GetSequences() const;
    const TreeNode *GetLeftChild() const;
    const TreeNode *GetRightChild() const;

    // print subtree starting at this node
    void Print (FILE *file) const;
    
    // progressive alignment
    void ProgressiveAlignment (int numSequences, SparseMatrix **posteriors);
  };
  
 private:

  TreeNode *root;

 public:
	 void UpdateIDs(int *used);
	 void GetIDs(IVECT &ids);
	 int GetNumSequences();
  
  // constructor and destructor
  Tree (Matrix similarity, const MultiSequence &seqs, float threshold = 0);
  ~Tree ();
  
  // print tree
  void Print (FILE *file) const;
  
  // progressive alignment
  MultiSequence *ProgressiveAlignment (int numSequences, SparseMatrix **posteriors);
};

#endif