00001
00002
00003
00004
00005
00006
00007
00008 #ifndef V_VGraph_h
00009 #define V_VGraph_h 1
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "viaio/Vlib.h"
00027 #include "viaio/file.h"
00028
00029
00030 #include <X11/Xfuncproto.h>
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 typedef struct V_GraphRec {
00047 int nnodes;
00048 int nfields;
00049 VRepnKind node_repn;
00050 VAttrList attributes;
00051 struct VNodestruct **table;
00052 int size;
00053 int lastUsed;
00054 int iter;
00055 int useWeights;
00056 } VGraphRec, *VGraph;
00057
00058 typedef struct VNodebaseStruct {
00059 unsigned int hops: 31;
00060 unsigned int visited: 1;
00061 VFloat weight;
00062 struct VAdjstruct *head;
00063 } VNodeBaseRec, *VNodeBase;
00064
00065 typedef struct VNodestruct {
00066 VNodeBaseRec base;
00067 char data[1];
00068 } VNodeRec, *VNode;
00069
00070 typedef struct VAdjstruct {
00071 unsigned int id;
00072 VFloat weight;
00073 struct VAdjstruct *next;
00074 } VAdjRec, *VAdjacency;
00075
00076
00077
00078
00079
00080
00081
00082 #define VGraphAttr "Graph"
00083 #define VNGraphNodesAttr "nnodes"
00084 #define VNNodeFieldsAttr "nfields"
00085 #define VNNodeWeightsAttr "useWeights"
00086
00087
00088
00089
00090
00091
00092
00093 #define VGraphNNodes(graph) (graph->nnodes)
00094
00095 #define VGraphNFields(graph) (graph->nfields)
00096
00097 #define VGraphNSize(graph) (graph->size)
00098
00099 #define VGraphAttrList(graph) (graph->attributes)
00100
00101 #define VGraphGetNode(graph, nid) (graph->table[nid-1])
00102
00103 #define VGraphNodeIsFree(graph, nid) (graph->table[nid-1] == 0)
00104
00105 #define VNodeRepn(graph) (graph->node_repn)
00106
00107 #define VNodeSize(graph) \
00108 (sizeof(VNodeBaseRec) + (graph->nfields * VRepnPrecision(graph->node_repn)) / 8)
00109
00110 #define VNodeTestVisit(node) (((VNodeBase)node)->visited == TRUE)
00111
00112 #define VNodeSetVisit(node) (((VNodeBase)node)->visited = TRUE)
00113
00114 #define VNodeClearVisit(node) (((VNodeBase)node)->visited = FALSE)
00115
00116
00117
00118
00119
00120
00121
00122 extern VGraph VCreateGraph (
00123 #if NeedFunctionPrototypes
00124 int ,
00125 int ,
00126 VRepnKind ,
00127 int
00128 #endif
00129 );
00130
00131 extern VGraph VCopyGraph (
00132 #if NeedFunctionPrototypes
00133 VGraph
00134 #endif
00135 );
00136
00137 extern void VDestroyGraph (
00138 #if NeedFunctionPrototypes
00139 VGraph
00140 #endif
00141 );
00142
00143 extern int VReadGraphs (
00144 #if NeedFunctionPrototypes
00145 FILE * ,
00146 VAttrList * ,
00147 VGraph **
00148 #endif
00149 );
00150
00151 extern VBoolean VWriteGraphs (
00152 #if NeedFunctionPrototypes
00153 FILE * ,
00154 VAttrList ,
00155 int ,
00156 VGraph *
00157 #endif
00158 );
00159
00160 extern int VGraphLookupNode (
00161 #if NeedFunctionPrototypes
00162 VGraph ,
00163 VNode
00164 #endif
00165 );
00166
00167 extern int VGraphAddNode (
00168 #if NeedFunctionPrototypes
00169 VGraph ,
00170 VNode
00171 #endif
00172 );
00173
00174 extern int VGraphAddNodeAt (
00175 #if NeedFunctionPrototypes
00176 VGraph ,
00177 VNode ,
00178 int
00179 #endif
00180 );
00181
00182 extern int VGraphLinkNodes (
00183 #if NeedFunctionPrototypes
00184 VGraph ,
00185 int ,
00186 int
00187 #endif
00188 );
00189
00190 extern int VGraphUnlinkNodes (
00191 #if NeedFunctionPrototypes
00192 VGraph ,
00193 int ,
00194 int
00195 #endif
00196 );
00197
00198 extern VPointer VGraphFirstNode (
00199 #if NeedFunctionPrototypes
00200 VGraph
00201 #endif
00202 );
00203
00204 extern VPointer VGraphNextNode (
00205 #if NeedFunctionPrototypes
00206 VGraph
00207 #endif
00208 );
00209
00210 extern void VGraphClearVisit (
00211 #if NeedFunctionPrototypes
00212 VGraph
00213 #endif
00214 );
00215
00216 extern int VGraphResizeFields (
00217 #if NeedFunctionPrototypes
00218 VGraph ,
00219 int
00220 #endif
00221 );
00222
00223 extern int VGraphNCycles (
00224 #if NeedFunctionPrototypes
00225 VGraph
00226 #endif
00227 );
00228
00229 extern void VGraphToggleNodesFrom (
00230 #if NeedFunctionPrototypes
00231 VGraph ,
00232 int
00233 #endif
00234 );
00235
00236 extern void VDestroyNode (
00237 #if NeedFunctionPrototypes
00238 VGraph ,
00239 int
00240 #endif
00241 );
00242
00243 extern void VGraphDestroyNodesFrom (
00244 #if NeedFunctionPrototypes
00245 VGraph ,
00246 int
00247 #endif
00248 );
00249
00250 extern void VGraphClearHops (
00251 #if NeedFunctionPrototypes
00252 VGraph
00253 #endif
00254 );
00255
00256 #ifdef __cplusplus
00257 }
00258 #endif
00259
00260 #endif