X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/95d328f9ca4dd6ccd2065c6c84aca83d43001804..dff9e15c44ab6340d27215957c56fa72fad246a2:/testsuite/xbt/graphxml_usage.c diff --git a/testsuite/xbt/graphxml_usage.c b/testsuite/xbt/graphxml_usage.c index f0e63f92cc..3df95126fa 100644 --- a/testsuite/xbt/graphxml_usage.c +++ b/testsuite/xbt/graphxml_usage.c @@ -7,9 +7,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #ifdef __BORLANDC__ - #pragma hdrstop - #endif - +#pragma hdrstop +#endif + #include #ifdef _MSC_VER @@ -26,11 +26,12 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to graphxml test"); static void *node_label_and_data(xbt_node_t node, const char *label, - const char *data) + const char *data) { char *lbl = xbt_strdup(label); return lbl; } + #define free_label free static const char *node_name(xbt_node_t n) @@ -55,15 +56,13 @@ void test(char *graph_file) xbt_dynar_t edges = NULL; xbt_dynar_t nodes = NULL; - xbt_graph_t graph = - xbt_graph_read(graph_file, &node_label_and_data, NULL); + xbt_graph_t graph = xbt_graph_read(graph_file, &node_label_and_data, NULL); n = xbt_dynar_length(xbt_graph_get_nodes(graph)); if (test_export_xml) { INFO0("---- Testing XML export. Exporting to testgraph.xml ----"); - xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL, - NULL); + xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL, NULL); } if (test_export_dot) { INFO0("---- Testing GraphViz export. Exporting to testgraph.dot ----"); @@ -76,10 +75,10 @@ void test(char *graph_file) INFO0("---- Dumping Edge lengths ----"); adj = xbt_graph_get_length_matrix(graph); - buf = xbt_new0(char,n * 20); + buf = xbt_new0(char, n * 20); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - sprintf(buf + strlen(buf), "%le\t", adj[i * n + j]); + sprintf(buf + strlen(buf), "%le\t", adj[i * n + j]); } INFO1("%s", buf); buf[0] = '\000'; @@ -91,15 +90,15 @@ void test(char *graph_file) if (test_shortest_paths) { char *buf = NULL; xbt_node_t *route = NULL; - + INFO0("---- Testing Shortest Paths ----"); route = xbt_graph_shortest_paths(graph); - buf = xbt_new0(char,n * 40); + buf = xbt_new0(char, n * 40); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - if (route[i * n + j]) - snprintf(buf+strlen(buf), 40, "%s\t", - node_name(route[i * n + j])); + if (route[i * n + j]) + snprintf(buf + strlen(buf), 40, "%s\t", + node_name(route[i * n + j])); } INFO1("%s", buf); buf[0] = '\000'; @@ -115,7 +114,7 @@ void test(char *graph_file) sorted = xbt_graph_topo_sort(graph); for (i = 0; i < n; i++) { if (sorted[i]) { - INFO3("sorted[%lu] = %s (%p)", i, node_name(sorted[i]), sorted[i]); + INFO3("sorted[%lu] = %s (%p)", i, node_name(sorted[i]), sorted[i]); } } free(sorted); @@ -127,14 +126,14 @@ void test(char *graph_file) nodes = xbt_graph_get_nodes(graph); edges = xbt_graph_get_edges(graph); INFO2("Before Node deletion: %lu nodes, %lu edges", - xbt_dynar_length(nodes), xbt_dynar_length(edges)); + xbt_dynar_length(nodes), xbt_dynar_length(edges)); while (xbt_dynar_length(nodes)) xbt_graph_free_node(graph, - *((xbt_node_t *) xbt_dynar_get_ptr(nodes, 0)), - free_label, NULL); + *((xbt_node_t *) xbt_dynar_get_ptr(nodes, 0)), + free_label, NULL); INFO2("After Node deletion: %lu nodes, %lu edges", - xbt_dynar_length(nodes), xbt_dynar_length(edges)); + xbt_dynar_length(nodes), xbt_dynar_length(edges)); } if (test_edge_deletion) { @@ -142,15 +141,15 @@ void test(char *graph_file) nodes = xbt_graph_get_nodes(graph); edges = xbt_graph_get_edges(graph); INFO2("Before Edge deletion: %lu nodes, %lu edges", - xbt_dynar_length(nodes), xbt_dynar_length(edges)); + xbt_dynar_length(nodes), xbt_dynar_length(edges)); while (xbt_dynar_length(edges)) xbt_graph_free_edge(graph, - *((xbt_edge_t *) xbt_dynar_get_ptr(edges, 0)), - NULL); + *((xbt_edge_t *) xbt_dynar_get_ptr(edges, 0)), + NULL); INFO2("After Edge deletion: %lu nodes, %lu edges", - xbt_dynar_length(nodes), xbt_dynar_length(edges)); + xbt_dynar_length(nodes), xbt_dynar_length(edges)); } xbt_graph_free_graph(graph, free_label, NULL, NULL); @@ -158,9 +157,10 @@ void test(char *graph_file) #ifdef __BORLANDC__ #pragma argsused -#endif +#endif -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ xbt_init(&argc, argv); if (argc == 1) { fprintf(stderr, "Usage : %s graph.xml\n", argv[0]);