comparison toolboxes/graph_visualisation/include/graphviz/graph.h @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 /* $Id: graph.h,v 1.20 2009/06/03 01:10:53 ellson Exp $ $Revision: 1.20 $ */
2 /* vim:set shiftwidth=4 ts=8: */
3
4 /**********************************************************
5 * This software is part of the graphviz package *
6 * http://www.graphviz.org/ *
7 * *
8 * Copyright (c) 1994-2004 AT&T Corp. *
9 * and is licensed under the *
10 * Common Public License, Version 1.0 *
11 * by AT&T Corp. *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research, Florham Park NJ *
15 **********************************************************/
16
17
18
19 #ifndef _GRAPH_H
20 #define _GRAPH_H 1
21
22 #if _PACKAGE_ast
23 #include <ast.h>
24 #else
25 #include <sys/types.h>
26 #include <stdlib.h>
27 #endif
28 #include <stdio.h>
29 #include "cdt.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define TAIL_ID "tailport"
36 #define HEAD_ID "headport"
37
38 typedef struct Agraph_t Agraph_t;
39 typedef struct Agnode_t Agnode_t;
40 typedef struct Agedge_t Agedge_t;
41 typedef struct Agdict_t Agdict_t;
42 typedef struct Agsym_t Agsym_t;
43 typedef struct Agdata_t Agdata_t;
44 typedef struct Agproto_t Agproto_t;
45
46 typedef char *(*gets_f) (char *ubuf, int n, FILE * fp);
47
48 #define AGFLAG_DIRECTED (1<<0)
49 #define AGFLAG_STRICT (1<<1)
50 #define AGFLAG_METAGRAPH (1<<2)
51
52 #define AGRAPH 0
53 #define AGRAPHSTRICT (AGRAPH | AGFLAG_STRICT)
54 #define AGDIGRAPH AGFLAG_DIRECTED
55 #define AGDIGRAPHSTRICT (AGDIGRAPH | AGFLAG_STRICT)
56 #define AGMETAGRAPH (AGFLAG_DIRECTED | AGFLAG_STRICT | AGFLAG_METAGRAPH)
57
58 #define AG_IS_DIRECTED(g) ((g)->kind & AGFLAG_DIRECTED)
59 #define AG_IS_STRICT(g) ((g)->kind & AGFLAG_STRICT)
60 #define AG_IS_METAGRAPH(g) ((g)->kind & AGFLAG_METAGRAPH)
61 #define aginit() aginitlib(sizeof(Agraph_t),sizeof(Agnode_t),sizeof(Agedge_t))
62
63 struct Agraph_t {
64 int tag:4;
65 int kind:4;
66 int handle:24;
67 char **attr;
68 char *didset;
69 char *name;
70 Agdata_t *univ;
71 Dict_t *nodes, *inedges, *outedges;
72 Agraph_t *root;
73 Agnode_t *meta_node;
74 Agproto_t *proto;
75 Agraphinfo_t u;
76 };
77
78 struct Agnode_t {
79 int tag:4;
80 int pad:4;
81 int handle:24;
82 char **attr;
83 char *didset;
84 char *name;
85 int id;
86 Agraph_t *graph;
87 Agnodeinfo_t u;
88 };
89
90 struct Agedge_t {
91 int tag:4;
92 int printkey:4;
93 int handle:24;
94 char **attr;
95 char *didset;
96 Agnode_t *head, *tail;
97 int id;
98 Agedgeinfo_t u;
99 };
100
101 struct Agdata_t { /* for main graph */
102 Dict_t *node_dict;
103 Agdict_t *nodeattr;
104 Agdict_t *edgeattr;
105 Agdict_t *globattr;
106 int max_node_id, max_edge_id;
107 };
108
109 struct Agsym_t {
110 char *name, *value;
111 int index;
112 unsigned char printed;
113 unsigned char fixed;
114 };
115
116 struct Agdict_t {
117 char *name;
118 Dict_t *dict;
119 Agsym_t **list;
120 };
121
122 struct Agproto_t {
123 Agnode_t *n;
124 Agedge_t *e;
125 Agproto_t *prev;
126 };
127
128 #if _PACKAGE_ast
129 _BEGIN_EXTERNS_ /* public data */
130 #if _BLD_graph && defined(__EXPORT__)
131 #define extern __EXPORT__
132 #endif
133 #if !_BLD_graph && defined(__IMPORT__) && 0
134 #define extern __IMPORT__
135 #endif
136 #endif
137
138 /*visual studio*/
139 #ifdef WIN32_DLL
140 #ifndef GRAPH_EXPORTS
141 #define extern __declspec(dllimport)
142 #endif
143 #endif
144 /*end visual studio*/
145 extern char *agstrcanon(char *, char *);
146 extern char *agcanonical(char *);
147 extern char *agcanon(char *);
148 extern int aghtmlstr(char *s);
149 extern char *agget(void *, char *);
150 extern char *agxget(void *, int);
151 extern int agset(void *, char *, char *);
152 extern int agsafeset(void *, char *, char *, char*);
153 extern int agxset(void *, int, char *);
154 extern int agindex(void *, char *);
155
156 extern void aginitlib(int, int, int);
157 extern Agraph_t *agopen(char *, int);
158 extern Agraph_t *agsubg(Agraph_t *, char *);
159 extern Agraph_t *agfindsubg(Agraph_t *, char *);
160 extern void agclose(Agraph_t *);
161 extern Agraph_t *agread(FILE *);
162 extern Agraph_t *agread_usergets(FILE *, gets_f);
163 extern void agreadline(int);
164 extern void agsetfile(char *);
165 extern Agraph_t *agmemread(char *);
166 extern void agsetiodisc(
167 char * (*myfgets) (char *s, int size, FILE *stream),
168 size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream),
169 int (*myferror) (FILE *stream) );
170 extern int agputs(const char *s, FILE *fp);
171 extern int agputc(int c, FILE *fp);
172 extern int agwrite(Agraph_t *, FILE *);
173 extern int agerrors(void);
174 extern Agraph_t *agprotograph(void);
175 extern Agnode_t *agprotonode(Agraph_t *);
176 extern Agedge_t *agprotoedge(Agraph_t *);
177 extern Agraph_t *agusergraph(Agnode_t *);
178 extern int agnnodes(Agraph_t *);
179 extern int agnedges(Agraph_t *);
180
181 extern void aginsert(Agraph_t *, void *);
182 extern void agdelete(Agraph_t *, void *);
183 extern int agcontains(Agraph_t *, void *);
184
185 extern Agnode_t *agnode(Agraph_t *, char *);
186 extern Agnode_t *agfindnode(Agraph_t *, char *);
187 extern Agnode_t *agfstnode(Agraph_t *);
188 extern Agnode_t *agnxtnode(Agraph_t *, Agnode_t *);
189 extern Agnode_t *aglstnode(Agraph_t *);
190 extern Agnode_t *agprvnode(Agraph_t *, Agnode_t *);
191
192 extern Agedge_t *agedge(Agraph_t *, Agnode_t *, Agnode_t *);
193 extern Agedge_t *agfindedge(Agraph_t *, Agnode_t *, Agnode_t *);
194 extern Agedge_t *agfstedge(Agraph_t *, Agnode_t *);
195 extern Agedge_t *agnxtedge(Agraph_t *, Agedge_t *, Agnode_t *);
196 extern Agedge_t *agfstin(Agraph_t *, Agnode_t *);
197 extern Agedge_t *agnxtin(Agraph_t *, Agedge_t *);
198 extern Agedge_t *agfstout(Agraph_t *, Agnode_t *);
199 extern Agedge_t *agnxtout(Agraph_t *, Agedge_t *);
200
201 extern Agsym_t *agattr(void *, char *, char *);
202 extern Agsym_t *agraphattr(Agraph_t *, char *, char *);
203 extern Agsym_t *agnodeattr(Agraph_t *, char *, char *);
204 extern Agsym_t *agedgeattr(Agraph_t *, char *, char *);
205 extern Agsym_t *agfindattr(void *, char *);
206 extern Agsym_t *agfstattr(void *);
207 extern Agsym_t *agnxtattr(void *, Agsym_t *);
208 extern Agsym_t *aglstattr(void *);
209 extern Agsym_t *agprvattr(void *, Agsym_t *);
210 extern int agcopyattr(void *, void *);
211
212 typedef enum { AGWARN, AGERR, AGMAX, AGPREV } agerrlevel_t;
213 extern agerrlevel_t agerrno;
214 extern void agseterr(agerrlevel_t);
215 extern char *aglasterr(void);
216 extern int agerr(agerrlevel_t level, char *fmt, ...);
217 extern void agerrorf(const char *fmt, ...);
218 extern void agwarningf(char *fmt, ...);
219
220 extern char *agstrdup(char *);
221 extern char *agstrdup_html(char *s);
222 extern void agstrfree(char *);
223
224 typedef enum { AGNODE = 1, AGEDGE, AGGRAPH } agobjkind_t;
225 #define agobjkind(p) ((agobjkind_t)(((Agraph_t*)(p))->tag))
226
227 #define agmetanode(g) ((g)->meta_node)
228
229 #undef extern
230 #if _PACKAGE_ast
231 _END_EXTERNS_
232 #endif
233 #ifdef __cplusplus
234 }
235 #endif
236 #endif /* _GRAPH_H */