Ejemplo n.º 1
0
void PlanRep::removeDeg1Nodes(Stack<Deg1RestoreInfo> &S, const NodeArray<bool> &mark)
{
	for(node v = firstNode(); v != nullptr; v = v->succ())
	{
		if(mark[v] || v->degree() == 0)
			continue;

		adjEntry adjRef;
		for(adjRef = v->firstAdj();
			adjRef != nullptr && mark[adjRef->twinNode()];
			adjRef = adjRef->succ()) ;

		if(adjRef == nullptr) {
			// only marked nodes adjacent with v (need no reference entry)
			for(adjEntry adj : v->adjEdges) {
				node x = adj->twinNode();
				S.push(Deg1RestoreInfo(m_eOrig[adj->theEdge()],m_vOrig[x],nullptr));
				delNode(x);
			}

		} else {
			adjEntry adj, adjNext, adjStart = adjRef;
			for(adj = adjRef->cyclicSucc(); adj != adjStart; adj = adjNext)
			{
				adjNext = adj->cyclicSucc();
				node x = adj->twinNode();
				if(mark[x]) {
					S.push(Deg1RestoreInfo(m_eOrig[adj->theEdge()],m_vOrig[x],adjRef));
					delNode(x);
				} else
					adjRef = adj;
			}
		}
	}
}
Ejemplo n.º 2
0
void delNode(Node* n)
{
  if (!n) return;
  delNode(n->child[2]);
  delNode(n->child[0]);
  delNode(n->child[1]);
  free(n);
}
Ejemplo n.º 3
0
void BTree::delSubTree(Node* subTree){	/*deletes a sub tree*/
	if ( subTree != NULL)
	{
		delNode(subTree->left);
		delNode(subTree->right);
		delNode(subTree);
	}
}
Ejemplo n.º 4
0
// embeds constraint graph such that all sources and sinks lie in a common
// face
void CompactionConstraintGraphBase::embed()
{
	NodeArray<bool> onExternal(*this,false);
	const CombinatorialEmbedding &E = *m_pOR;
	face fExternal = E.externalFace();

	for(adjEntry adj : fExternal->entries)
		onExternal[m_pathNode[adj->theNode()]] = true;

	// compute lists of sources and sinks
	SList<node> sources, sinks;

	for(node v : nodes) {
		if (onExternal[v]) {
			if (v->indeg() == 0)
				sources.pushBack(v);
			if (v->outdeg() == 0)
				sinks.pushBack(v);
		}
	}

	// determine super source and super sink
	node s,t;
	if (sources.size() > 1)
	{
		s = newNode();
		for (node v : sources)
			newEdge(s,v);
	}
	else
		s = sources.front();

	if (sinks.size() > 1)
	{
		t = newNode();
		for (node v : sinks)
			newEdge(v,t);
	}
	else
		t = sinks.front();

	edge st = newEdge(s,t);

	bool isPlanar = planarEmbed(*this);
	if (!isPlanar) OGDF_THROW(AlgorithmFailureException);


	delEdge(st);
	if (sources.size() > 1)
		delNode(s);
	if (sinks.size() > 1)
		delNode(t);
}
Ejemplo n.º 5
0
void delNode(TreeItem *node)
{
	if (node == NULL) return;

	if (node->left != NULL)
		delNode(node->left);

	if (node->right != NULL)
		delNode(node->right);

	free(node);
}
Ejemplo n.º 6
0
Archivo: graph.c Proyecto: rbertoche/t2
void GRA_DelNode (Graph *g)
{
	Node *n;
#ifdef _DEBUG
	int nOfNodesAntigo = g->nOfNodes;
	AssertGraph(g);
#endif /* _DEBUG */

    CNT_CONTAR("GRA_delNode - Inicializao");
	assert(g->currentNode);
	n = (Node *) LIS_ObterValor(g->currentNode);
	assert( n!=NULL );
#ifdef _DEBUG
	AssertNode(n,g);
#endif /* _DEBUG */

    CNT_CONTAR("GRA_delNode - Deletando no");
	delNode(g,n);
	LIS_ExcluirElemento(g->nodes);
	g->currentNode = LIS_ObterValor(g->nodes);
#ifdef _DEBUG
	g->nOfNodes--;
	assert ( g->nOfNodes == (nOfNodesAntigo - 1) );
	AssertGraph(g);
#endif /* _DEBUG */
}
Ejemplo n.º 7
0
int main() {
    list_t *root, *a, *b;
    int i;
    
    root=NULL;
    printList(root);
    for(i=0;i<10;i++) {
        a = new_node(i);
        add(&root, a);
        if(i==5)
            b=a;
    }
   
    printList(root);
    printNode(b);
    del(&root, b);
    printList(root);
    
    b=getNode(&root, 8);
    printNode(b);
    delNode(&root, 8);
    printList(root);
    
return 0;
}
Ejemplo n.º 8
0
circList<T>::~circList(){

	while (listSize != 0){
		delNode(0);
	}

}
Ejemplo n.º 9
0
void ParallelCoordinatesGraphProxy::deleteData(const unsigned int dataId) {
  if (getDataLocation() == NODE) {
    delNode(node(dataId));
  } else {
    delEdge(edge(dataId));
  }
}
Ejemplo n.º 10
0
void filterNBV(GLMmodel *obj, GLMnode **NBVStruct)
{
	for(unsigned int index = STARTFROM; index <= (*obj).numvertices; index++)
	{
		GLMnode *currCol;
		GLMnode *nextCol;
		GLMnode *preNode;


		nextCol = NBVStruct[index];

		while (nextCol->next != NULL)
		{
			currCol = nextCol;
			preNode = currCol;
			while (preNode->next != NULL)
			{
				currCol = preNode;
				currCol = currCol->next;

				if (nextCol->index == currCol->index)
					delNode(preNode, currCol->next);
				
				if(preNode->next != NULL)
					preNode = preNode->next;
			} //end while
			
			if(nextCol->next != NULL)
				nextCol = nextCol->next;
		} //end while
	} //end for
} //end filterNBV
Ejemplo n.º 11
0
void *reader(void *info) {
    int i = 0;
    clientNode *thisClient = (clientNode*) info;
    char recvLine[MAXLINE + 1];
    char **lines = NULL;
    ssize_t  n;

    printf("[Uma conexao aberta]\n");

    //Loop de leitura de mensagens
    while ((n=read(thisClient->socket, recvLine, MAXLINE)) > 0) {
        recvLine[n] = '\0';
        printf("[Cliente %d enviou:] ", thisClient->socket);
        if ((fputs(recvLine, stdout)) == EOF) {
            perror("fputs :( \n");
            exit(6);
        }

        lines = getLines(recvLine); //Quebra a mensagem em linhas
        for(i = 0; lines[i] != NULL; i++) {
            parseMessage(lines[i], thisClient);
        }

        free(lines);
    }

    delNode(thisClient);
    printf("[Uma conexao fechada]\n");

    return NULL;
}
Ejemplo n.º 12
0
void delNode(Node **node, const char *name)
{
  if (*node != NULL)
  {
    if (strcmp((*node)->name, name) == 0)
    {
      Node *temp_node = *node;
      *node = (*node)->next;
      freeNode(&temp_node);
      delEmptyNames(node);
      delNode(node, name);
    }
    else
    {
      delNode(&(*node)->next, name);
    }
  }
}
bool DListNode::insertNode(int ID_insert,bool f1,bool f2,int succ_id)//插入结点ID_insert,且f1=true说明此结点为hull的表层结点
{   //在f1=true的情况下,f2=true说明插入的结点为顺时针方向hull表层的下一结点。
    DListNode* newnode=new DListNode(ID_insert);                                   //succ_id为要插入的结点的后一结点标识,且保证这种succ_id存在,否则不做事
    DListNode* next=m_ptrNext;
    DListNode* pre=m_ptrPre;                                     //此双向链表从前到后组织按顺时针方向的结点
    DListNode* p;
    if(ID_insert == this->getData()){//如果插入节点为头节点,返回false
      cout << "Waring: inserting head node: " << this->getData() << endl; 
      return false;
    }
    else if(searchNode(ID_insert)){
//       cout << "Warning: Node " << ID_insert << " already exit in Point:" << this->getData() << endl;
       //方案一:如果节点存在则不插入。
//       return false;
      //方案二:先删除原节点再插入——效果较方案一好。
      delNode(ID_insert);
    }
    if(f1)
    {
        if(f2)//将结点插在this指向的结点的后面一个位子
        {
//             cout << "Into true true! newId = " << newnode->getData() << endl;
            newnode->m_ptrNext=m_ptrNext;
            m_ptrNext=newnode;
            newnode->m_ptrPre=this;
            next->m_ptrPre=newnode;
        }
        else//将结点插在this指向的结点的前面一个位子
        {
//             cout << "Into true false! newId = " << newnode->getData() << endl;
            newnode->m_ptrNext=this;
            newnode->m_ptrPre=pre;
            m_ptrPre=newnode;
            pre->m_ptrNext=newnode;
        }
    }
    else
    {
        p=this;//绝对不在this节点的前一或后一位置??
        do
        {
            if(p->getData()==succ_id)
            {
                newnode->m_ptrNext=p;
                newnode->m_ptrPre=p->getPre();
                p->getPre()->m_ptrNext=newnode;
                p->m_ptrPre=newnode;
                return true;
            }
            p=p->getNext();
        } while(p!=this);
	cout << "Warning: inserting " << ID_insert << " to " << this->getData() << " before " << succ_id << " failed!" << endl;
	return false;
    }
    return true;
}
Ejemplo n.º 14
0
Archivo: pb1.c Proyecto: iulianR/labs
int main()
{
	Graph g;
	readG(g);
	printG(g);
	delNode(g, 3);
	printf("Graful dupa stergerea nodului 3\n");
	printG(g);
	return 0;
}
Ejemplo n.º 15
0
void linearFree(void* mem)
{
	auto node = getNode(mem);
	if (!node) return;

	// Free the chunk
	sLinearPool.Deallocate(node->chunk);

	// Free the node
	delNode(node);
}
Ejemplo n.º 16
0
ListT* delList(ListT* l) {
    if (l) {
        NodeT* aux;
        while(l->head) {
            aux = l->head->next;
            l->head = delNode(l->head);
            l->head = aux;
        }
    }
    free(l);
    return NULL;
}
Ejemplo n.º 17
0
int main() { 
    LinkList l;
	l = init(5);
	printLink(l);
	insertEle(l, 6, 10);
	printLink(l);
	delNode(l, 2);
	printLink(l);
	updateNode(l, 5, 22);
	printLink(l);
	return 0;
}
Ejemplo n.º 18
0
void deleteLevel(nodeTree *root, int level, int rLevel)
{
	if (root == NULL) return;
	if (level == rLevel)
	{
		delNode(root->key);
	}
	else
	{
		deleteLevel(root->pLeft, level + 1, rLevel);
		deleteLevel(root->pRight, level + 1, rLevel);
	}
}
Ejemplo n.º 19
0
/* remove duplicated exp nodes */
void removeDup( Poly l ){
        Position  n, p;
        p = first( l ) ;
        while ( NULL != p ){
                n = p->next;
                if ( NULL != n && p->exp == n->exp )
                {
                        p->coeff += n->coeff;
                        delNode( p->exp, l);
                }
                p = n;
        }
}
Ejemplo n.º 20
0
int delTree(Tree *tree)
{
	if (tree == NULL) return TREE_NULL;

	if (tree->root != NULL) {
		delNode(tree->root);
	}

	tree->root = NULL;
	tree->compare = NULL;

	return 0;
}
Ejemplo n.º 21
0
void delEventTable(EventTable *et, const char *name, void (*callback)(void *)) {
    Node  *head = (Node *)g_hash_table_lookup(et, name);
    Event *event;
    Node  *curr;
    Node  *p;
    forEachNodes(head, curr, p) {
        event = containerOf(curr, Event, node);
        if (event->callback == callback) {
            delNode(curr);
            xfree(event);
            break;
        }
    }
Ejemplo n.º 22
0
Archivo: list.c Proyecto: HAVRM/work
int main(void){
  List *p=NULL;
  p=addHead(p,"def");
  p=addHead(p,"abc");
  p=addTail(p,"xyz");
  p=sortedaddNode(p,"opq");
  p=sortedaddNode(p,"lmn");
  p=sortedaddNode(p,"uvm");
  disp(p);
  printf("\n");
  p=delNode(p,"opq");
  dispReverse(p);
  return 0;
}
Ejemplo n.º 23
0
int main()
{
    struct NODE *header;
    header = NULL;
    int i;

    for(i=0; i<MAX_NODE; i++)
        addNode(&header,((rand()%25)+(rand()%25)));
    displayList(header);

    delNode(&header,19);
    displayList(header);

    delNode(&header,0);
    displayList(header);

    delNode(&header,28);
    displayList(header);

    delNode(&header,16);
    displayList(header);

    return(1);
}
int main(){
	node* head = NULL;
 
    push(&head, 7);
    push(&head, 1);
    push(&head, 3);
    push(&head, 2);
 
    puts("Created Linked List: ");
    printList(head);
    delNode(&head, 1);
    puts("\nLinked List after Deletion of 1: ");
    printList(head);
    return 0;
}
Ejemplo n.º 25
0
Archivo: ds.c Proyecto: dubenju/javay
int main(void) {
	puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */

	LinkList l;
	l = init(5);
	printLink(l);
	insertEle(l, 6, 10);
	printLink(l);
	delNode(l, 2);
	printLink(l);
	updateNode(l, 6, 22);
	printLink(l);
	printf("this is a test for list by c./n");

	return EXIT_SUCCESS;
}
Ejemplo n.º 26
0
//Driver function
int main(void){
	int ch;
	/*
	start = (struct node *)malloc(sizeof(struct node)); //initializing the linked list
	if(start == NULL){
		printf("Memory full");
		exit(1);
	}
	printf("Enter data:\t");
	scanf("%d",&data);
	start->data = data;
	start->ptr = NULL;
	*/
	while(1){
		menu();
		printf("\nEnter choice:\t");
		scanf("%d",&ch);

		switch(ch){
			case 1:
				addNode();
				break;
			case 2:
				delNode();
				break;
			case 3:
				search();
				break;
			case 4:
				display(0);
				break;
			default:
				ch = 0;
				break;
		}
		if(ch == 0)
			break;
	}

	printf("\nThanks for using...");
	clear();
	getchar();
	system("clear");
	return 0;
}
Ejemplo n.º 27
0
void monsterAttack2(int code)
{
	int levelO = code % 10;
	int keyO = code / 10 % 1000;
	nodeTree *attackShip = myTree->root;
	int cnt = 3;
	while (cnt)
	{
		findNearestKey(myTree->root, attackShip, 1000, keyO);

		int absKey = keyO - attackShip->key;
		if (absKey < 0) absKey *= -1;

		if (attackShip->level <= levelO)
		{
			keyO += 3*absKey;
			while (keyO > 999) keyO -= 1000;

			delNode(attackShip->key);
		}
		else
		{
			int delta = 1000 / (((attackShip->level - levelO) + 1) * (attackShip->level + 1));
			if (attackShip->level == 7)
			{
				attackShip->exp = (100 < (attackShip->exp + delta))? 100 : (attackShip->exp + delta);
			}
			else
			{
				attackShip->exp += delta;
				while (attackShip->exp >= 100)
				{
					attackShip->level += 1;
					attackShip->exp -= 100;
				}

			}
			cnt--;
			keyO -= 3*absKey;
			while (keyO < 0) keyO += 1000;
			//cout << attackShip->exp << "\n";
		}
		if (myTree->root == NULL) return;
	}
}
Ejemplo n.º 28
0
/*
test add node and delete node
*/
void main()
{
  linklist *str =malloc(sizeof(linklist)*10) ;

   int i =0;
   while(i<10)
   {
    str[i].num=i;
    if(i<9)
    str[i].next=&str[i+1];
    i++;
   } 
   
   str[i-1].next=NULL;
   readList(str);
   addNode(str,2,9999);
   readList(str);
   delNode(str,2); 
   readList(str);
   free(str);
}//end main 
Ejemplo n.º 29
0
void driverGuy(int code)
{
	int x = code%10;

	if (isJack)
	{
		isHalt = 1;
		return;
	}

	queue *front = new queue;
	queue *rear = front;
	rear->next = NULL;

	if (getCount(myTree->root) > (3 * x))
	{
		listLNR(myTree->root->pRight, rear);
	}
	else
	{
		isRiverCrossed = 1;
		isSoulLand = 0;
		listLNRleaf(myTree->root->pLeft, rear);
	}

	while (front->next != NULL)
	{
		queue *del = front;
		if (front->next->key == 888)
		{
			isBlackBeard = 0;
			isAVL = 0;
		}
		delNode(front->next->key);
		front = front->next;
		delete del;
	}
	delete front;
}
Ejemplo n.º 30
0
void monsterAttack(int code)
{
	int levelO = code % 10;
	int keyO = code / 10 % 1000;
	nodeTree *root = myTree->root;
	nodeTree *attackShip = myTree->root;

	while (root != NULL)
	{
		if (root->key < keyO)
		{
			attackShip = root;
			root = root->pRight;
		}
		else root = root->pLeft;
	}

	if (attackShip->level <= levelO) delNode(attackShip->key);
	else
	{
		int delta = 1000 / (((attackShip->level - levelO) + 1) * (attackShip->level + 1));
		if (attackShip->level == 7)
		{
			attackShip->exp = (100 < (attackShip->exp + delta))? 100 : (attackShip->exp + delta);
		}
		else
		{
			attackShip->exp += delta;
			while (attackShip->exp >= 100)
			{
				attackShip->level += 1;
				attackShip->exp -= 100;
			}
		}
		//cout << attackShip->exp << "\n";
	}

}