Example #1
0
linkedList* variableOrdering(graph *g,int choice){
     
     item *currItem;
     linkedList *orderedList;
     vertex *v;
     int i;
     
     breakCycles(g);
                   
     resetWeights(g); 
     computeWeights(g);
     genericSuccessorsOrdering(g, choice);
     orderByWeights(g->vertices);
     resetVisited(g); 
     orderedList= newLinkedList();
     
     currItem = (g-> vertices)->head;
     while (currItem!= NULL) {
           if ((currItem->vert)->visited == 0) visit(currItem->vert,orderedList);
           currItem = currItem->next;
     }
     
     return orderedList;
     
}
Example #2
0
void resetVisited(trieNodePointer root)
{
	for (int i=0; i < 36; i++)
	{
		if (root->children[i] != NULL)
		{
			resetVisited(root->children[i]);
			root->children[i]->visited = false;
		}
	}
}
Example #3
0
void printTree(trieNodePointer root, char *output)
{
	FILE *outputFile = fopen(output, "w");
	totalNodes = 0;
	nodeCount = 0;
	total(ROOT);
	fprintf(outputFile, "{\"list\" : [\n");
	resetVisited(root);
	printTreeRecursive(root, outputFile);
	fprintf(outputFile, "]}\n");
	fclose(outputFile);
}
Example #4
0
void computeWeights(graph* g){

     item *curr;
     curr = (g->vertices)->head;
     
     while (curr != NULL) {
          resetVisited(g);
          (curr->vert)->weight=weight(curr->vert); 
          curr = curr->next;      
     }
     
}
Example #5
0
void breakCycles(graph* g){
	item* curr;

	resetVisited(g);
	curr = (g->vertices)->head;
	

	while(curr!=NULL) {
		if( (curr->vert)->visited == 0) bCycles(curr->vert);
		curr=curr->next;
	}

}