Пример #1
0
void test_cst_dfs_iterator_and_depth(Cst& cst, typename Cst::size_type times=1000000, bool output=false)
{
    if (times > 2*cst.nodes()-cst.size())
        times = 2*cst.nodes()-cst.size();
    typedef typename Cst::size_type size_type;
    size_type cnt=0;
    write_R_output("cst","dfs and depth","begin",times,cnt);
    typename Cst::const_iterator it = cst.begin();
    if (!output) {
        for (size_type i=0; i<times; ++i, ++it) {
            if (!cst.is_leaf(*it))
                cnt += cst.depth(*it);
        }
    } else {
        for (size_type i=0; i<times; ++i, ++it) {
            if (!cst.is_leaf(*it)) {
                size_type d = cst.depth(*it);
                std::cerr << d << "-[" << cst.lb(*it) << "," << cst.rb(*it) << "] ";
                if (d < 60) {
                    for (int i=1; i<=d; ++i)
                        std::cerr<< cst.edge(*it, i);
                }
                std::cerr << std::endl;
                cnt += d;
            }
        }
    }
    write_R_output("cst","dfs and depth","end",times,cnt);
}
Пример #2
0
 louds_tree(const Cst& cst, const CstBfsIterator begin, const CstBfsIterator end):m_bv(), m_bv_select1(), m_bv_select0(), bv(m_bv) {
     bit_vector tmp_bv(4*cst.size(*begin) , 0); // resize the bit_vector to the maximal
     // possible size 2*2*#leaves in the tree
     size_type pos = 0;
     for (CstBfsIterator it = begin; it != end;) {
         tmp_bv[pos++] = 1;
         size_type size = it.size();
         ++it;
         pos += it.size()+1-size;
     }
     tmp_bv.resize(pos);
     m_bv = bit_vector_type(std::move(tmp_bv));
     util::init_support(m_bv_select1, &m_bv);
     util::init_support(m_bv_select0, &m_bv);
 }
Пример #3
0
void test_cst_dfs_iterator_and_id(Cst& cst, typename Cst::size_type times=1000000, bool output=false)
{
    if (times > 2*cst.nodes()-cst.size())
        times = 2*cst.nodes()-cst.size();
    typedef typename Cst::size_type size_type;
    size_type cnt=0;
    write_R_output("cst","dfs and id","begin",times,cnt);
    typename Cst::const_iterator it = cst.begin();
    if (!output) {
        for (size_type i=0; i<times; ++i, ++it) {
            cnt += cst.id(*it);
        }
    } else {
        for (size_type i=0; i<times; ++i, ++it) {
            size_type id = cst.id(*it);
            std::cerr << id << std::endl;
            cnt += id;
        }
    }
    write_R_output("cst","dfs and id","end",times,cnt);
}