Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
710af8a43643ec271aaf49c98c8006b9ecdd763b
[simgrid.git] / include / xbt / graph.h
1 #ifndef _XBT_GRAPH_H
2 #define _XBT_GRAPH_H
3 #include "xbt/misc.h" /* SG_BEGIN_DECL */
4 #include "xbt/fifo.h" 
5 #include "xbt/dict.h" 
6
7 SG_BEGIN_DECL()
8
9 typedef struct xbt_node *xbt_node_t;
10 typedef struct xbt_edge  *xbt_edge_t;
11 typedef struct xbt_graph  *xbt_graph_t;
12
13 /* API */
14 xbt_graph_t xbt_graph_new_graph(const char *name, unsigned short int directed, void *data);
15 xbt_node_t xbt_graph_new_node(xbt_graph_t g,const char *name, void *data);
16 xbt_edge_t xbt_graph_new_edge(xbt_graph_t g,const char *name,
17                              xbt_node_t src, xbt_node_t dst, void *data);
18
19 void xbt_graph_remove_node(xbt_graph_t g, xbt_node_t n, void free_function(void * ptr));
20 void xbt_graph_remove_edge(xbt_graph_t g, xbt_edge_t e, void free_function(void * ptr));
21 void xbt_graph_free_graph(xbt_graph_t g, 
22                          void node_free_function(void * ptr),
23                          void edge_free_function(void * ptr),
24                          void graph_free_function(void * ptr));
25
26 void xbt_export_graphviz(xbt_graph_t g, const char *filename,
27                          const char *(node_name)(xbt_node_t),
28                          const char *(edge_name)(xbt_edge_t)
29                         );
30
31                         void xbt_graph_export_surfxml(xbt_graph_t g,
32                                                       const char *filename,
33                                                       const char *(node_name)(xbt_node_t),
34                                                       const char *(edge_name)(xbt_edge_t)
35                                                      );
36
37 void *xbt_graph_to_array(xbt_graph_t g); 
38 void xbt_graph_shortest_paths(xbt_graph_t g);
39 void xbt_graph_topological_sort(xbt_graph_t g);
40
41
42
43
44 /** Convenient for loop : g is a graph, n a node, e an edge, b a bucket and i an item **/
45
46 /* #define xbt_graph_foreachInNeighbor(v,n,i)            \ */
47 /*    for(i=xbt_fifo_get_first_item((v)->in);              \ */
48 /*      ((i)?(n=((xbt_edge_t)((xbt_fifo_get_item_content(i)) */
49 /* )->src):(NULL));\ */
50 /*        i=xbt_fifo_get_next_item(i)) */
51 /* #define xbt_graph_foreachOutNeighbor(v,n,i)           \ */
52 /*    for(i=xbt_fifo_get_first_item((v)->out);             \ */
53 /*      ((i)?(n=((xbt_edge_t)(xbt_fifo_get_item_content(i)))->dst):(NULL));\ */
54 /*        i=xbt_fifo_get_next_item(i)) */
55
56
57
58 SG_END_DECL()
59
60 #endif                          /* _XBT_GRAPH_H */
61
62
63
64
65
66