本文整理汇总了C++中Cst::depth方法的典型用法代码示例。如果您正苦于以下问题:C++ Cst::depth方法的具体用法?C++ Cst::depth怎么用?C++ Cst::depth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cst
的用法示例。
在下文中一共展示了Cst::depth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_cst_dfs_iterator_and_depth
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: test_cst_matching_statistics
void test_cst_matching_statistics(const Cst& cst, unsigned char* S2, typename Cst::size_type n2)
{
typedef typename Cst::size_type size_type;
typedef typename Cst::node_type node_type;
size_type cnt = 0;
write_R_output("cst","mstats","begin",n2,cnt);
size_type q = 0; // current match length
size_type p2 = n2-1; // position in S2
size_type i = 0, j = cst.csa.size()-1; // \f$ \epsilon \f$ matches all suffixes of S1
while (p2+1 > 0) {
size_type lb, rb;
// perform backward search on interval \f$ [i,j] \f$
size_type size = algorithm::backward_search(cst.csa, i, j, S2[p2], lb, rb);
if (size > 0) {
q = q + 1;
i = lb; j = rb;
p2 = p2 - 1;
} else if (i==0 and j == cst.csa.size()) {
p2 = p2 -1;
} else {
// map interval to a node of the cst and calculate parent
node_type p = cst.parent(cst.node(i, j));
q = cst.depth(p); // update match length
i = cst.lb(p); // update left bound
j = cst.rb(p); // update right bound
}
cnt += q;
}
write_R_output("cst","mstats","end",n2,cnt);
}
示例3: test_cst_dfs_iterator
void test_cst_dfs_iterator(Cst& cst, typename Cst::size_type times=100000)
{
if (times > cst.nodes())
times = cst.nodes();
typedef typename Cst::size_type size_type;
size_type cnt=0;
{
// calc values for cnt
typename Cst::const_iterator it = cst.begin();
for (size_type i=0; i < std::min(times,(size_type)1000); ++i, ++it) {
cnt += cst.depth(*it);
}
}
write_R_output("cst","dfs","begin",times,cnt);
typename Cst::const_iterator it = cst.begin();
for (size_type i=0; i<times; ++i) {
++it;
}
write_R_output("cst", "dfs", "end", times, cnt + cst.depth(*it));
}
示例4: test_cst_depth_operation
void test_cst_depth_operation(const Cst& cst, typename Cst::size_type times=100000, uint64_t x=17)
{
typedef typename Cst::size_type size_type;
typedef typename Cst::node_type node_type;
std::vector<node_type> nodes;
generate_nodes_from_random_leaves(cst, times, nodes, x);
size_type cnt = 0;
write_R_output("cst","depth","begin",nodes.size(),cnt);
for (size_type i=0; i < nodes.size(); ++i) {
cnt += cst.depth(nodes[i]);
}
write_R_output("cst","depth","end",nodes.size(),cnt);
}
示例5: test_cst_depth_operation_for_inner_nodes
void test_cst_depth_operation_for_inner_nodes(const Cst& cst, typename Cst::size_type times=100000, uint64_t x=17)
{
typedef typename Cst::size_type size_type;
typedef typename Cst::node_type node_type;
std::vector<node_type> nodes;
{
std::vector<node_type> nodes2;
generate_nodes_from_random_leaves(cst, times, nodes2, x);
for (size_type i=0; i<nodes2.size(); ++i)
if (!cst.is_leaf(nodes2[i])) {
nodes.push_back(nodes2[i]);
}
}
size_type cnt = 0;
write_R_output("cst","depth of inner nodes","begin",nodes.size(),cnt);
for (size_type i=0; i < nodes.size(); ++i) {
cnt += cst.depth(nodes[i]);
}
write_R_output("cst","depth of inner nodes","end",nodes.size(),cnt);
}