- return;
-
-}
-void xbt_graph_remove_edge(xbt_graph_t g, xbt_edge_t e, void free_function(void * ptr))
-{
- int cursor=0;
- xbt_edge_t edge=NULL;
- xbt_node_t node=NULL;
- xbt_node_t temp=NULL;
-
- if ((free_function)&&(e->data))
- free_function(e->data);
- xbt_dynar_foreach(g->nodes,cursor,node)
- {
- if (node==e->src)
- xbt_dynar_pop(node->out,temp);
- if (g->directed)
- xbt_dynar_pop(node->in,temp);
-
- }
- node=NULL;
- cursor=0;
- xbt_dynar_foreach(g->nodes,cursor,node)
- {
- if (node==e->dst)
- xbt_dynar_pop(node->in,temp);
- if (g->directed)
- xbt_dynar_pop(node->out,temp);
-
- }
- cursor=0;
- xbt_dynar_foreach(g->edges,cursor,edge)
- if (edge==e)
- {
- xbt_dynar_cursor_rm(g->edges,&cursor);
- break;
- }
-
-}
-
-static xbt_graph_t parsed_graph=NULL;
-
-static void __parse_graph_begin(void) {
- DEBUG0("<graph>");
-}
-static void __parse_graph_end(void) {
- DEBUG0("</graph>");
-}
-static void __parse_node(void) {
- DEBUG1("<node label=\"%s\"/>",A_graphxml_node_name);
-}
-static void __parse_edge(void) {
- DEBUG2("<edge source=\"%s\" target=\"%s\"/>",A_graphxml_edge_source,
- A_graphxml_edge_target);
-}
-
-xbt_graph_t xbt_graph_read(const char *filename)
-{
- xbt_graph_t graph = xbt_graph_new_graph(1,NULL);
-
- parsed_graph = graph;
-
- xbt_graph_parse_reset_parser();
-
- STag_graphxml_graph_fun = __parse_graph_begin;
- ETag_graphxml_graph_fun = __parse_graph_end;
- ETag_graphxml_node_fun = __parse_node;
- ETag_graphxml_edge_fun = __parse_edge;
-
- xbt_graph_parse_open(filename);
- xbt_assert1((!xbt_graph_parse()),"Parse error in %s",filename);
- xbt_graph_parse_close();
-
- parsed_graph = NULL;
-
- return graph;
+ }
+ xbt_dynar_foreach(g->edges, cursor, edge) {
+ const char *c;
+ const char *c_dir = "->";
+ const char *c_ndir = "--";
+ if (g->directed){
+ c = c_dir;
+ }else{
+ c = c_ndir;
+ }
+ const char *src_name, *dst_name;
+ if (node_name){
+ src_name = node_name(edge->src);
+ dst_name = node_name(edge->dst);
+ fprintf(file, " \"%s\" %s \"%s\"", src_name, c, dst_name);
+ }else{
+ fprintf(file, " \"%p\" %s \"%p\"", edge->src, c, edge->dst);
+ }
+
+ if ((edge_name) && ((name = edge_name(edge))))
+ fprintf(file, "[label=\"%s\"]", name);
+ fprintf(file, ";\n");
+ }
+ fprintf(file, "}\n");
+ fclose(file);