예제 #1
0
파일: tree.c 프로젝트: ASP1234/Scilabv5.5.2
/************************* function tree2 *********************************/
int ctree2(int *vect, int nb, int *depu, int *depuptr, int *outoin, int *outoinptr, int *ord, int *nord, int *ok)

{
    int fini = 0, i, j, k, m, ii;

    *ok = 1;
    for (j = 1; (j <= nb + 2) && (! fini); j++)
    {
        fini = 1;
        for (i = 0; i < nb; i++)
        {
            if (vect[i] == j - 1 )
            {
                if (j == nb + 2)
                {
                    *ok = 0;
                    *nord = 0;
                    return 0;
                }
                if (outoinptr[i + 1] - outoinptr[i] != 0)
                {
                    for (k = outoinptr[i]; k <= outoinptr[i + 1] - 1; k++)
                    {
                        ii = outoin[k - 1];
                        if (vect[ii - 1] > -1 && depu[depuptr[ii - 1] - 2 + outoin[outoinptr[nb] + k - 2]] == 1)
                        {
                            fini = 0;
                            vect[ii - 1] = j;
                        }
                    }
                }
            }
        }
    }
    Inver(vect, nb);
    C2F(isort)(vect, &nb, ord);
    for (m = 0 ; m < nb; m++)
    {
        if (vect[m] < 1)
        {
            if (m == 0)
            {
                *nord = nb;
                return 0;
            }
            else
            {
                *nord = nb - m;
                for (i = 0; i < *nord; i++)
                {
                    ord[i] = ord[i + nb - *nord];
                }
                return 0;
            }
        }
    }
    *nord = 0;
    return 0;
}
예제 #2
0
파일: tree.c 프로젝트: rossdrummond/scilab
/* ********************************************** function tree3 ***************************************** */
int ctree3(int *vec,int nb, int *depu, int*depuptr, int *typl, int*bexe,int*boptr,int*blnk,int*blptr,int*ord,int*nord,int*ok)
{
  int fini=0,i,j,m,nkk,kk;
  
  *ok = 1;
  for( i= 0; i < nb; i++)
    {
      if ((vec[i] == 0) && (typl[i] == 1)) vec[i]=1; 
    }
  for (j = 1; (j <= nb+2) &&(! fini); j++) 
    {
      fini = 1;
      if (j == nb + 2) 
	{
	  *ok = 0;
	  *nord = 0;
	  return 0;
	}
      
      for (i = 0; i < nb; i++) 
	{
          if (vec[i] > -1 && typl[i] != -1) 
            {
	      if (typl[i] == 1) 
                {
                  nkk = boptr[i + 1] - boptr[i];
                  if (nkk != 0) 
                    {
                      for (m = 0; m < nkk; m++) 
                        {
                          kk = bexe[m + boptr[i] - 1];
			  if (typl[kk-1] == 1) 
			    {
			      if (vec[kk-1] < vec[i]+2)
				{
				  fini=0;
				  vec[kk-1]=vec[i]+2;
				}
			    }
			  else
			    {
			      if (vec[kk-1] < vec[i]+1)
				{
				  fini=0;
				  vec[kk-1]=vec[i]+1;
				} 
			    }
			}
		    }
                } 
              else 
                {
                  nkk = blptr[i+1]-blptr[i];
                  if (nkk != 0) 
                    {
                      for (m = 0; m < nkk; m++) 
                        {
                          kk = blnk[m+blptr[i]-1];
			  if (vec[kk-1] > -1 && (depu[depuptr[kk-1]-2+blnk[blptr[nb]+blptr[i]-2]] == 1 || typl[kk-1] == 1)) 
                            {
			      if (vec[kk-1] < vec[i])
				{
				  fini=0;
				  vec[kk-1]=vec[i];
				}
			    }
                        }
                    }
                }
	    }
          
	}
    }
  Inver(vec,nb); 
  C2F(isort)(vec,&nb,ord);
  for(m=0 ; m < nb; m++)
    {
      if (vec[m] < 1){
	if (m == 0) {
	  *nord=nb;
	  return 0;
	} else {
	  *nord=nb-m;
	  for (i=0; i<*nord;i++)
	    ord[i]=ord[i+nb-*nord];
	  return 0;      
	}
      }
    }
  *nord=0;  
  return 0;
}