Example #1
0
void processroute (uint32 target, uint32 parent) {

	int pindex = SYSERR;
	int tindex = SYSERR;

	//check if the parent exists
	if (getindex (parent) == SYSERR) {
		kprintf (" DAO Message-> Parent does not exist in the map %04x \n", parent);
		return;
	}

	pindex = getindex (parent);

	if (getindex (target) == SYSERR) 
		tindex = assignindex (target);
	else 
		tindex = getindex (target);
	

	//check if the mapping already exists or it is a new mapping
	//ignore if the mapping already exists.
	if (rpladjlist[target][parent] || rpladjlist[parent][target]){
		kprintf (" DAO Message-> Mapping already exists (target - parent)%04x - %04x \n", target, parent);
		return;
	}

	rpladjlist[target][parent] = 1;
	rpladjlist[parent][target] = 1;

	//kickoff the Dijkstras shortest path calculation.
	shortestpath ();
	computepaths ();
	printpaths ();
}
void printpaths(Node *node, int paths[], pathLen){

	if(node == NULL)
		return;

	paths[pathLen] = node->data;
	pathLen++;

	if(node->left == NULL && node->right == NULL){
		printArray(paths, pathLen);
	}
	else{
		printpaths(node->left, paths, pathLen);
		printpaths(node->right, paths, pathLen);
	}

}
Example #3
0
int main()
{
    struct node *root = NULL;
    int path[100];
    root = insert(root, 3);
    root = insert(root, 1);
    root = insert(root, 2);
    root = insert(root, 5);
    root = insert(root, 4);
    display(root);
    if (lookup(root, 2))
    {
        printf("\nelement found in tree");
    }
    else
    {
        printf("\nelement not found");
    }
    printf("\nMin value: %d", min(root));
    root = delete_node(root, 3);
    display(root);
    printpaths(root, path, 0);
    return 0;
}
void btree_printpaths(BTree *btree){
	Node *iterator = btree->root;
	int paths[1000];
	printpaths(iterator, paths, 0);
}