00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _EGdGraph
00030 #define _EGdGraph
00031 #include <stdio.h>
00032 #include <limits.h>
00033 #include <stddef.h>
00034 #include "eg_config.h"
00035 #include "eg_macros.h"
00036 #include "eg_io.h"
00037 #include "eg_list.h"
00038 #include "eg_listint.h"
00039 #include "eg_mempool.h"
00040
00041 typedef struct
00042 {
00043 EGlist_t *in_edges;
00044 EGlist_t *out_edges;
00045 EGlistNode_t *cn;
00046 void *data;
00047 unsigned int id;
00048 }
00049 EGdGraphNode_t;
00050
00051 typedef struct
00052 {
00053 EGdGraphNode_t *head;
00054 EGdGraphNode_t *tail;
00055 EGlistNode_t *head_cn,
00056 *tail_cn;
00057 void *data;
00058 unsigned int id;
00059 }
00060 EGdGraphEdge_t;
00061
00062 typedef struct
00063 {
00064 EGlist_t *nodes;
00065 void *data;
00066 EGmemPool_t *mem;
00067 unsigned int id;
00068 unsigned int nedges;
00069 unsigned int node_id_max;
00070 unsigned int edge_id_max;
00071 }
00072 EGdGraph_t;
00073
00074 #define __EG_DGRAPH_CHECK__ 0
00075
00076 int EGdGraphAttachNode (EGdGraph_t * G,
00077 EGdGraphNode_t * n);
00078 int EGdGraphAttachEdge (EGdGraph_t * G,
00079 EGdGraphEdge_t * e);
00080
00081 int EGdGraphUnattachNode (EGdGraph_t * G,
00082 EGdGraphNode_t * n);
00083 int EGdGraphUnattachEdge (EGdGraph_t * G,
00084 EGdGraphEdge_t * e);
00085
00086 EGdGraph_t *EGnewDGraph (EGmemPool_t * mem);
00087 EGdGraphNode_t *EGnewDGraphNode (EGmemPool_t * mem);
00088 EGdGraphEdge_t *EGnewDGraphEdge (EGmemPool_t * mem);
00089
00090 void EGfreeDGraph (void *v);
00091 void EGfreeDGraphNode (void *v);
00092 void EGfreeDGraphEdge (void *v,
00093 EGmemPool_t * mem);
00094
00095 void EGdGraphClear (EGdGraph_t * G,
00096 EGfree_f userFreeEdgeData,
00097 EGfree_f userFreeNodeData,
00098 EGfree_f userFreeGraphData);
00099
00100 void EGdGraphClearMP (EGdGraph_t * G,
00101 EGfreeMP_f userFreeEdgeDataMP,
00102 EGfreeMP_f userFreeNodeDataMP,
00103 EGfreeMP_f userFreeGraphDataMP,
00104 EGmemPool_t * edge_data_mem,
00105 EGmemPool_t * node_data_mem,
00106 EGmemPool_t * graph_data_mem);
00107
00108 void EGdGraphEraseEdge (EGdGraph_t * G,
00109 EGdGraphEdge_t * e,
00110 EGfree_f userFreeEdgeData,
00111 EGmemPool_t * mem);
00112
00113 void EGdGraphEraseEdgeMP (EGdGraph_t * G,
00114 EGdGraphEdge_t * e,
00115 EGfreeMP_f userFreeEdgeDataMP,
00116 EGmemPool_t * edge_data_mem,
00117 EGmemPool_t * mem);
00118
00119 void EGdGraphEraseNode (EGdGraph_t * G,
00120 EGdGraphNode_t * n,
00121 EGfree_f userFreeEdgeData,
00122 EGfree_f userFreeNodeData);
00123
00124 void EGdGraphEraseNodeMP (EGdGraph_t * G,
00125 EGdGraphNode_t * n,
00126 EGfreeMP_f userFreeEdgeDataMP,
00127 EGfreeMP_f userFreeNodeDataMP,
00128 EGmemPool_t * node_data_mem,
00129 EGmemPool_t * edge_data_mem);
00130
00131 EGdGraphNode_t *EGdGraphAddNode (EGdGraph_t * G,
00132 void *ndata);
00133
00134 EGdGraphEdge_t *EGdGraphAddEdge (EGdGraph_t * G,
00135 void *edata,
00136 EGdGraphNode_t * head,
00137 EGdGraphNode_t * tail);
00138
00139 int EGdGraphResetNodeId (EGdGraph_t * G);
00140 int EGdGraphResetEdgeId (EGdGraph_t * G);
00141
00142 int EGdGraphDisplay (EGdGraph_t * G,
00143 EGdisplay_f userDisplayDGraphData,
00144 EGdisplay_f userDisplayNodeData,
00145 EGdisplay_f userDisplayEdgeData,
00146 FILE * file);
00147
00148
00149 #endif