コード例 #1
0
/**
 * Returns the d-th character of the label of the node v's incoming edge.
 */
uchar SSTree::edge(ulong v, ulong d)
{
    uchar *ss;
    if (isleaf(v))
    {
        ulong i = leftrank(v);
        ulong j = depth(parent(v));
        ulong d1 = sa->lookup(i) + j;
        if (d > n - d1)
            return 0u;
        ss = sa->substring(d1 + d - 1,1);
        uchar result = ss[0];
        delete [] ss;
        return result;
    }

    ulong d1 = hgt->GetPos(inorder(parent(v)));
    ulong d2 = hgt->GetPos(inorder(v));
    if (d > d2 - d1)
        return 0u;
    ss = sa->substring(sa->lookup(inorder(v)) + d1 + d - 1,1);
    uchar result = ss[0];
    delete [] ss;
    return result;
}
コード例 #2
0
ファイル: SSTree.cpp プロジェクト: peterwilliams97/cst
/**
 * Returns the path label from root to the node v.
 */
uchar *SSTree::pathlabel(ulong v) {
    if (isleaf(v)) {
        ulong i = leftrank(v);
        ulong k = depth(v);
        ulong d1 = _sa->lookup(i);
        return _sa->substring(d1,k);
    }
    ulong d2 = _hgt->GetPos(inorder(v));
    return _sa->substring(_sa->lookup(inorder(v)), d2);
}
コード例 #3
0
ファイル: SSTree.cpp プロジェクト: peterwilliams97/cst
/**
 * Returns the string depth of the node v.
 */
ulong SSTree::depth(ulong v) {
    if (v == 0) {
        return 0;
    }

    if (isleaf(v)) {
        ulong i = leftrank(v);
        return _n - _sa->lookup(i);
    }

    v = inorder(v);
    return _hgt->GetPos(v);
}
コード例 #4
0
ファイル: SSTree.cpp プロジェクト: peterwilliams97/cst
/**
 * Returns the edge label of the incoming edge of the node v.
 */
uchar *SSTree::edge(ulong v) {
    if (isleaf(v)) {
        ulong i = leftrank(v);
        ulong j = depth(parent(v));
        ulong k = depth(v);
        ulong d1 = _sa->lookup(i) + j;
        return _sa->substring(d1, k - j);
    }

    ulong d1 = _hgt->GetPos(inorder(parent(v)));
    ulong d2 = _hgt->GetPos(inorder(v));

    return _sa->substring(_sa->lookup(inorder(v)) + d1, d2 - d1);
}
コード例 #5
0
/**
 * Returns the Number of leaf nodes in a subtree rooted at the node v.
 */
ulong SSTree::numberofleaves(ulong v)
{
    return leftrank(Pr->findclose(v))-leftrank(v);
}