예제 #1
0
static void makeBipartitionsRec(nodeptr p, bList *blThis, int *bCountThis, int numsp)
{  
  if(/*p->tip*/ isTip(p->number, numsp))
    return;
  {
    nodeptr q;
    int l, r;
    int c;   
    
    if(/*!p->back->tip*/ ! isTip(p->back->number, numsp))
      {       
	l = countTips(p, numsp);
	r = countTips(p->back, numsp);
	c = 0;
	     
	if(l < r)
	  {
	    blThis[*bCountThis].entries = (int *)malloc(l * sizeof(int));	   
	    getTips(p, &c, blThis[*bCountThis].entries, numsp);
	  }
	else
	  {
	    blThis[*bCountThis].entries = (int *)malloc(r * sizeof(int));
	    getTips(p->back, &c, blThis[*bCountThis].entries, numsp);
	  }
	
	blThis[*bCountThis].length = c;      

	qsort((blThis[*bCountThis].entries), c, sizeof(int), intCompare);
	blThis[*bCountThis].p = p;
	blThis[*bCountThis].pNum = p->number;
	blThis[*bCountThis].qNum = p->back->number;
	*bCountThis = *bCountThis + 1;
      }
  
    q = p->next;
    while(q != p)
      {
	makeBipartitionsRec(q->back, blThis, bCountThis, numsp);
	q = q->next;
      } 
    return;
  }
}
예제 #2
0
static void collectSubtrees(tree *tr, nodeptr *subtrees, int *count, int ogn)
{
  int i;
  for(i = tr->mxtips + 1; i <= tr->mxtips + tr->mxtips - 2; i++)
    {
      nodeptr p, q;
      p = tr->nodep[i];
      if(countTips(p, tr->rdta->numsp) == ogn)
	{
	  subtrees[*count] = p;
	  *count = *count + 1;
	}
      q = p->next;
      while(q != p)
	{
	  if(countTips(q, tr->rdta->numsp) == ogn)
	    {
	      subtrees[*count] = q;
	      *count = *count + 1;
	    }
	  q = q->next;
	}
    }
}
예제 #3
0
static void addRecBL(nodeptr p, BL *b, int number, int modulo, int numberOfTips, int numsp)
{  
  if(/*p->tip*/ isTip(p->number, numsp))
    return;
  {
    nodeptr q;    
    
    if(/*!p->back->tip*/ ! isTip(p->back->number, numsp))
      {       
	int *entries;
	int length = 0; 
	int l, r;  

	l = countTips(p, numsp);
	if(l < ((numberOfTips/2) + 1))
	  {
	    entries = (int *)malloc(l * sizeof(int));	   
	    getTips(p, &length, entries, numsp);
	  }
	else
	  {
	    r = numberOfTips - l;
	    entries = (int *)malloc(r * sizeof(int));
	    getTips(p->back, &length, entries, numsp);	  
	  }	    

	qsort(entries, length, sizeof(int), intCompare);

	{
	  double t = gettime();
	  addBipartitionsFaster(b, number, entries, length, modulo);
	  addTime += (gettime() - t);
	}

	free(entries);	
      }
  
    q = p->next;
    while(q != p)
      {
        addRecBL(q->back, b, number, modulo, numberOfTips, numsp);
	q = q->next;
      } 
    return;
  }
}
예제 #4
0
int countTips(nodeptr p, int numsp)
{
  if(isTip(p->number, numsp))  
    return 1;    
  {
    nodeptr q;
    int tips = 0;

    q = p->next;
    while(q != p)
      { 
	tips += countTips(q->back, numsp);
	q = q->next;
      } 
    
    return tips;
  }
}