src/Functions.cpp
/**
 * This function prints out the contents of the suffix tree by walking through the
 * hash table and printing out all used edges. It provides next infomration:
 * Start - starting node index
 * End - ending node index
 * Suf - suffix node index
 * First - index of first char in sequence
 * Last - index of last char in sequence
 * String - content of suffix
 */
This function prints out the contents of the suffix tree by walking through the
hash table and printing out all used edges.
This function prints out the contents of the suffix tree by walking through the hash table and printing out all used edges .
void print_edges(int current_n, ofstream &file) {
    cout << " Start  End  Suf  First  Last  String\n";
    file << " Start  End  Suf  First  Last  String\n";
    for (int j = 0; j < HASH_TABLE_SIZE; j++) {
        Edge *s = Edges + j;
        if (s->start_node == -1)
            continue;
        cout << setw(5) << s->start_node << " "
        << setw(5) << s->end_node << " "
        << setw(3) << Nodes[s->end_node].suffix_node << " "
        << setw(5) << s->first_char_index << " "
        << setw(6) << s->last_char_index << "  ";
        file << setw(5) << s->start_node << " "
        << setw(5) << s->end_node << " "
        << setw(3) << Nodes[s->end_node].suffix_node << " "
        << setw(5) << s->first_char_index << " "
        << setw(6) << s->last_char_index << "  ";
        int top;
        if (current_n > s->last_char_index)
            top = s->last_char_index;
        else
            top = current_n;
        for (int l = s->first_char_index; l <= top; l++) {
            cout << Sequence[l];
            file << Sequence[l];
        }
        cout << "\n";
        file << "\n";
    }
}
void print_edges ( int current_n , ofstream & file ) { cout << " \n " ; file << " \n " ; for ( int j = 0 ; j < HASH_TABLE_SIZE ; j ++ ) { Edge * s = Edges + j ; if ( s -> start_node == -1 ) continue ; cout << setw ( 5 ) << s -> start_node << " " << setw ( 5 ) << s -> end_node << " " << setw ( 3 ) << Nodes [ s -> end_node ] . suffix_node << " " << setw ( 5 ) << s -> first_char_index << " " << setw ( 6 ) << s -> last_char_index << " " ; file << setw ( 5 ) << s -> start_node << " " << setw ( 5 ) << s -> end_node << " " << setw ( 3 ) << Nodes [ s -> end_node ] . suffix_node << " " << setw ( 5 ) << s -> first_char_index << " " << setw ( 6 ) << s -> last_char_index << " " ; int top ; if ( current_n > s -> last_char_index ) top = s -> last_char_index ; else top = current_n ; for ( int l = s -> first_char_index ; l <= top ; l ++ ) { cout << Sequence [ l ] ; file << Sequence [ l ] ; } cout << " \n " ; file << " \n " ; } }
This function prints out the contents of the suffix tree by walking through the
 hash table and printing out all used edges.
This function prints out the contents of the suffix tree by walking through the hash table and printing out all used edges .