Пример #1
0
static void OdAdd(order *od,
                  int   *node_status,
                  int   x,
                  int   newsze)
{
  int n,*adjn,*rbeg,*rexs,*rlen,*pres,*succ;

  n   =od->nnod;
  adjn=od->adjn;
  rbeg=od->rbeg;
  rexs=od->rexs;
  rlen=od->rlen;
  pres=od->pres;
  succ=od->succ;
      
  if (newsze<=rlen[x])
    return;

  if (od->raft+newsze>od->nn0)
    OdCheck(od,node_status);
    
  if (od->raft+newsze>od->nn0)
    ExitProc(OutOfSpc,"OdAdd");
    
  if (pres[x]!=n)
    rlen[pres[x]]+=rlen[x];
    
  iCopy(rexs[x],adjn+rbeg[x],adjn+od->raft);
  rbeg[x]=od->raft;
  rlen[x]=newsze;
  od->raft+=newsze;
  
  if (pres[x]==n) {
    if (succ[x]==n)
      od->head=x;
    else
      od->head=succ[x];
  }
  
  else {
    if (succ[x]==n)
      succ[pres[x]]=x;
    else
      succ[pres[x]]=succ[x];
  }
  
  if (succ[x]!=n)
    pres[succ[x]]=pres[x];
   
  if (od->last!=x) {
    succ[od->last]=x;
    pres[x]=od->last;
  }
  
  succ[x] =n;  
  od->last=x;
} /* OdAdd */
Пример #2
0
static void copyChl(chfac *af,
                    chfac *bf)
{
  iFree(&af->shead);
  iFree(&af->ssize);
  iFree(&af->ssub);
  
  iFree(&bf->shead);
  iFree(&bf->ssize);
  iFree(&bf->ssub);
  
  bf->unnz =af->unnz;
  bf->ujnz =af->ujnz;
  bf->nsnds=af->nsnds;
  bf->ndens=af->ndens;
  bf->nsndn=af->nsndn;
  bf->sdens=af->sdens;
  bf->upst =af->upst;
  
  bf->usub =iAlloc(bf->ujnz,"usub, copyChl");
  bf->uval =dAlloc(bf->unnz,"uval, copyChl");
  
  iCopy(af->ujnz,af->usub,bf->usub);
  iCopy(af->nrow,af->ujbeg,bf->ujbeg);
  iCopy(af->nrow,af->uhead,bf->uhead);
  iCopy(af->nrow,af->ujsze,bf->ujsze);
  iCopy(af->nrow,af->perm,bf->perm);
  iCopy(af->nrow,af->invp,bf->invp);
  iCopy(af->nrow+1,af->subg,bf->subg);
  
  bf->dhead=iAlloc(af->ndens+1,"dhead, copyChl");
  iCopy(af->ndens+1,af->dhead,bf->dhead);
  
  if (af->nsnds) {
    bf->dbeg=iAlloc(af->nsnds,"dbeg, copyChl");
    bf->dsub=iAlloc(af->nsnds,"dsub, copyChl");
    iCopy(af->nsnds,af->dbeg,bf->dbeg);
    iCopy(af->nsnds,af->dsub,bf->dsub);
  }
} /* copyChl */
Пример #3
0
static int OdSelect(order *od,
                    xlist *elist,
                    int   *node_status,
                    int   *marker,
                    int   *isize,
                    int   *ilink,
                    int   *oinfo,
                    int   *osize,
                    int   x,
                    int   *rsze,
                    int   *rchset,
                    int   *ibuf1,
                    int   *ibuf2,
                    int   *mask2,
                    int   *e,
                    int   *p)
{
  int absorp,old,i,j,n,esze,y,z,l,f,t,stopt,s,
      o,stops,indsze,xdeg,e0,ssze,*slist,tsze,
      *tlist,sze,*adjn,*rbeg,*rexs,*rlen,*rend;
  
  adjn =od->adjn;
  rbeg =od->rbeg;
  rexs =od->rexs;
  rlen =od->rlen;
  rend =od->rend;
  n    =od->nnod;
  slist=ibuf1;
  
  e0 = *e;
  OdArriv(od,node_status,marker,isize,x,&xdeg,rsze,&esze,rchset);
  
  XtDel(elist,x);
  
  OdRenew(od,ilink,x,xdeg,e,p);
  
  for(i=n-esze; i<n; ++i) {
    node_status[rchset[i]]=0;
    marker[rchset[i]]=TRUE;
  }
  
  marker[x]=TRUE;
  iSet(*rsze,TRUE,marker,rchset);
  
  ssze=0;
  for(i=0; i<*rsze;) {
    y=rchset[i];
    
    if (node_status[y]==0||node_status[y]==3)
      ExitProc(SysError,NULL);
    
    f=rbeg[y];
    for(t=f, stopt=f+rend[y]; t<stopt; ++t) {
      z=adjn[t];
      if (node_status[z]==3) {
        adjn[f++]=z;
        
        if (!mask2[z]) {
          slist[ssze++]=z;
          mask2[z]=TRUE;
        }
      }
    }
    rend[y]=f-rbeg[y];
    
    for(stopt=rbeg[y]+rexs[y]; t<stopt; ++t) {
      z=adjn[t];
      if (!marker[z])
        adjn[f++]=z;
    }
    
    rexs[y]=f-rbeg[y];
     
    if (rexs[y]==0) {
      OdRenew(od,ilink,y,xdeg-(*e-e0),e,p);
      node_status[y] = 0;
      marker[y]      = TRUE;
      
      (*rsze)--;
      iSwap(i,*rsze,rchset);
    }
    
    else {
      if (rexs[y]>=rlen[y]) 
        ExitProc(SysError,NULL);
      
      if (rexs[y]>rend[y])
        adjn[rbeg[y]+rexs[y]]=adjn[rbeg[y]+rend[y]];
        
      rexs[y]++;
       
      adjn[rbeg[y]+rend[y]]=x;
      rend[y]++;
      
      i++;
    }
  }
  
  iSet(ssze,FALSE,mask2,slist);
  
  if (*rsze==0) {
    node_status[x]=0;
    marker[x]=TRUE;
  }
  
  else {
    node_status[x]=3;
     
    rend[x]=0;
    rexs[x]=0;
    if (*rsze>rlen[x])
      OdAdd(od,node_status,x,*rsze);
     
    rexs[x]=*rsze;
    iCopy(*rsze,rchset,adjn+rbeg[x]);
    
    tsze=0;
    tlist=ibuf2;
    for(i=0; i<ssze; ++i){
      y=slist[i];
      old=marker[y];
      marker[y]=TRUE;
      
      absorp=TRUE;
        
      indsze=n;
      l=n;
      
      f=rbeg[y];
      for(t=f, stopt=f+rexs[y]; t<stopt; ++t) {
        z=adjn[t];
        if (node_status[z]!=0) {
          adjn[f++]=z;
          
          if (marker[z]) {
            l--;
            slist[l]=z;
            
            if (!mask2[z]) {
              for(s=rbeg[z],stops=rbeg[z]+rexs[z];
                  s<stops &&marker[adjn[s]]; ++s);
              
              if (s==stops) {
                indsze--;
                iSwap(l,indsze,slist);
              }
              
              mask2[z]=TRUE;
              tlist[tsze++]=z;
            }
          }
          else
            absorp=FALSE;
        }
      }
      
      marker[y]=old;
      rexs[y]=f-rbeg[y];
      
      if (indsze<n) {
        z=OdComb(od,node_status,marker,
                 isize,ilink,osize,
                 n-indsze,slist+indsze);
        
        node_status[z]=1;
        
        sze=0;
        for(j=l; j<indsze; ++j) {
          o=slist[j];
          sze+=1+isize[o];
          node_status[o]=2;
          oinfo[o]=z;
        }
        osize[z]=max(osize[z],sze);
      }
      
      if (absorp) {
        node_status[y]=0;
        marker[y]=TRUE;
      }
    }
    
    iSet(tsze,FALSE,mask2,tlist);
  }
  
  marker[x]=(node_status[x]==0);
  
  for(t=0; t<*rsze; ++t) {
    z=rchset[t];
    marker[z]=(node_status[z]==0);
  }
  
  return (FALSE);
} /* OdSelect */