boolean regionalSmooth (tree *tr, nodeptr p, int maxtimes, int region) { nodeptr q; int i; if (isTip(p->number, tr->rdta->numsp)) return FALSE; /* Should be an error */ for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; while (--maxtimes >= 0) { for(i = 0; i < tr->numBranches; i++) tr->partitionSmoothed[i] = TRUE; q = p; do { if (! smoothRegion(tr, q, region)) return FALSE; q = q->next; } while (q != p); if (allSmoothed(tr)) break; } for(i = 0; i < tr->numBranches; i++) tr->partitionSmoothed[i] = FALSE; for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; return TRUE; } /* localSmooth */
boolean localSmooth (tree *tr, nodeptr p, int maxtimes) { nodeptr q; int i; if (isTip(p->number, tr->rdta->numsp)) return FALSE; for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; while (--maxtimes >= 0) { for(i = 0; i < tr->numBranches; i++) tr->partitionSmoothed[i] = TRUE; q = p; do { if (! update(tr, q)) return FALSE; q = q->next; } while (q != p); if (allSmoothed(tr)) break; } for(i = 0; i < tr->numBranches; i++) { tr->partitionSmoothed[i] = FALSE; tr->partitionConverged[i] = FALSE; } return TRUE; }
void nniSmooth(tree *tr, nodeptr p, int maxtimes) { int i; for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; while (--maxtimes >= 0) { for(i = 0; i < tr->numBranches; i++) tr->partitionSmoothed[i] = TRUE; assert(!isTip(p->number, tr->mxtips)); assert(!isTip(p->back->number, tr->mxtips)); update(tr, p); update(tr, p->next); update(tr, p->next->next); update(tr, p->back->next); update(tr, p->back->next->next); if (allSmoothed(tr)) break; } for(i = 0; i < tr->numBranches; i++) { tr->partitionSmoothed[i] = FALSE; tr->partitionConverged[i] = FALSE; } }
boolean smoothTree (tree *tr, int maxtimes) { nodeptr p, q; int i, count = 0; p = tr->start; for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; while (--maxtimes >= 0) { for(i = 0; i < tr->numBranches; i++) tr->partitionSmoothed[i] = TRUE; if (! smooth(tr, p->back)) return FALSE; if (!isTip(p->number, tr->rdta->numsp)) { q = p->next; while (q != p) { if (! smooth(tr, q->back)) return FALSE; q = q->next; } } count++; if (allSmoothed(tr)) break; } for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; return TRUE; }
static void smoothTreeRandom (tree *tr, int maxtimes) { int i, k, *perm; tr->branchCounter = 0; tr->numberOfBranches = 2 * tr->mxtips - 3; tr->bInf = (branchInfo*)rax_malloc(tr->numberOfBranches * sizeof(branchInfo)); perm = (int*)rax_malloc(sizeof(int) * tr->numberOfBranches); setupBranches(tr, tr->start->back, tr->bInf); for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; /*printf("%d \n", maxtimes);*/ while (--maxtimes >= 0) { for(i = 0; i < tr->numBranches; i++) tr->partitionSmoothed[i] = TRUE; /*printf("%d %d\n", maxtimes, tr->numberOfBranches);*/ for(k = 0; k < tr->numberOfBranches; k++) perm[k] = k; makePerm(perm, tr->numberOfBranches); for(k = 0; k < tr->numberOfBranches; k++) { /*printf("%d Node %d\n", k, tr->bInf[k].oP->number);*/ update(tr, tr->bInf[perm[k]].oP); newviewGeneric(tr, tr->bInf[perm[k]].oP); } /*if (! smooth(tr, p->back)) return FALSE; if (!isTip(p->number, tr->rdta->numsp)) { q = p->next; while (q != p) { if (! smooth(tr, q->back)) return FALSE; q = q->next; } } */ if (allSmoothed(tr)) break; } for(i = 0; i < tr->numBranches; i++) tr->partitionConverged[i] = FALSE; rax_free(tr->bInf); rax_free(perm); }