void deleteSimpleLoop()
{
    unsigned int index;
    int loop1=0,loop2=0;
    for(index=1; index<=num_ed; index++)
    {
        ARC * arc1 = getArcBetween(index,index);
        if(arc1)
        {
            arc1->multiplicity=0;
            arc1->bal_arc->multiplicity=0;
            loop1++;
        }
        ARC * arc = edge_array[index].arcs;

        while(arc)
        {
            unsigned int to_ed = arc->to_ed;
            ARC * arc2 = getArcBetween(to_ed,index);
            if(arc2)
            {
                arc2->multiplicity=0;
                arc2->bal_arc->multiplicity=0;
                arc->multiplicity=0;
                arc->bal_arc->multiplicity=0;
                loop2++;
            }
            arc=arc->next;
        }
    }
    printf("%d loops removed in Graph\n",loop1+loop2);
    removeArc();
}
Exemplo n.º 2
0
void Magnusson::removeSwapArcs()
{
    for(Arc* a : swapArcs_)
    {
        removeArc(a);
        delete a;
    }
    swapArcs_.clear();
}
Exemplo n.º 3
0
void Magnusson::removeSwapArc(Arc* arc)
{
    assert(arc->getType() == Arc::Swap);

    removeArc(arc);
    std::vector<Arc*>::iterator it = std::find(swapArcs_.begin(), swapArcs_.end(), arc);
    if(it != swapArcs_.end())
        swapArcs_.erase(it);
    else
        throw std::runtime_error("Did not find arc to remove!");
}
void deleteUnlikeArc()
{
    unsigned int index;
    ARC * arc ,*arc_temp;
    unsigned short source_multi,target_multi,max_multi;
    for(index=1; index<=num_ed; index++)
    {
        arc=edge_array[index].arcs;
        source_multi=edge_array[index].cvg;
        while(arc)
        {
            target_multi=edge_array[arc->to_ed].cvg;
            max_multi=source_multi>target_multi?source_multi:target_multi;
//			printf("test:\t%4.1f",arc->multiplicity/max_multi);
            if(arc->multiplicity <  (double)max_multi/25 ||arc->multiplicity<3 )
            {
                arc->multiplicity=0;
            }
            arc=arc->next;
        }
    }
    /*
    for(index=1;index<=num_ed;index++)
    {
    	arc=edge_array[index].arcs;
    	while(arc)
    	{
    		arc_temp=arc;
    		arc=arc->next;

    		if(arc_temp->multiplicity == 0)
    		{
    			if(arc_temp->prev)
    			{
    				arc_temp->prev->next=arc_temp->next;
    			}
    			else
    			{
    				edge_array[index].arcs=arc_temp->next;
    			}
    			if(arc_temp->next)
    			{
    				arc_temp->next->prev = arc_temp->prev;
    			}
    			dismissArc (arc_temp);
    			total_changed++;
    		}
    	}
    }*/
    int total_changed = removeArc();
    printf("delete unlike arc :%d\n",total_changed);
}
Exemplo n.º 5
0
RegionDesc::BlockVec::iterator
RegionDesc::deleteBlock(RegionDesc::BlockVec::iterator it) {
  const auto bid = (*it)->id();
  for (auto pid : preds(bid)) removeArc(pid, bid);
  for (auto sid : succs(bid)) removeArc(bid, sid);

  if (auto nextR = nextRetrans(bid)) {
    auto prevR = prevRetrans(bid);
    clearPrevRetrans(nextR.value());
    if (prevR) {
      clearNextRetrans(prevR.value());
      setNextRetrans(prevR.value(), nextR.value());
    } else {
      clearPrevRetrans(nextR.value());
    }
  } else if (auto prevR = prevRetrans(bid)) {
    clearNextRetrans(prevR.value());
  }

  m_data.erase(bid);
  return m_blocks.erase(it);
}
void deleteShortContig(int cutLength)
{
    unsigned int index;
    if(pool== NULL)
        pool= (int*)ckalloc (sizeof(int)*(num_ed+1));
    int * poolid_length=(int*)ckalloc(sizeof(int)*(num_ed+1));
    for(index=0; index<=num_ed; index++)
    {
        pool[index]=0;
        poolid_length[index]=0;
    }
    int poolid_index=1;

    COV_LIST * cov = (COV_LIST * ) ckalloc (sizeof(COV_LIST)*(num_ed+1));
    for(index=1; index<=num_ed; index++)
    {
        cov[index].contig=index;
        cov[index].cov=edge_array[index].cvg;
    }
    qsort(&cov[1], num_ed, sizeof(COV_LIST), cmp_cov);
    for(index=1; index<=num_ed; index++)
    {
        poolid_length[poolid_index]=extern_contig(cov[index].contig,poolid_index);
        if(poolid_length[poolid_index]!=0)
            poolid_index++;
    }

    int num_delelte=0;
    for(index=1; index<=num_ed; index++)
    {
        if(poolid_length[pool[index]]<cutLength)
        {
            delete1contig(index);
            num_delelte++;
        }
        if(!EdSameAsTwin(index))
            index++;
    }

    free(poolid_length);
    free(pool);
    free(cov);
    printf("%d short contig(<%d) removed \n",num_delelte,cutLength);

    removeArc();
}
void deleteWeakEdge(unsigned short cutoff)
{
    if(cutoff > 30)
        cutoff=30;
    printf("Start to remove the low coverage edge < %d\n",cutoff/10);
    unsigned int index;
    int total=0;
    for(index=1; index<=num_ed; index++)
    {
        if(edge_array[index].cvg < cutoff)
        {
            delete1contig(index);
            total++;
        }
        if(!EdSameAsTwin(index))
            index++;
    }
    printf("%d edges removed\n\n",total);
    removeArc();
}
int deleteLightArc()
{
    printf("Start to remove light arc using the rate %f and %f\n",(double)da/100,(double)dA/100);
    unsigned int changed = deleteLightOutArc((double)da/100);
    unsigned int flow_changed = deleteLightFlowArc((double)dA/100);
    /*
    	unsigned int index,total_changed=0;
    	ARC * arc ,*arc_temp;
    	for(index=1;index<=num_ed;index++)
    	{
    		arc=edge_array[index].arcs;
    		while(arc)
    		{
    			arc_temp=arc;
    			arc=arc->next;

    			if(arc_temp->multiplicity == 0)
    			{
    				if(arc_temp->prev)
    				{
    					arc_temp->prev->next=arc_temp->next;
    				}
    				else
    				{
    					edge_array[index].arcs=arc_temp->next;
    				}
    				if(arc_temp->next)
    				{
    					arc_temp->next->prev = arc_temp->prev;
    				}
    				dismissArc (arc_temp);
    				total_changed++;
    			}
    		}
    	}*/
    int total_changed = removeArc();
    printf("delete light arc :%d/%d\n",total_changed/2,changed+flow_changed);
    return (changed+flow_changed)>0 ? 1 : 0;
}
Exemplo n.º 9
0
void NavMesh::removeArc(Arc* arc)
{
    removeArc( arc->from, arc->to );
}
int deleteLightContig()
{
    double prev_cov,next_cov,max,min,curr_cov;
    unsigned int index;
    int change=0;
    ARC * arc,*arc_temp;

    for(index=1; index<=num_ed; index++)
    {
        if(EdSameAsTwin(index))
            continue;
        computeNextCov(index,&next_cov);
        computeNextCov(getTwinEdge(index),&prev_cov);
        if(next_cov ==0 || prev_cov ==0)
            continue;
        if(next_cov > prev_cov)
        {
            max=next_cov;
            min=prev_cov;
        }
        else
        {
            max=prev_cov;
            min=next_cov;
        }
        curr_cov = (double)edge_array[index].cvg;
        printf("contig_cov:\t%0.1f\t%0.1f\t%0.1f\n",curr_cov,max,min);


        if(min / max <0.1)
        {
            if(curr_cov /min < 0.5)
            {
                delete1contig(index);
            }
        }
        else
        {
            if(curr_cov / max <0.05)
            {
                delete1contig(index);
            }
        }
        index++;
    }
    /*
    for(index=1;index<=num_ed;index++)
    {
    	arc=edge_array[index].arcs;
    	while(arc)
    	{
    		arc_temp=arc;
    		arc=arc->next;

    		if(arc_temp->multiplicity == 0)
    		{
    			if(arc_temp->prev)
    			{
    				arc_temp->prev->next=arc_temp->next;
    			}
    			else
    			{
    				edge_array[index].arcs=arc_temp->next;
    			}
    			if(arc_temp->next)
    			{
    				arc_temp->next->prev = arc_temp->prev;
    			}
    			dismissArc (arc_temp);
    			change++;
    		}
    	}
    }*/
    change = removeArc();
    return change>0?1:0;;
}