wolffd@0: /* $Id: graph.h,v 1.20 2009/06/03 01:10:53 ellson Exp $ $Revision: 1.20 $ */ wolffd@0: /* vim:set shiftwidth=4 ts=8: */ wolffd@0: wolffd@0: /********************************************************** wolffd@0: * This software is part of the graphviz package * wolffd@0: * http://www.graphviz.org/ * wolffd@0: * * wolffd@0: * Copyright (c) 1994-2004 AT&T Corp. * wolffd@0: * and is licensed under the * wolffd@0: * Common Public License, Version 1.0 * wolffd@0: * by AT&T Corp. * wolffd@0: * * wolffd@0: * Information and Software Systems Research * wolffd@0: * AT&T Research, Florham Park NJ * wolffd@0: **********************************************************/ wolffd@0: wolffd@0: wolffd@0: wolffd@0: #ifndef _GRAPH_H wolffd@0: #define _GRAPH_H 1 wolffd@0: wolffd@0: #if _PACKAGE_ast wolffd@0: #include wolffd@0: #else wolffd@0: #include wolffd@0: #include wolffd@0: #endif wolffd@0: #include wolffd@0: #include "cdt.h" wolffd@0: wolffd@0: #ifdef __cplusplus wolffd@0: extern "C" { wolffd@0: #endif wolffd@0: wolffd@0: #define TAIL_ID "tailport" wolffd@0: #define HEAD_ID "headport" wolffd@0: wolffd@0: typedef struct Agraph_t Agraph_t; wolffd@0: typedef struct Agnode_t Agnode_t; wolffd@0: typedef struct Agedge_t Agedge_t; wolffd@0: typedef struct Agdict_t Agdict_t; wolffd@0: typedef struct Agsym_t Agsym_t; wolffd@0: typedef struct Agdata_t Agdata_t; wolffd@0: typedef struct Agproto_t Agproto_t; wolffd@0: wolffd@0: typedef char *(*gets_f) (char *ubuf, int n, FILE * fp); wolffd@0: wolffd@0: #define AGFLAG_DIRECTED (1<<0) wolffd@0: #define AGFLAG_STRICT (1<<1) wolffd@0: #define AGFLAG_METAGRAPH (1<<2) wolffd@0: wolffd@0: #define AGRAPH 0 wolffd@0: #define AGRAPHSTRICT (AGRAPH | AGFLAG_STRICT) wolffd@0: #define AGDIGRAPH AGFLAG_DIRECTED wolffd@0: #define AGDIGRAPHSTRICT (AGDIGRAPH | AGFLAG_STRICT) wolffd@0: #define AGMETAGRAPH (AGFLAG_DIRECTED | AGFLAG_STRICT | AGFLAG_METAGRAPH) wolffd@0: wolffd@0: #define AG_IS_DIRECTED(g) ((g)->kind & AGFLAG_DIRECTED) wolffd@0: #define AG_IS_STRICT(g) ((g)->kind & AGFLAG_STRICT) wolffd@0: #define AG_IS_METAGRAPH(g) ((g)->kind & AGFLAG_METAGRAPH) wolffd@0: #define aginit() aginitlib(sizeof(Agraph_t),sizeof(Agnode_t),sizeof(Agedge_t)) wolffd@0: wolffd@0: struct Agraph_t { wolffd@0: int tag:4; wolffd@0: int kind:4; wolffd@0: int handle:24; wolffd@0: char **attr; wolffd@0: char *didset; wolffd@0: char *name; wolffd@0: Agdata_t *univ; wolffd@0: Dict_t *nodes, *inedges, *outedges; wolffd@0: Agraph_t *root; wolffd@0: Agnode_t *meta_node; wolffd@0: Agproto_t *proto; wolffd@0: Agraphinfo_t u; wolffd@0: }; wolffd@0: wolffd@0: struct Agnode_t { wolffd@0: int tag:4; wolffd@0: int pad:4; wolffd@0: int handle:24; wolffd@0: char **attr; wolffd@0: char *didset; wolffd@0: char *name; wolffd@0: int id; wolffd@0: Agraph_t *graph; wolffd@0: Agnodeinfo_t u; wolffd@0: }; wolffd@0: wolffd@0: struct Agedge_t { wolffd@0: int tag:4; wolffd@0: int printkey:4; wolffd@0: int handle:24; wolffd@0: char **attr; wolffd@0: char *didset; wolffd@0: Agnode_t *head, *tail; wolffd@0: int id; wolffd@0: Agedgeinfo_t u; wolffd@0: }; wolffd@0: wolffd@0: struct Agdata_t { /* for main graph */ wolffd@0: Dict_t *node_dict; wolffd@0: Agdict_t *nodeattr; wolffd@0: Agdict_t *edgeattr; wolffd@0: Agdict_t *globattr; wolffd@0: int max_node_id, max_edge_id; wolffd@0: }; wolffd@0: wolffd@0: struct Agsym_t { wolffd@0: char *name, *value; wolffd@0: int index; wolffd@0: unsigned char printed; wolffd@0: unsigned char fixed; wolffd@0: }; wolffd@0: wolffd@0: struct Agdict_t { wolffd@0: char *name; wolffd@0: Dict_t *dict; wolffd@0: Agsym_t **list; wolffd@0: }; wolffd@0: wolffd@0: struct Agproto_t { wolffd@0: Agnode_t *n; wolffd@0: Agedge_t *e; wolffd@0: Agproto_t *prev; wolffd@0: }; wolffd@0: wolffd@0: #if _PACKAGE_ast wolffd@0: _BEGIN_EXTERNS_ /* public data */ wolffd@0: #if _BLD_graph && defined(__EXPORT__) wolffd@0: #define extern __EXPORT__ wolffd@0: #endif wolffd@0: #if !_BLD_graph && defined(__IMPORT__) && 0 wolffd@0: #define extern __IMPORT__ wolffd@0: #endif wolffd@0: #endif wolffd@0: wolffd@0: /*visual studio*/ wolffd@0: #ifdef WIN32_DLL wolffd@0: #ifndef GRAPH_EXPORTS wolffd@0: #define extern __declspec(dllimport) wolffd@0: #endif wolffd@0: #endif wolffd@0: /*end visual studio*/ wolffd@0: extern char *agstrcanon(char *, char *); wolffd@0: extern char *agcanonical(char *); wolffd@0: extern char *agcanon(char *); wolffd@0: extern int aghtmlstr(char *s); wolffd@0: extern char *agget(void *, char *); wolffd@0: extern char *agxget(void *, int); wolffd@0: extern int agset(void *, char *, char *); wolffd@0: extern int agsafeset(void *, char *, char *, char*); wolffd@0: extern int agxset(void *, int, char *); wolffd@0: extern int agindex(void *, char *); wolffd@0: wolffd@0: extern void aginitlib(int, int, int); wolffd@0: extern Agraph_t *agopen(char *, int); wolffd@0: extern Agraph_t *agsubg(Agraph_t *, char *); wolffd@0: extern Agraph_t *agfindsubg(Agraph_t *, char *); wolffd@0: extern void agclose(Agraph_t *); wolffd@0: extern Agraph_t *agread(FILE *); wolffd@0: extern Agraph_t *agread_usergets(FILE *, gets_f); wolffd@0: extern void agreadline(int); wolffd@0: extern void agsetfile(char *); wolffd@0: extern Agraph_t *agmemread(char *); wolffd@0: extern void agsetiodisc( wolffd@0: char * (*myfgets) (char *s, int size, FILE *stream), wolffd@0: size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream), wolffd@0: int (*myferror) (FILE *stream) ); wolffd@0: extern int agputs(const char *s, FILE *fp); wolffd@0: extern int agputc(int c, FILE *fp); wolffd@0: extern int agwrite(Agraph_t *, FILE *); wolffd@0: extern int agerrors(void); wolffd@0: extern Agraph_t *agprotograph(void); wolffd@0: extern Agnode_t *agprotonode(Agraph_t *); wolffd@0: extern Agedge_t *agprotoedge(Agraph_t *); wolffd@0: extern Agraph_t *agusergraph(Agnode_t *); wolffd@0: extern int agnnodes(Agraph_t *); wolffd@0: extern int agnedges(Agraph_t *); wolffd@0: wolffd@0: extern void aginsert(Agraph_t *, void *); wolffd@0: extern void agdelete(Agraph_t *, void *); wolffd@0: extern int agcontains(Agraph_t *, void *); wolffd@0: wolffd@0: extern Agnode_t *agnode(Agraph_t *, char *); wolffd@0: extern Agnode_t *agfindnode(Agraph_t *, char *); wolffd@0: extern Agnode_t *agfstnode(Agraph_t *); wolffd@0: extern Agnode_t *agnxtnode(Agraph_t *, Agnode_t *); wolffd@0: extern Agnode_t *aglstnode(Agraph_t *); wolffd@0: extern Agnode_t *agprvnode(Agraph_t *, Agnode_t *); wolffd@0: wolffd@0: extern Agedge_t *agedge(Agraph_t *, Agnode_t *, Agnode_t *); wolffd@0: extern Agedge_t *agfindedge(Agraph_t *, Agnode_t *, Agnode_t *); wolffd@0: extern Agedge_t *agfstedge(Agraph_t *, Agnode_t *); wolffd@0: extern Agedge_t *agnxtedge(Agraph_t *, Agedge_t *, Agnode_t *); wolffd@0: extern Agedge_t *agfstin(Agraph_t *, Agnode_t *); wolffd@0: extern Agedge_t *agnxtin(Agraph_t *, Agedge_t *); wolffd@0: extern Agedge_t *agfstout(Agraph_t *, Agnode_t *); wolffd@0: extern Agedge_t *agnxtout(Agraph_t *, Agedge_t *); wolffd@0: wolffd@0: extern Agsym_t *agattr(void *, char *, char *); wolffd@0: extern Agsym_t *agraphattr(Agraph_t *, char *, char *); wolffd@0: extern Agsym_t *agnodeattr(Agraph_t *, char *, char *); wolffd@0: extern Agsym_t *agedgeattr(Agraph_t *, char *, char *); wolffd@0: extern Agsym_t *agfindattr(void *, char *); wolffd@0: extern Agsym_t *agfstattr(void *); wolffd@0: extern Agsym_t *agnxtattr(void *, Agsym_t *); wolffd@0: extern Agsym_t *aglstattr(void *); wolffd@0: extern Agsym_t *agprvattr(void *, Agsym_t *); wolffd@0: extern int agcopyattr(void *, void *); wolffd@0: wolffd@0: typedef enum { AGWARN, AGERR, AGMAX, AGPREV } agerrlevel_t; wolffd@0: extern agerrlevel_t agerrno; wolffd@0: extern void agseterr(agerrlevel_t); wolffd@0: extern char *aglasterr(void); wolffd@0: extern int agerr(agerrlevel_t level, char *fmt, ...); wolffd@0: extern void agerrorf(const char *fmt, ...); wolffd@0: extern void agwarningf(char *fmt, ...); wolffd@0: wolffd@0: extern char *agstrdup(char *); wolffd@0: extern char *agstrdup_html(char *s); wolffd@0: extern void agstrfree(char *); wolffd@0: wolffd@0: typedef enum { AGNODE = 1, AGEDGE, AGGRAPH } agobjkind_t; wolffd@0: #define agobjkind(p) ((agobjkind_t)(((Agraph_t*)(p))->tag)) wolffd@0: wolffd@0: #define agmetanode(g) ((g)->meta_node) wolffd@0: wolffd@0: #undef extern wolffd@0: #if _PACKAGE_ast wolffd@0: _END_EXTERNS_ wolffd@0: #endif wolffd@0: #ifdef __cplusplus wolffd@0: } wolffd@0: #endif wolffd@0: #endif /* _GRAPH_H */