
/********************************************************************
 *
 * Implementation of the adaptive algorithm for determining
 * strings from substrings.
 * Prefix tree version.
 *
 *
 ********************************************************************/
#ifndef  _STREEH
#define  _STREEH

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>

#define  NUMSTR    10000
#define  ALPHABET  5
#define  MINLEN    12

typedef struct leaf {
    int  fragid : 16; 
    int  suffix : 16;
    struct leaf  *next_leaf;
} Leaf;

typedef struct node {
    int    fragid : 16;              /* upper arc */
    int    first  : 16;
    int    length : 16;
    int    depth  : 16;               /* How many chars this node is from the root.*/
    struct node *suff_link;     /* Pointer to my prev-to-last node in prefix.*/
    struct node *children[ALPHABET];    /* Array of downward arcs. */
    struct leaf *leaves;    /* Array of leaf links, for Leaf only */
} Node;

typedef enum {FALSE = 0, TRUE = 1} Bool;

extern long numOfNodes, numOfArcs, numOfLeaves;
extern long numOfStrings, numOfChars;

extern Node *initial_suffix_tree();
extern void add_a_string(Node *root, char *str, int id);
extern void DFS(Node *root);

#endif

/*  end of stree.h */

