34 vectortype first_child;
35 vectortype next_sibling;
46 vectortype suffix_link;
70 void add_sl(
uint node){
73 if(last_added_sl != 0) {
74 suffix_link[last_added_sl]=node;
93 auto size = Text.
size() * 2 -1;
94 start= vectortype(size + 1, 0);
95 end = vectortype(size + 1, 0);
96 first_child= vectortype(size, 0);
97 next_sibling= vectortype(size, 0);
98 suffix_link= vectortype(size, 0);
99 suffix= vectortype(size + 1, 0);
110 first_child.
resize(new_node);
111 next_sibling.
resize(new_node);
123 suffix_link=vectortype(0, 0);
152 DLOG(INFO)<<
"Text size: " << Text.
size();
154 for (
uint i = 0; i < Text.
size(); i++) {
173 if(end[node] == (
uint)0){
174 return pos - start[node]+1;
176 return end[node]- start[node];
186 inline void add_char(
char c){
192 while(remainder > 0){
193 if(active_length==0){
201 uint child = first_child[active_node];
202 uint previous_sibling = child;
206 if( Text[(start[child])] == active_edge){
210 previous_sibling = child;
211 child=next_sibling[child];
221 uint leaf = create_node(pos, 0, active_edge);
222 suffix[leaf] = current_suffix++;
223 if(first_child[active_node]== (
uint)0){
224 first_child[active_node] = leaf;
226 next_sibling[previous_sibling] = leaf;
238 active_edge = (char) Text[pos-active_length];
243 if( (
char) Text[start[next]+active_length] == c){
252 uint split = create_node(start[next], start[next]+active_length, active_edge);
255 start[next]=start[next]+ active_length;
259 if(first_child[active_node] == (
uint) 0){
260 first_child[active_node]= split;
262 if(first_child[active_node] == next){
263 first_child[active_node]= split;
265 next_sibling[previous_sibling] = split;
267 first_child[split] = next;
268 next_sibling[split] = next_sibling[next];
270 uint leaf = create_node(pos, 0, c);
271 next_sibling[next] = leaf;
272 suffix[leaf] = current_suffix++;
277 if(active_node==0 && active_length>0){
279 active_edge = Text[pos-remainder+1];
281 if(suffix_link[active_node] != (
uint)0){
282 active_node = suffix_link[active_node];
298 return first_child[node];
302 return next_sibling[node];
318 std::stringstream ss ;
319 ss << start[node]<<
" " <<start[node] +
edge_length(node);
331 uint child = first_child[node];
335 child=next_sibling[child];
Contains the text compression and encoding framework.
uint edge_length(uint node)
std::string get_string_of_edge(uint node)
A vector over arbitrary unsigned integer types.
BinarySuffixTree(io::InputView &input)
uint get_next_sibling(uint node)
size_type size() const
Returns size of the View.
uint get_first_child(uint node)
uint get_suffix(uint node)
void print_tree(uint node, std::string depth)
uint get_edge_length(uint node)