Thread: [digraphanalysis-cvs] digraphanalysis/src node.c,
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-04-22 14:58:42
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22490/src Modified Files: node.c Log Message: function implementation Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** node.c 22 Apr 2005 01:55:21 -0000 1.5 --- node.c 22 Apr 2005 14:58:32 -0000 1.6 *************** *** 25,28 **** --- 25,31 ---- node_free(struct node *node) { + free(node->uid); + nodelist_free(node->links); + free(node); } *************** *** 30,33 **** --- 33,50 ---- node_new(char *uid) { + struct node *node; + size_t len; + + node = (struct node *) malloc(sizeof(struct node *)); + + len = strlen(uid) + 1; + node->uid = (char *) malloc(len); + strlcpy(node->uid, uid, len); + + node->msd = 0; + + node->links = nodelist_new(); + + return node; } *************** *** 35,38 **** --- 52,83 ---- nodelist_add(struct nodelist *node_list, struct node *node) { + int i; + struct nodelink *node_iter, *node_link; + + node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); + node_link->node = node; + + if(LIST_EMPTY(node_list)) + LIST_INSERT_HEAD(node_list, node_link, list); + else + LIST_FOREACH(node_iter, node_list, list) + { + if((i = node_compare(node, node_iter->node)) < 0) + { + if(node_iter == LIST_FIRST(node_list)) + LIST_INSERT_HEAD(node_list, node_link, list); + else + LIST_INSERT_BEFORE(node_iter, node_link, list); + break; + } + else + if(i == 0) + return node_iter->node; + else + if(LIST_NEXT(node_iter, list) == NULL) + LIST_INSERT_AFTER(node_iter, node_link, list); + } + + return node; } *************** *** 40,43 **** --- 85,116 ---- nodelist_add_msd(struct nodelist *node_list, struct node *node) { + int i; + struct nodelink *node_iter, *node_link; + + node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); + node_link->node = node; + + if(LIST_EMPTY(node_list)) + LIST_INSERT_HEAD(node_list, node_link, list); + else + LIST_FOREACH(node_iter, node_list, list) + { + if((i = node_compare_msd(node, node_iter->node)) < 0) + { + if(node_iter == LIST_FIRST(node_list)) + LIST_INSERT_HEAD(node_list, node_link, list); + else + LIST_INSERT_BEFORE(node_iter, node_link, list); + break; + } + else + if(i == 0) + return node_iter->node; + else + if(LIST_NEXT(node_iter, list) == NULL) + LIST_INSERT_AFTER(node_iter, node_link, list); + } + + return node; } *************** *** 45,53 **** nodelist_compare(struct nodelist *node_list1, struct nodelist *node_list2) { } struct nodelist * ! nodelist_duplicate(struct nodelist *node_list) { } --- 118,138 ---- nodelist_compare(struct nodelist *node_list1, struct nodelist *node_list2) { + return nodelist_size(node_list2) - nodelist_size(node_list1); } + /* How should we go about duplicating a msd organized list. + */ struct nodelist * ! nodelist_duplicate(struct nodelist *node_list1) { + struct nodelist *node_list2; + struct nodelink *node_link; + + node_list2 = nodelist_new(); + + LIST_FOREACH(node_link, node_list1, list) + nodelist_add(node_list2, node_link->node); + + return node_list2; } *************** *** 55,58 **** --- 140,154 ---- nodelist_find(struct nodelist *node_list, struct node *node) { + int i; + struct nodelink *node_link; + + LIST_FOREACH(node_link, node_list, list) + if((i = node_compare(node_link->node, node)) == 0) + return node_link->node; + else + if(i > 0) + break; + + return NULL; } *************** *** 60,63 **** --- 156,172 ---- nodelist_free(struct nodelist *node_list) { + struct nodelink *node_link, *tmp_link; + + tmp_link = NULL; + + LIST_FOREACH(node_link, node_list, list) + { + free(tmp_link); + tmp_link = node_link; + LIST_REMOVE(node_link, list); + } + + free(node_link); + free(node_list); } |
|
From: Jeff B. <jb...@us...> - 2005-04-24 03:50:30
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22716 Modified Files: node.c Log Message: function implementations. Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** node.c 22 Apr 2005 14:58:32 -0000 1.6 --- node.c 24 Apr 2005 03:50:22 -0000 1.7 *************** *** 174,177 **** --- 174,186 ---- nodelist_intersection(struct nodelist *node_list1, struct nodelist *node_list2) { + struct nodelink *node_iter; + struct nodelist *node_list; + + node_list = nodelist_new(); + LIST_FOREACH(node_iter, node_list1, list) + if(nodelist_find(node_list2, node_iter->node) != NULL) + nodelist_add(node_list, node_iter->node); + + return node_list; } *************** *** 179,182 **** --- 188,197 ---- nodelist_merge(struct nodelist *node_list1, struct nodelist *node_list2) { + struct nodelink *node_iter; + + LIST_FOREACH(node_iter, node_list2, list) + nodelist_add(node_list1, node_iter->node); + + return node_list1; } *************** *** 205,208 **** --- 220,232 ---- nodelist_size(struct nodelist *node_list) { + struct nodelink *node_iter; + unsigned int size; + + size = 0; + + LIST_FOREACH(node_iter, node_list, list) + ++size; + + return size; } |
|
From: Jeff B. <jb...@us...> - 2005-04-25 04:40:12
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4474 Modified Files: node.c Log Message: function implementation Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** node.c 24 Apr 2005 03:50:22 -0000 1.7 --- node.c 25 Apr 2005 04:40:03 -0000 1.8 *************** *** 210,213 **** --- 210,219 ---- nodelist_print(FILE *filep, struct nodelist *node_list) { + struct nodelink *node_link; + + LIST_FOREACH(node_link, node_list, list) + node_print(filep, node_link->node); + + return; } *************** *** 215,218 **** --- 221,242 ---- nodelist_remove(struct nodelist *node_list, struct node *node) { + int i; + struct nodelink *node_link; + + LIST_FOREACH(node_link, node_list, list) + { + tmp_node = node_link->node; + if((i = node_compare(tmp_node, node)) == 0) + { + LIST_REMOVE(node_link, list); + free(node_link); + return tmp_node; + } + else + if(i > 0) + break; + } + + return NULL; } |
|
From: Jeff B. <jb...@us...> - 2005-04-25 15:07:25
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13771 Modified Files: node.c Log Message: finish implementing functions Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** node.c 25 Apr 2005 04:53:14 -0000 1.9 --- node.c 25 Apr 2005 15:07:16 -0000 1.10 *************** *** 267,271 **** nodelist_subtract(struct nodelist *node_list1, struct nodelist *node_list2) { ! return NULL; } --- 267,279 ---- nodelist_subtract(struct nodelist *node_list1, struct nodelist *node_list2) { ! struct nodelink *node_link; ! struct nodelist *node_list; ! ! node_list = nodelist_duplicate(node_list1); ! ! LIST_FOREACH(node_link, node_list2, list) ! nodelist_remove(node_list, node_link->node); ! ! return node_list; } *************** *** 273,277 **** nodelist_union(struct nodelist *node_list1, struct nodelist *node_list2) { ! return NULL; } --- 281,290 ---- nodelist_union(struct nodelist *node_list1, struct nodelist *node_list2) { ! struct nodelist *node_list; ! ! node_list = nodelist_duplicate(node_list1); ! nodelist_merge(node_list, node_list2); ! ! return node_list; } |