[digraphanalysis-cvs] digraphanalysis/src/digraph_analyze main.c,
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-09-18 13:40:59
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src/digraph_analyze In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9369 Modified Files: main.c Log Message: finish up analyze_subgraphs Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/digraph_analyze/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.c 18 Sep 2005 03:08:32 -0000 1.2 --- main.c 18 Sep 2005 13:40:51 -0000 1.3 *************** *** 52,75 **** struct list *analyze_subgraphs(struct graph *graph_msd) { ! struct graph *graph; ! struct listlink *graph_link; ! struct node *node; ! struct listlink *node_link; ! struct list *subgraphs; if((subgraphs = list_new(graph_compare, graph_print)) == NULL) err(EX_UNAVAILABLE, "list_new(graph_compare, graph_print) == NULL"); ! LIST_FOREACH(node_link, graph_msd->node_list, list) { LIST_FOREACH(graph_link, subgraphs, list) ! if((node = graph_find_node(graph_link->object, node_link->object)) != NULL) break; if(node == NULL) { graph = graph_new(graph_msd->alias_list, list_new(node_compare_msd, node_print)); ! graph_add_node(graph, node_link->object); ! /* todo: Add strongly connected links */ list_add(subgraphs, graph); } } --- 52,97 ---- struct list *analyze_subgraphs(struct graph *graph_msd) { ! struct graph *graph = NULL; ! struct listlink *graph_link = NULL; ! struct node *node = NULL; ! struct listlink *node_link1 = NULL; ! struct listlink *node_link2 = NULL; ! struct listlink *node_link3 = NULL; ! unsigned int size_old = 0; ! unsigned int size_new = 0; ! struct list *subgraphs = NULL; if((subgraphs = list_new(graph_compare, graph_print)) == NULL) err(EX_UNAVAILABLE, "list_new(graph_compare, graph_print) == NULL"); ! LIST_FOREACH(node_link1, graph_msd->node_list, list) { LIST_FOREACH(graph_link, subgraphs, list) ! if((node = graph_find_node(graph_link->object, node_link1->object)) != NULL) break; if(node == NULL) { + /* Create a new graph and add the node to it. + */ graph = graph_new(graph_msd->alias_list, list_new(node_compare_msd, node_print)); ! graph_add_node(graph, node_link1->object); ! ! /* Add all strongly connected links to the graph. ! */ ! size_new = list_size(graph->node_list); ! while(size_old != size_new) ! { ! size_old = size_new; ! LIST_FOREACH(node_link2, graph->node_list, list) ! LIST_FOREACH(node_link3, node_link2->object->links, list) ! if(list_find(node_link3->object->links, nodelink2->object) != NULL) ! graph_add_node(graph, node_link3->object); ! size_new = list_size(graph->node_list); ! } ! ! /* Add the graph to subgraphs. ! */ list_add(subgraphs, graph); + graph = NULL; } } |