3 /* A few basic tests for the graphxml library */
5 /* Copyright (c) 2006 Darina Dimitrova, Arnaud Legrand. All rights reserved.*/
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include <xbt/module.h>
12 #include "xbt/graph.h"
13 #include "xbt/graphxml.h"
14 #include "xbt/dynar.h"
19 void test(char *graph_file);
20 void test(char *graph_file)
25 xbt_dynar_t dynar=NULL;
26 xbt_dynar_t dynar1=NULL;
27 xbt_graph_t graph = xbt_graph_read(graph_file);
28 n=xbt_dynar_length(xbt_graph_get_nodes( graph));
31 double *d=xbt_graph_get_length_matrix(graph);
37 fprintf(stderr,"%le\t",d[i*n+j] );
39 fprintf(stderr,"\n" );
41 dynar = xbt_graph_get_nodes(graph);
44 while(xbt_dynar_length(dynar))
45 xbt_graph_free_node(graph,*((xbt_node_t*)xbt_dynar_get_ptr(dynar,0)),NULL,NULL);
47 dynar = xbt_graph_get_edges(graph);
48 printf("%lu edges\n",xbt_dynar_length(dynar));
49 dynar1 = xbt_graph_get_nodes(graph);
50 printf("%lu nodes\n",xbt_dynar_length(dynar1));
52 xbt_graph_free_graph(graph, NULL, NULL, NULL);
55 int main(int argc, char** argv)
60 fprintf(stderr,"Usage : %s graph.xml\n",argv[0]);