DNWA/11/wywolania/Data/stide_v1.1/Seq-code/flexitree.h
Jakub Stefko ab1d7e2546 ...
2021-01-28 18:33:55 +01:00

60 lines
1.6 KiB
C++
Executable File

#ifndef __FLEXITREE_H
#define __FLEXITREE_H
#include "../Utils/arrays.h"
class FlexiTreeNode;
class FlexiTree {
private:
FlexiTreeNode *children;
int root;
int id;
public:
void Write(ostream &s, int &depth);
int Read(istream &s, int &depth);
int OutputGraph(ostream &s);
FlexiTree();
FlexiTree(int d);
~FlexiTree();
void SetRoot(int d) {root = d;}
int InsertSeq(const Array<int> &seq, int first, int last);
int IsSeqInTree(const Array<int> &seq, int first, int last);
int ComputeHDistForTree(Array<int> &seq, int first, int last);
friend ostream &operator<<(ostream &s, FlexiTree &tn);
friend istream &operator>>(istream &s, FlexiTree &tn);
int NumNodes(); // returns the number of nodes in the tree
int NumLeaves(); // returns the number of leaves in the tree, i.e num of distinct seqs
int NumBranches(); // returns the total # of branches, of all nodes
};
//===========================================================================
class SeqForest {
public:
// this structure is a an array of N tree nodes, i.e. a tree for each value
// type
Array<FlexiTree> trees;
// this structure is to record what types of values actually occured -
// for efficiency, if there were actually fewer value types than
// specified in the config
Array<int> trees_found;
SeqForest(int max_trees)
{trees.Allocate(max_trees); trees_found.Allocate(max_trees); trees_found.Set(0);}
int IsSeqInForest(const Array<int> &seq, int seq_len) const;
};
//===========================================================================
#endif