Thread: [digraphanalysis-cvs] digraphanalysis/src analysis.c, analysis.h, BSDmakefile, main.c,
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-05-17 00:13:07
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30785 Modified Files: BSDmakefile main.c Added Files: analysis.c analysis.h Log Message: +analysis Index: BSDmakefile =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/BSDmakefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BSDmakefile 17 May 2005 00:08:06 -0000 1.3 --- BSDmakefile 17 May 2005 00:12:45 -0000 1.4 *************** *** 17,20 **** --- 17,21 ---- PROG= digraphanalysis SRCS= alias.c \ + analysis.c \ graph.c \ input.c \ Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** main.c 17 May 2005 00:08:06 -0000 1.12 --- main.c 17 May 2005 00:12:45 -0000 1.13 *************** *** 33,138 **** #include "node.h" - /* Analyze the keys and output the results. - * - * Return -1 on error - */ int ! do_analysis(struct graph *graph, char *outputdir) ! { ! struct graphlist *graph_list; ! ! graph_list = NULL; ! if(output_main_directory(outputdir) == (-1)) ! return (-1); ! analysis_nodes(graph); ! graph_list = analysis_seperate_nodes(graph); ! output_report(graph_list); ! return 0; ! } ! ! void ! analysis_nodes(struct graph *graph) ! { ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, graph->node_list, list) ! output_file(node_link->node, graph); ! ! return; ! } ! ! struct graphlist * ! analysis_seperate_nodes(struct graph *graph) ! { ! struct aliaslist *alias_list; ! struct graphlist *graph_list; ! struct nodelink *node_link1; ! struct nodelink *node_link2; ! struct nodelist *node_list; ! struct nodelist *node_list_msd1; ! struct nodelist *node_list_msd2; ! ! /* Duplicate the graphs alias and node lists so as to not modify the original copies. ! */ ! alias_list = aliaslist_duplicate(graph->alias_list); ! node_list = nodelist_duplicate(graph->node_list); ! ! /* Create the list, to add the msd sorted graphs to. ! */ ! graph_list = graphlist_new(); ! ! /* Iterate through our copy of the original graph's node list. ! */ ! while(!LIST_EMPTY(node_list)) ! { ! /* Create two new node lists. ! */ ! if(((node_list_msd1 = nodelist_new()) == NULL) || ! ((node_list_msd2 = nodelist_new()) == NULL)) ! return NULL; ! ! /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. ! */ ! nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); ! nodelist_remove(node_list, LIST_FIRST(node_list)->node); ! ! /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. ! */ ! while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) ! { ! /* Duplicate nodelist1 onto nodelist2. ! */ ! nodelist_free(node_list_msd2); ! if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) ! return NULL; ! /* Iterate through nodelist2 adding nodes to nodelist1. ! */ ! LIST_FOREACH(node_link1, node_list_msd2, list) ! LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) ! if(node_distance(node_link2->node, node_link1->node)) ! { ! nodelist_add_msd(node_list_msd1, node_link2->node); ! nodelist_remove(node_list, node_link2->node); ! } ! } ! ! /* Add strongly connected nodelist to the graphlist. ! */ ! graphlist_add(graph_list, graph_new(alias_list, node_list_msd1)); ! ! /* Free the 2nd nodelist so as to not leak memory. ! */ ! nodelist_free(node_list_msd2); ! } ! /* Free the copy of the node_list. ! */ ! nodelist_free(node_list); ! ! return graph_list; ! } ! ! /* DONE ! */ ! int main(int argc, char **argv) { int c; --- 33,38 ---- #include "node.h" int ! main(int argc, char **argv) { int c; *************** *** 163,167 **** } ! void usage(void) { extern char *__progname; --- 63,68 ---- } ! void ! usage(void) { extern char *__progname; --- NEW FILE: analysis.c --- /* $Id: analysis.c,v 1.1 2005/05/17 00:12:45 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "analysis.h" /* Analyze the keys and output the results. * * Return -1 on error */ int do_analysis(struct graph *graph, char *outputdir) { struct graphlist *graph_list; graph_list = NULL; if(output_main_directory(outputdir) == (-1)) return (-1); analysis_nodes(graph); graph_list = analysis_seperate_nodes(graph); output_report(graph_list); return 0; } void analysis_nodes(struct graph *graph) { struct nodelink *node_link; LIST_FOREACH(node_link, graph->node_list, list) output_file(node_link->node, graph); return; } struct graphlist * analysis_seperate_nodes(struct graph *graph) { struct aliaslist *alias_list; struct graphlist *graph_list; struct nodelink *node_link1; struct nodelink *node_link2; struct nodelist *node_list; struct nodelist *node_list_msd1; struct nodelist *node_list_msd2; /* Duplicate the graphs alias and node lists so as to not modify the original copies. */ alias_list = aliaslist_duplicate(graph->alias_list); node_list = nodelist_duplicate(graph->node_list); /* Create the list, to add the msd sorted graphs to. */ graph_list = graphlist_new(); /* Iterate through our copy of the original graph's node list. */ while(!LIST_EMPTY(node_list)) { /* Create two new node lists. */ if(((node_list_msd1 = nodelist_new()) == NULL) || ((node_list_msd2 = nodelist_new()) == NULL)) return NULL; /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. */ nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); nodelist_remove(node_list, LIST_FIRST(node_list)->node); /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. */ while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) { /* Duplicate nodelist1 onto nodelist2. */ nodelist_free(node_list_msd2); if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) return NULL; /* Iterate through nodelist2 adding nodes to nodelist1. */ LIST_FOREACH(node_link1, node_list_msd2, list) LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) if(node_distance(node_link2->node, node_link1->node)) { nodelist_add_msd(node_list_msd1, node_link2->node); nodelist_remove(node_list, node_link2->node); } } /* Add strongly connected nodelist to the graphlist. */ graphlist_add(graph_list, graph_new(alias_list, node_list_msd1)); /* Free the 2nd nodelist so as to not leak memory. */ nodelist_free(node_list_msd2); } /* Free the copy of the node_list. */ nodelist_free(node_list); return graph_list; } --- NEW FILE: analysis.h --- /* $Id: analysis.h,v 1.1 2005/05/17 00:12:45 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _ANALYSIS_H_ #define _ANALYSIS_H_ #include "graph.h" void analysis_nodes(struct graph *); struct graphlist *analysis_seperate_nodes(struct graph *); int do_analysis(struct graph *, char *); #endif |