本文整理汇总了C++中tree::FixClades方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::FixClades方法的具体用法?C++ tree::FixClades怎么用?C++ tree::FixClades使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::FixClades方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareClades
int CompareClades(tree T, node* x, node* y)
{
// printf("COMPARE\n");
int q = 0;
if (x->clade.size() < y->clade.size()) {
//printf("LESS\n");
return 1;}
else if (x->clade.size() == y->clade.size())
{
// printf("EQUAL %lu\n", x->clade.size());
for (int i = 0; i < y->clade.size(); ++i)
{
q = 0;
for (int j = 0; j < x->clade.size(); ++j)
{
if (y->clade[i] == x->clade[j]) q = 1;
}
if (q == 0) {return 1;}
}
return 0;
}
else// if ( 1 == 0)
{
int N = (int)x->childs.size();
int k;
int* A = (int*)calloc(2, sizeof(int));
node* n = new node;
for (k = 2; k < N; ++k)
{
A = (int*)realloc(A, k*sizeof(int));
for (int i = 0; i < k; ++i)
{
A[i] = i;
}
int p = k;
int C = 0;
while (p > -1)
{
n->clade.erase(n->clade.begin(), n->clade.end());
for (int i = 0; i < k; ++i)
{
for (int s = 0; s < x->childs[A[i]]->clade.size(); ++s)
{
int L = 0;
for (int v = 0; v < n->clade.size(); ++v)
{
if (n->clade[v] == x->childs[A[i]]->clade[s])
{
L = 1;
}
}
if (L == 0) n->clade.push_back(x->childs[A[i]]->clade[s]);
}
// n->clade.insert(n->clade.end(), x->childs[A[i]]->clade.begin(), x->childs[A[i]]->clade.end());
}
if (n->clade.size() == y->clade.size())
{
// printf("A k = %d; N = %d: ", k,N);
// for (int s = 0; s < k; ++s)
{
// printf("%2d ", A[s]);
}
// printf(";\n");
for (int s = 0; s < n->clade.size(); ++s)
{
// printf("\tn: %3s; y: %3s\n", n->clade[s].c_str(), y->clade[s].c_str());
}
// printf("=============\n");
T.FixClades(n);
if (CompareClades(T, n, y) == 0) {
// printf("FUCK YEAH\n");
return 0;}
}
C++;
if (A[k-1] == N-1) --p;
else p = k-1;
if (p > -1)
{
for (int i = k-1; i > p-1; --i)
{
A[i] = A[p]+i-p+1;
}
}
}
// printf("k = %d; N = %d; C = %d\n", k, N, C);
}
}
return 1;
}