-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneralizedSuffixTree.h
81 lines (58 loc) · 2.08 KB
/
GeneralizedSuffixTree.h
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
81
/*******************************************************************************
* Copyright (c) 2013 95A31.
*
* This file is part of SimpleGST.
*
* SimpleGST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GeneralizedSuffixTree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GeneralizedSuffixTree. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef GENERALIZEDSUFFIXTREE_H_
#define GENERALIZEDSUFFIXTREE_H_
#include <vector>
#include <string>
#include <vector>
#include "ActivePoint.h"
#include "Node.h"
using namespace std;
class GeneralizedSuffixTree {
public:
GeneralizedSuffixTree(string s);
GeneralizedSuffixTree(vector<string>& strings);
virtual ~GeneralizedSuffixTree();
int addString(string& s);
void exportInDotFormat(char* fileName);
char getLastChar(Node& n);
string getEdgeString(Node& node);
string getEdgeStringWithTerm(Node& node, bool withTerm);
int lastInsertedNode = -1;
int currentStringIdx = -1;
short currentCharIdx = -1;
vector<string> strings;
int rootIdx;
unordered_map<int, Node> nodes;
private:
void initialize(vector<string>& strings);
void clearStringInfo();
void addNextString();
void extend();
char getActiveEdge();
Node getActiveNode();
bool walkDown(int node);
int addNode(int stringIdx, short labelStartIdx, short labelEndInx);
int addLeaf(int stringIdx, short labelStartIdx, short labelEndInx);
void setSuffixLink(int node);
ActivePoint activePoint;
int currentNodeID = -1;
short currentStringLength = -1;
};
#endif /* GENERALIZEDSUFFIXTREE_H_ */