Graphviz 2.29.20120208.0545
lib/common/types.h
Go to the documentation of this file.
00001 /* $Id$ $Revision$ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /*************************************************************************
00005  * Copyright (c) 2011 AT&T Intellectual Property 
00006  * All rights reserved. This program and the accompanying materials
00007  * are made available under the terms of the Eclipse Public License v1.0
00008  * which accompanies this distribution, and is available at
00009  * http://www.eclipse.org/legal/epl-v10.html
00010  *
00011  * Contributors: See CVS logs. Details at http://www.graphviz.org/
00012  *************************************************************************/
00013 
00014 #ifndef GV_TYPES_H
00015 #define GV_TYPES_H
00016 
00017 #include <stdio.h>
00018 #include <assert.h>
00019 #include <signal.h>
00020 
00021 typedef unsigned char boolean;
00022 #ifndef NOT
00023 #define NOT(v) (!(v))
00024 #endif
00025 #ifndef FALSE
00026 #define FALSE 0
00027 #endif
00028 #ifndef TRUE
00029 #define TRUE NOT(FALSE)
00030 #endif
00031 
00032 #include "geom.h"
00033 #include "gvcext.h"
00034 #include "pathgeom.h"
00035 #include "textpara.h"
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041     typedef int (*qsort_cmpf) (const void *, const void *);
00042     typedef int (*bsearch_cmpf) (const void *, const void *);
00043 
00044 #ifdef WITH_CGRAPH
00045 #include <cgraph.h>
00046     typedef struct Agraph_s graph_t;
00047     typedef struct Agnode_s node_t;
00048     typedef struct Agedge_s edge_t;
00049     typedef struct Agsym_s attrsym_t;
00050 #define TAIL_ID "tailport"
00051 #define HEAD_ID "headport"
00052 #else
00053     typedef struct Agraph_t graph_t;
00054     typedef struct Agnode_t node_t;
00055     typedef struct Agedge_t edge_t;
00056     typedef struct Agsym_t attrsym_t;
00057 #endif
00058 
00059     typedef struct htmllabel_t htmllabel_t;
00060 
00061     typedef union inside_t {
00062         struct {
00063             pointf* p;
00064             double* r;
00065         } a;
00066         struct {
00067             node_t* n;
00068             boxf*    bp;
00069         } s;
00070     } inside_t;
00071 
00072     typedef struct port {       /* internal edge endpoint specification */
00073         pointf p;               /* aiming point relative to node center */
00074         double theta;           /* slope in radians */
00075         boxf *bp;               /* if not null, points to bbox of 
00076                                  * rectangular area that is port target
00077                                  */
00078         boolean defined;        /* if true, edge has port info at this end */
00079         boolean constrained;    /* if true, constraints such as theta are set */
00080         boolean clip;           /* if true, clip end to node/port shape */
00081         boolean dyna;           /* if true, assign compass point dynamically */
00082         unsigned char order;    /* for mincross */
00083         unsigned char side;     /* if port is on perimeter of node, this
00084                                  * contains the bitwise OR of the sides (TOP,
00085                                  * BOTTOM, etc.) it is on. 
00086                                  */
00087         char *name;             /* port name, if it was explicitly given, otherwise NULL */
00088     } port;
00089 
00090     typedef struct {
00091         boolean(*swapEnds) (edge_t * e);        /* Should head and tail be swapped? */
00092         boolean(*splineMerge) (node_t * n);     /* Is n a node in the middle of an edge? */
00093         boolean ignoreSwap;                     /* Test for swapped edges if false */
00094         boolean isOrtho;                        /* Orthogonal routing used */
00095     } splineInfo;
00096 
00097     typedef struct pathend_t {
00098         boxf nb;                        /* the node box */
00099         pointf np;              /* node port */
00100         int sidemask;
00101         int boxn;
00102         boxf boxes[20];
00103     } pathend_t;
00104 
00105     typedef struct path {       /* internal specification for an edge spline */
00106         port start, end;
00107         int nbox;               /* number of subdivisions */
00108         boxf *boxes;            /* rectangular regions of subdivision */
00109         void *data;
00110     } path;
00111 
00112     typedef struct bezier {
00113         pointf *list;
00114         int size;
00115         int sflag, eflag;
00116         pointf sp, ep;
00117     } bezier;
00118 
00119     typedef struct splines {
00120         bezier *list;
00121         int size;
00122         boxf bb;
00123     } splines;
00124 
00125     typedef struct textlabel_t {
00126         char *text, *fontname, *fontcolor;
00127         int charset;
00128         double fontsize;
00129         pointf dimen; /* the diagonal size of the label (estimated by layout) */
00130         pointf space; /* the diagonal size of the space for the label */
00131                       /*   the rendered label is aligned in this box */
00132                       /*   space does not include pad or margin */
00133         pointf pos;   /* the center of the space for the label */
00134         union {
00135             struct {
00136                 textpara_t *para;
00137                 short nparas;
00138             } txt;
00139             htmllabel_t *html;
00140         } u;
00141         char valign;  /* 't' 'c' 'b' */
00142         boolean set;  /* true if position is set */
00143         boolean html; /* true if html label */
00144     } textlabel_t;
00145 
00146     typedef struct polygon_t {  /* mutable shape information for a node */
00147         int regular;            /* true for symmetric shapes */
00148         int peripheries;        /* number of periphery lines */
00149         int sides;              /* number of sides */
00150         double orientation;     /* orientation of shape (+ve degrees) */
00151         double distortion;      /* distortion factor - as in trapezium */
00152         double skew;            /* skew factor - as in parallelogram */
00153         int option;             /* ROUNDED, DIAGONAL corners, etc. */
00154         pointf *vertices;       /* array of vertex points */
00155     } polygon_t;
00156 
00157     typedef struct stroke_t {   /* information about a single stroke */
00158         /* we would have called it a path if that term wasn't already used */
00159         int nvertices;          /* number of points in the stroke */
00160         int flags;              /* stroke style flags */
00161         pointf *vertices;       /* array of vertex points */
00162     } stroke_t;
00163 
00164 /* flag definitions for stroke_t */
00165 #define STROKE_CLOSED (1 << 0)
00166 #define STROKE_FILLED (1 << 1)
00167 #define STROKE_PENDOWN (1 << 2)
00168 #define STROKE_VERTICES_ALLOCATED (1 << 3)
00169 
00170     typedef struct shape_t {    /* mutable shape information for a node */
00171         int nstrokes;           /* number of strokes in array */
00172         stroke_t *strokes;      /* array of strokes */
00173         /* The last stroke must always be closed, but can be pen_up.
00174          * It is used as the clipping path */
00175     } shape_t;
00176 
00177     typedef struct shape_functions {    /* read-only shape functions */
00178         void (*initfn) (node_t *);      /* initializes shape from node u.shape_info structure */
00179         void (*freefn) (node_t *);      /* frees  shape from node u.shape_info structure */
00180          port(*portfn) (node_t *, char *, char *);      /* finds aiming point and slope of port */
00181          boolean(*insidefn) (inside_t * inside_context, pointf);        /* clips incident gvc->e spline on shape of gvc->n */
00182         int (*pboxfn)(node_t* n, port* p, int side, boxf rv[], int *kptr); /* finds box path to reach port */
00183         void (*codefn) (GVJ_t * job, node_t * n);       /* emits graphics code for node */
00184     } shape_functions;
00185 
00186     typedef enum { SH_UNSET, SH_POLY, SH_RECORD, SH_POINT, SH_EPSF} shape_kind;
00187 
00188     typedef struct shape_desc { /* read-only shape descriptor */
00189         char *name;             /* as read from graph file */
00190         shape_functions *fns;
00191         polygon_t *polygon;     /* base polygon info */
00192         boolean usershape;
00193     } shape_desc;
00194 
00195 #include "usershape.h"          /* usershapes needed by gvc */
00196 
00197     typedef struct nodequeue {
00198         node_t **store, **limit, **head, **tail;
00199     } nodequeue;
00200 
00201     typedef struct adjmatrix_t {
00202         int nrows, ncols;
00203         char *data;
00204     } adjmatrix_t;
00205 
00206     typedef struct rank_t {
00207         int n;                  /* number of nodes in this rank  */
00208         node_t **v;             /* ordered list of nodes in rank    */
00209         int an;                 /* globally allocated number of nodes   */
00210         node_t **av;            /* allocated list of nodes in rank  */
00211         int ht1, ht2;           /* height below/above centerline    */
00212         int pht1, pht2;         /* as above, but only primitive nodes   */
00213         boolean candidate;      /* for transpose () */
00214         boolean valid;
00215         int cache_nc;           /* caches number of crossings */
00216         adjmatrix_t *flat;
00217     } rank_t;
00218 
00219     typedef enum { R_NONE =
00220             0, R_VALUE, R_FILL, R_COMPRESS, R_AUTO, R_EXPAND } ratio_t;
00221 
00222     typedef struct layout_t {
00223         double quantum;
00224         double scale;
00225         double ratio;           /* set only if ratio_kind == R_VALUE */
00226         double dpi;
00227         pointf margin;
00228         pointf page;
00229         pointf size;
00230         boolean filled;
00231         boolean landscape;
00232         boolean centered;
00233         ratio_t ratio_kind;
00234         void* xdots;
00235         char* id;
00236     } layout_t;
00237 
00238 /* for "record" shapes */
00239     typedef struct field_t {
00240         pointf size;            /* its dimension */
00241         boxf b;                 /* its placement in node's coordinates */
00242         int n_flds;
00243         textlabel_t *lp;        /* n_flds == 0 */
00244         struct field_t **fld;   /* n_flds > 0 */
00245         char *id;               /* user's identifier */
00246         unsigned char LR;       /* if box list is horizontal (left to right) */
00247         unsigned char sides;    /* sides of node exposed to field */
00248     } field_t;
00249 
00250     typedef struct nlist_t {
00251         node_t **list;
00252         int size;
00253     } nlist_t;
00254 
00255     typedef struct elist {
00256         edge_t **list;
00257         int size;
00258     } elist;
00259 
00260 #define GUI_STATE_ACTIVE    (1<<0)
00261 #define GUI_STATE_SELECTED  (1<<1)
00262 #define GUI_STATE_VISITED   (1<<2)
00263 #define GUI_STATE_DELETED   (1<<3)
00264 
00265 #define elist_fastapp(item,L) do {L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
00266 #define elist_append(item,L)  do {L.list = ALLOC(L.size + 2,L.list,edge_t*); L.list[L.size++] = item; L.list[L.size] = NULL;} while(0)
00267 #define alloc_elist(n,L)      do {L.size = 0; L.list = N_NEW(n + 1,edge_t*); } while (0)
00268 #define free_list(L)          do {if (L.list) free(L.list);} while (0)
00269 
00270 typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind;
00271 
00272     typedef struct Agraphinfo_t {
00273 #ifdef WITH_CGRAPH
00274         Agrec_t hdr;
00275 #endif
00276         /* to generate code */
00277         layout_t *drawing;
00278         textlabel_t *label;     /* if the cluster has a title */
00279         boxf bb;                        /* bounding box */
00280         pointf border[4];       /* sizes of margins for graph labels */
00281         unsigned char gui_state; /* Graph state for GUI ops */
00282         unsigned char has_labels;
00283         boolean has_images;
00284         unsigned char charset; /* input character set */
00285         int rankdir;
00286         int ht1, ht2;   /* below and above extremal ranks */
00287         unsigned short flags;
00288         void *alg;
00289         GVC_t *gvc;     /* context for "globals" over multiple graphs */
00290         void (*cleanup) (graph_t * g);   /* function to deallocate layout-specific data */
00291 
00292 #ifndef DOT_ONLY
00293         /* to place nodes */
00294         node_t **neato_nlist;
00295         int move;
00296         double **dist, **spring, **sum_t, ***t;
00297         unsigned short ndim;
00298         unsigned short odim;
00299 #endif
00300 #ifndef NEATO_ONLY
00301         /* to have subgraphs */
00302         int n_cluster;
00303         graph_t **clust;        /* clusters are in clust[1..n_cluster] !!! */
00304         node_t *nlist;
00305         rank_t *rank;
00306 #ifdef WITH_CGRAPH
00307         graph_t *parent;        /* containing cluster (not parent subgraph) */
00308         int level;              /* cluster nesting level (not node level!) */
00309         node_t  *minrep, *maxrep;       /* set leaders for min and max rank */
00310 #endif
00311 
00312         /* fast graph node list */
00313         nlist_t comp;
00314         /* connected components */
00315         node_t *minset, *maxset;        /* set leaders */
00316         long n_nodes;
00317         /* includes virtual */
00318         short minrank, maxrank;
00319 
00320         /* various flags */
00321         boolean has_flat_edges;
00322 #ifdef WITH_CGRAPH
00323         boolean has_sourcerank;
00324         boolean has_sinkrank;
00325 #endif
00326         unsigned char   showboxes;
00327         boolean cluster_was_collapsed;
00328         fontname_kind fontnames;                /* to override mangling in SVG */
00329 
00330         int nodesep, ranksep;
00331         node_t *ln, *rn;        /* left, right nodes of bounding box */
00332 
00333         /* for clusters */
00334         node_t *leader, **rankleader;
00335         boolean expanded;
00336         char installed;
00337         char set_type;
00338         char label_pos;
00339         boolean exact_ranksep;
00340 #endif
00341 
00342     } Agraphinfo_t;
00343 
00344 #ifdef WITH_CGRAPH
00345 #define GD_parent(g) (((Agraphinfo_t*)AGDATA(g))->parent)
00346 #define GD_level(g) (((Agraphinfo_t*)AGDATA(g))->level)
00347 #define GD_drawing(g) (((Agraphinfo_t*)AGDATA(g))->drawing)
00348 #define GD_bb(g) (((Agraphinfo_t*)AGDATA(g))->bb)
00349 #define GD_gvc(g) (((Agraphinfo_t*)AGDATA(g))->gvc)
00350 #define GD_cleanup(g) (((Agraphinfo_t*)AGDATA(g))->cleanup)
00351 #define GD_dist(g) (((Agraphinfo_t*)AGDATA(g))->dist)
00352 #define GD_alg(g) (((Agraphinfo_t*)AGDATA(g))->alg)
00353 #define GD_border(g) (((Agraphinfo_t*)AGDATA(g))->border)
00354 #define GD_cl_cnt(g) (((Agraphinfo_t*)AGDATA(g))->cl_nt)
00355 #define GD_clust(g) (((Agraphinfo_t*)AGDATA(g))->clust)
00356 #define GD_cluster_was_collapsed(g) (((Agraphinfo_t*)AGDATA(g))->cluster_was_collapsed)
00357 #define GD_comp(g) (((Agraphinfo_t*)AGDATA(g))->comp)
00358 #define GD_exact_ranksep(g) (((Agraphinfo_t*)AGDATA(g))->exact_ranksep)
00359 #define GD_expanded(g) (((Agraphinfo_t*)AGDATA(g))->expanded)
00360 #define GD_flags(g) (((Agraphinfo_t*)AGDATA(g))->flags)
00361 #define GD_gui_state(g) (((Agraphinfo_t*)AGDATA(g))->gui_state)
00362 #define GD_charset(g) (((Agraphinfo_t*)AGDATA(g))->charset)
00363 #define GD_has_labels(g) (((Agraphinfo_t*)AGDATA(g))->has_labels)
00364 #define GD_has_images(g) (((Agraphinfo_t*)AGDATA(g))->has_images)
00365 #define GD_has_flat_edges(g) (((Agraphinfo_t*)AGDATA(g))->has_flat_edges)
00366 #define GD_has_sourcerank(g)    (((Agraphinfo_t*)AGDATA(g))->has_sourcerank)
00367 #define GD_has_sinkrank(g)      (((Agraphinfo_t*)AGDATA(g))->has_sinkrank)
00368 #define GD_ht1(g) (((Agraphinfo_t*)AGDATA(g))->ht1)
00369 #define GD_ht2(g) (((Agraphinfo_t*)AGDATA(g))->ht2)
00370 #define GD_inleaf(g) (((Agraphinfo_t*)AGDATA(g))->inleaf)
00371 #define GD_installed(g) (((Agraphinfo_t*)AGDATA(g))->installed)
00372 #define GD_label(g) (((Agraphinfo_t*)AGDATA(g))->label)
00373 #define GD_leader(g) (((Agraphinfo_t*)AGDATA(g))->leader)
00374 #define GD_rankdir2(g) (((Agraphinfo_t*)AGDATA(g))->rankdir)
00375 #define GD_rankdir(g) (((Agraphinfo_t*)AGDATA(g))->rankdir & 0x3)
00376 #define GD_flip(g) (GD_rankdir(g) & 1)
00377 #define GD_realrankdir(g) ((((Agraphinfo_t*)AGDATA(g))->rankdir) >> 2)
00378 #define GD_realflip(g) (GD_realrankdir(g) & 1)
00379 #define GD_ln(g) (((Agraphinfo_t*)AGDATA(g))->ln)
00380 #define GD_maxrank(g) (((Agraphinfo_t*)AGDATA(g))->maxrank)
00381 #define GD_maxset(g) (((Agraphinfo_t*)AGDATA(g))->maxset)
00382 #define GD_minrank(g) (((Agraphinfo_t*)AGDATA(g))->minrank)
00383 #define GD_minset(g) (((Agraphinfo_t*)AGDATA(g))->minset)
00384 #define GD_minrep(g) (((Agraphinfo_t*)AGDATA(g))->minrep)
00385 #define GD_maxrep(g) (((Agraphinfo_t*)AGDATA(g))->maxrep)
00386 #define GD_move(g) (((Agraphinfo_t*)AGDATA(g))->move)
00387 #define GD_n_cluster(g) (((Agraphinfo_t*)AGDATA(g))->n_cluster)
00388 #define GD_n_nodes(g) (((Agraphinfo_t*)AGDATA(g))->n_nodes)
00389 #define GD_ndim(g) (((Agraphinfo_t*)AGDATA(g))->ndim)
00390 #define GD_odim(g) (((Agraphinfo_t*)AGDATA(g))->odim)
00391 #define GD_neato_nlist(g) (((Agraphinfo_t*)AGDATA(g))->neato_nlist)
00392 #define GD_nlist(g) (((Agraphinfo_t*)AGDATA(g))->nlist)
00393 #define GD_nodesep(g) (((Agraphinfo_t*)AGDATA(g))->nodesep)
00394 #define GD_outleaf(g) (((Agraphinfo_t*)AGDATA(g))->outleaf)
00395 #define GD_rank(g) (((Agraphinfo_t*)AGDATA(g))->rank)
00396 #define GD_rankleader(g) (((Agraphinfo_t*)AGDATA(g))->rankleader)
00397 #define GD_ranksep(g) (((Agraphinfo_t*)AGDATA(g))->ranksep)
00398 #define GD_rn(g) (((Agraphinfo_t*)AGDATA(g))->rn)
00399 #define GD_set_type(g) (((Agraphinfo_t*)AGDATA(g))->set_type)
00400 #define GD_label_pos(g) (((Agraphinfo_t*)AGDATA(g))->label_pos)
00401 #define GD_showboxes(g) (((Agraphinfo_t*)AGDATA(g))->showboxes)
00402 #define GD_fontnames(g) (((Agraphinfo_t*)AGDATA(g))->fontnames)
00403 #define GD_spring(g) (((Agraphinfo_t*)AGDATA(g))->spring)
00404 #define GD_sum_t(g) (((Agraphinfo_t*)AGDATA(g))->sum_t)
00405 #define GD_t(g) (((Agraphinfo_t*)AGDATA(g))->t)
00406 
00407 #else
00408 
00409 #define GD_alg(g) (g)->u.alg
00410 #define GD_bb(g) (g)->u.bb
00411 #define GD_border(g) (g)->u.border
00412 #define GD_cl_cnt(g) (g)->u.cl_cnt
00413 #define GD_cleanup(g) (g)->u.cleanup
00414 #define GD_clust(g) (g)->u.clust
00415 #define GD_cluster_was_collapsed(g) (g)->u.cluster_was_collapsed
00416 #define GD_comp(g) (g)->u.comp
00417 #define GD_dist(g) (g)->u.dist
00418 #define GD_drawing(g) (g)->u.drawing
00419 #define GD_exact_ranksep(g) (g)->u.exact_ranksep
00420 #define GD_expanded(g) (g)->u.expanded
00421 #define GD_flags(g) (g)->u.flags
00422 #define GD_gui_state(g) (g)->u.gui_state
00423 #define GD_gvc(g) (g)->u.gvc
00424 #define GD_charset(g) (g)->u.charset
00425 #define GD_has_labels(g) (g)->u.has_labels
00426 #define GD_has_images(g) (g)->u.has_images
00427 #define GD_has_flat_edges(g) (g)->u.has_flat_edges
00428 #define GD_ht1(g) (g)->u.ht1
00429 #define GD_ht2(g) (g)->u.ht2
00430 #define GD_inleaf(g) (g)->u.inleaf
00431 #define GD_installed(g) (g)->u.installed
00432 #define GD_label(g) (g)->u.label
00433 #define GD_leader(g) (g)->u.leader
00434 #define GD_rankdir(g) ((g)->u.rankdir & 0x3)
00435 #define GD_flip(g) (GD_rankdir(g) & 1)
00436 #define GD_realrankdir(g) ((g)->u.rankdir >> 2)
00437 #define GD_realflip(g) (GD_realrankdir(g) & 1)
00438 #define GD_ln(g) (g)->u.ln
00439 #define GD_maxrank(g) (g)->u.maxrank
00440 #define GD_maxset(g) (g)->u.maxset
00441 #define GD_minrank(g) (g)->u.minrank
00442 #define GD_minset(g) (g)->u.minset
00443 #define GD_move(g) (g)->u.move
00444 #define GD_n_cluster(g) (g)->u.n_cluster
00445 #define GD_n_nodes(g) (g)->u.n_nodes
00446 #define GD_ndim(g) (g)->u.ndim
00447 #define GD_odim(g) (g)->u.odim
00448 #define GD_neato_nlist(g) (g)->u.neato_nlist
00449 #define GD_nlist(g) (g)->u.nlist
00450 #define GD_nodesep(g) (g)->u.nodesep
00451 #define GD_outleaf(g) (g)->u.outleaf
00452 #define GD_rank(g) (g)->u.rank
00453 #define GD_rankleader(g) (g)->u.rankleader
00454 #define GD_ranksep(g) (g)->u.ranksep
00455 #define GD_rn(g) (g)->u.rn
00456 #define GD_set_type(g) (g)->u.set_type
00457 #define GD_label_pos(g) (g)->u.label_pos
00458 #define GD_showboxes(g) (g)->u.showboxes
00459 #define GD_fontnames(g) (g)->u.fontnames
00460 #define GD_spring(g) (g)->u.spring
00461 #define GD_sum_t(g) (g)->u.sum_t
00462 #define GD_t(g) (g)->u.t
00463 #endif
00464 
00465     typedef struct Agnodeinfo_t {
00466 #ifdef WITH_CGRAPH
00467         Agrec_t hdr;
00468 #endif
00469         shape_desc *shape;
00470         void *shape_info;
00471         pointf coord;
00472         double width, height;  /* inches */
00473         boxf bb;
00474         double ht, lw, rw;
00475         textlabel_t *label;
00476         textlabel_t *xlabel;
00477         void *alg;
00478         char state;
00479         unsigned char gui_state; /* Node state for GUI ops */
00480         boolean clustnode;
00481 
00482 #ifndef DOT_ONLY
00483         unsigned char pinned;
00484         int id, heapindex, hops;
00485         double *pos, dist;
00486 #endif
00487 #ifndef NEATO_ONLY
00488         unsigned char showboxes;
00489         boolean  has_port;
00490 #ifdef WITH_CGRAPH
00491         node_t* rep;
00492         node_t *set;
00493 #endif
00494 
00495         /* fast graph */
00496         char node_type, mark, onstack;
00497         char ranktype, weight_class;
00498         node_t *next, *prev;
00499         elist in, out, flat_out, flat_in, other;
00500         graph_t *clust;
00501 
00502         /* for union-find and collapsing nodes */
00503         int UF_size;
00504         node_t *UF_parent;
00505         node_t *inleaf, *outleaf;
00506 
00507         /* for placing nodes */
00508         int rank, order;        /* initially, order = 1 for ordered edges */
00509         int mval;
00510         elist save_in, save_out;
00511 
00512         /* for network-simplex */
00513         elist tree_in, tree_out;
00514         edge_t *par;
00515         int low, lim;
00516         int priority;
00517 
00518         double pad[1];
00519 #endif
00520 
00521     } Agnodeinfo_t;
00522 
00523 #ifdef WITH_CGRAPH
00524 #define ND_id(n) (((Agnodeinfo_t*)AGDATA(n))->id)
00525 #define ND_alg(n) (((Agnodeinfo_t*)AGDATA(n))->alg)
00526 #define ND_UF_parent(n) (((Agnodeinfo_t*)AGDATA(n))->UF_parent)
00527 #define ND_set(n) (((Agnodeinfo_t*)AGDATA(n))->set)
00528 #define ND_UF_size(n) (((Agnodeinfo_t*)AGDATA(n))->UF_size)
00529 #define ND_bb(n) (((Agnodeinfo_t*)AGDATA(n))->bb)
00530 #define ND_clust(n) (((Agnodeinfo_t*)AGDATA(n))->clust)
00531 #define ND_coord(n) (((Agnodeinfo_t*)AGDATA(n))->coord)
00532 #define ND_dist(n) (((Agnodeinfo_t*)AGDATA(n))->dist)
00533 #define ND_flat_in(n) (((Agnodeinfo_t*)AGDATA(n))->flat_in)
00534 #define ND_flat_out(n) (((Agnodeinfo_t*)AGDATA(n))->flat_out)
00535 #define ND_gui_state(n) (((Agnodeinfo_t*)AGDATA(n))->gui_state)
00536 #define ND_has_port(n) (((Agnodeinfo_t*)AGDATA(n))->has_port)
00537 #define ND_rep(n) (((Agnodeinfo_t*)AGDATA(n))->rep)
00538 #define ND_heapindex(n) (((Agnodeinfo_t*)AGDATA(n))->heapindex)
00539 #define ND_height(n) (((Agnodeinfo_t*)AGDATA(n))->height)
00540 #define ND_hops(n) (((Agnodeinfo_t*)AGDATA(n))->hops)
00541 #define ND_ht(n) (((Agnodeinfo_t*)AGDATA(n))->ht)
00542 #define ND_in(n) (((Agnodeinfo_t*)AGDATA(n))->in)
00543 #define ND_inleaf(n) (((Agnodeinfo_t*)AGDATA(n))->inleaf)
00544 #define ND_label(n) (((Agnodeinfo_t*)AGDATA(n))->label)
00545 #define ND_xlabel(n) (((Agnodeinfo_t*)AGDATA(n))->xlabel)
00546 #define ND_lim(n) (((Agnodeinfo_t*)AGDATA(n))->lim)
00547 #define ND_low(n) (((Agnodeinfo_t*)AGDATA(n))->low)
00548 #define ND_lw(n) (((Agnodeinfo_t*)AGDATA(n))->lw)
00549 #define ND_mark(n) (((Agnodeinfo_t*)AGDATA(n))->mark)
00550 #define ND_mval(n) (((Agnodeinfo_t*)AGDATA(n))->mval)
00551 #define ND_n_cluster(n) (((Agnodeinfo_t*)AGDATA(n))->n_cluster)
00552 #define ND_next(n) (((Agnodeinfo_t*)AGDATA(n))->next)
00553 #define ND_node_type(n) (((Agnodeinfo_t*)AGDATA(n))->node_type)
00554 #define ND_onstack(n) (((Agnodeinfo_t*)AGDATA(n))->onstack)
00555 #define ND_order(n) (((Agnodeinfo_t*)AGDATA(n))->order)
00556 #define ND_other(n) (((Agnodeinfo_t*)AGDATA(n))->other)
00557 #define ND_out(n) (((Agnodeinfo_t*)AGDATA(n))->out)
00558 #define ND_outleaf(n) (((Agnodeinfo_t*)AGDATA(n))->outleaf)
00559 #define ND_par(n) (((Agnodeinfo_t*)AGDATA(n))->par)
00560 #define ND_pinned(n) (((Agnodeinfo_t*)AGDATA(n))->pinned)
00561 #define ND_pos(n) (((Agnodeinfo_t*)AGDATA(n))->pos)
00562 #define ND_prev(n) (((Agnodeinfo_t*)AGDATA(n))->prev)
00563 #define ND_priority(n) (((Agnodeinfo_t*)AGDATA(n))->priority)
00564 #define ND_rank(n) (((Agnodeinfo_t*)AGDATA(n))->rank)
00565 #define ND_ranktype(n) (((Agnodeinfo_t*)AGDATA(n))->ranktype)
00566 #define ND_rw(n) (((Agnodeinfo_t*)AGDATA(n))->rw)
00567 #define ND_save_in(n) (((Agnodeinfo_t*)AGDATA(n))->save_in)
00568 #define ND_save_out(n) (((Agnodeinfo_t*)AGDATA(n))->save_out)
00569 #define ND_shape(n) (((Agnodeinfo_t*)AGDATA(n))->shape)
00570 #define ND_shape_info(n) (((Agnodeinfo_t*)AGDATA(n))->shape_info)
00571 #define ND_showboxes(n) (((Agnodeinfo_t*)AGDATA(n))->showboxes)
00572 #define ND_state(n) (((Agnodeinfo_t*)AGDATA(n))->state)
00573 #define ND_clustnode(n) (((Agnodeinfo_t*)AGDATA(n))->clustnode)
00574 #define ND_tree_in(n) (((Agnodeinfo_t*)AGDATA(n))->tree_in)
00575 #define ND_tree_out(n) (((Agnodeinfo_t*)AGDATA(n))->tree_out)
00576 #define ND_weight_class(n) (((Agnodeinfo_t*)AGDATA(n))->weight_class)
00577 #define ND_width(n) (((Agnodeinfo_t*)AGDATA(n))->width)
00578 #define ND_xsize(n) (ND_lw(n)+ND_rw(n))
00579 #define ND_ysize(n) (ND_ht(n))
00580 
00581 #else
00582 
00583 #define ND_UF_parent(n) (n)->u.UF_parent
00584 #define ND_UF_size(n) (n)->u.UF_size
00585 #define ND_alg(n) (n)->u.alg
00586 #define ND_bb(n) (n)->u.bb
00587 #define ND_clust(n) (n)->u.clust
00588 #define ND_coord(n) (n)->u.coord
00589 #define ND_dist(n) (n)->u.dist
00590 #define ND_flat_in(n) (n)->u.flat_in
00591 #define ND_flat_out(n) (n)->u.flat_out
00592 #define ND_gui_state(n) (n)->u.gui_state
00593 #define ND_has_port(n) (n)->u.has_port
00594 #define ND_heapindex(n) (n)->u.heapindex
00595 #define ND_height(n) (n)->u.height
00596 #define ND_hops(n) (n)->u.hops
00597 #define ND_ht(n) (n)->u.ht
00598 #define ND_id(n) (n)->u.id
00599 #define ND_in(n) (n)->u.in
00600 #define ND_inleaf(n) (n)->u.inleaf
00601 #define ND_label(n) (n)->u.label
00602 #define ND_xlabel(n) (n)->u.xlabel
00603 #define ND_lim(n) (n)->u.lim
00604 #define ND_low(n) (n)->u.low
00605 #define ND_lw(n) (n)->u.lw
00606 #define ND_mark(n) (n)->u.mark
00607 #define ND_mval(n) (n)->u.mval
00608 #define ND_n_cluster(n) (n)->u.n_cluster
00609 #define ND_next(n) (n)->u.next
00610 #define ND_node_type(n) (n)->u.node_type
00611 #define ND_onstack(n) (n)->u.onstack
00612 #define ND_order(n) (n)->u.order
00613 #define ND_other(n) (n)->u.other
00614 #define ND_out(n) (n)->u.out
00615 #define ND_outleaf(n) (n)->u.outleaf
00616 #define ND_par(n) (n)->u.par
00617 #define ND_pinned(n) (n)->u.pinned
00618 #define ND_pos(n) (n)->u.pos
00619 #define ND_prev(n) (n)->u.prev
00620 #define ND_priority(n) (n)->u.priority
00621 #define ND_rank(n) (n)->u.rank
00622 #define ND_ranktype(n) (n)->u.ranktype
00623 #define ND_rw(n) (n)->u.rw
00624 #define ND_save_in(n) (n)->u.save_in
00625 #define ND_save_out(n) (n)->u.save_out
00626 #define ND_shape(n) (n)->u.shape
00627 #define ND_shape_info(n) (n)->u.shape_info
00628 #define ND_showboxes(n) (n)->u.showboxes
00629 #define ND_state(n) (n)->u.state
00630 #define ND_clustnode(n) (n)->u.clustnode
00631 #define ND_tree_in(n) (n)->u.tree_in
00632 #define ND_tree_out(n) (n)->u.tree_out
00633 #define ND_weight_class(n) (n)->u.weight_class
00634 #define ND_width(n) (n)->u.width
00635 #define ND_xsize(n) (ND_lw(n)+ND_rw(n))
00636 #define ND_ysize(n) (ND_ht(n))
00637 #endif
00638 
00639     typedef struct Agedgeinfo_t {
00640 #ifdef WITH_CGRAPH
00641         Agrec_t hdr;
00642 #endif
00643         splines *spl;
00644         port tail_port, head_port;
00645         textlabel_t *label, *head_label, *tail_label, *xlabel;
00646         char edge_type;
00647         char adjacent;          /* true for flat edge with adjacent nodes */
00648         char label_ontop;
00649         unsigned char gui_state; /* Edge state for GUI ops */
00650         edge_t *to_orig;        /* for dot's shapes.c    */
00651         void *alg;
00652 
00653 #ifndef DOT_ONLY
00654         double factor;
00655         double dist;
00656         Ppolyline_t path;
00657 #endif
00658 #ifndef NEATO_ONLY
00659         unsigned char showboxes;
00660         boolean conc_opp_flag;
00661         short xpenalty;
00662         float weight;
00663         int cutvalue, tree_index;
00664         short count;
00665         unsigned short minlen;
00666         edge_t *to_virt;
00667 #endif
00668     } Agedgeinfo_t;
00669 
00670 #ifdef WITH_CGRAPH
00671 #define ED_alg(e) (((Agedgeinfo_t*)AGDATA(e))->alg)
00672 #define ED_conc_opp_flag(e) (((Agedgeinfo_t*)AGDATA(e))->conc_opp_flag)
00673 #define ED_count(e) (((Agedgeinfo_t*)AGDATA(e))->count)
00674 #define ED_cutvalue(e) (((Agedgeinfo_t*)AGDATA(e))->cutvalue)
00675 #define ED_edge_type(e) (((Agedgeinfo_t*)AGDATA(e))->edge_type)
00676 #define ED_adjacent(e) (((Agedgeinfo_t*)AGDATA(e))->adjacent)
00677 #define ED_factor(e) (((Agedgeinfo_t*)AGDATA(e))->factor)
00678 #define ED_gui_state(e) (((Agedgeinfo_t*)AGDATA(e))->gui_state)
00679 #define ED_head_label(e) (((Agedgeinfo_t*)AGDATA(e))->head_label)
00680 #define ED_head_port(e) (((Agedgeinfo_t*)AGDATA(e))->head_port)
00681 #define ED_label(e) (((Agedgeinfo_t*)AGDATA(e))->label)
00682 #define ED_xlabel(e) (((Agedgeinfo_t*)AGDATA(e))->xlabel)
00683 #define ED_label_ontop(e) (((Agedgeinfo_t*)AGDATA(e))->label_ontop)
00684 #define ED_minlen(e) (((Agedgeinfo_t*)AGDATA(e))->minlen)
00685 #define ED_path(e) (((Agedgeinfo_t*)AGDATA(e))->path)
00686 #define ED_showboxes(e) (((Agedgeinfo_t*)AGDATA(e))->showboxes)
00687 #define ED_spl(e) (((Agedgeinfo_t*)AGDATA(e))->spl)
00688 #define ED_tail_label(e) (((Agedgeinfo_t*)AGDATA(e))->tail_label)
00689 #define ED_tail_port(e) (((Agedgeinfo_t*)AGDATA(e))->tail_port)
00690 #define ED_to_orig(e) (((Agedgeinfo_t*)AGDATA(e))->to_orig)
00691 #define ED_to_virt(e) (((Agedgeinfo_t*)AGDATA(e))->to_virt)
00692 #define ED_tree_index(e) (((Agedgeinfo_t*)AGDATA(e))->tree_index)
00693 #define ED_xpenalty(e) (((Agedgeinfo_t*)AGDATA(e))->xpenalty)
00694 #define ED_dist(e) (((Agedgeinfo_t*)AGDATA(e))->dist)
00695 #define ED_weight(e) (((Agedgeinfo_t*)AGDATA(e))->weight)
00696 
00697 #else
00698 
00699 #define ED_alg(e) (e)->u.alg
00700 #define ED_conc_opp_flag(e) (e)->u.conc_opp_flag
00701 #define ED_count(e) (e)->u.count
00702 #define ED_cutvalue(e) (e)->u.cutvalue
00703 #define ED_dist(e) (e)->u.dist
00704 #define ED_edge_type(e) (e)->u.edge_type
00705 #define ED_adjacent(e) (e)->u.adjacent
00706 #define ED_factor(e) (e)->u.factor
00707 #define ED_gui_state(e) (e)->u.gui_state
00708 #define ED_head_label(e) (e)->u.head_label
00709 #define ED_head_port(e) (e)->u.head_port
00710 #define ED_label(e) (e)->u.label
00711 #define ED_xlabel(e) (e)->u.xlabel
00712 #define ED_label_ontop(e) (e)->u.label_ontop
00713 #define ED_minlen(e) (e)->u.minlen
00714 #define ED_path(e) (e)->u.path
00715 #define ED_showboxes(e) (e)->u.showboxes
00716 #define ED_spl(e) (e)->u.spl
00717 #define ED_tail_label(e) (e)->u.tail_label
00718 #define ED_tail_port(e) (e)->u.tail_port
00719 #define ED_to_orig(e) (e)->u.to_orig
00720 #define ED_to_virt(e) (e)->u.to_virt
00721 #define ED_tree_index(e) (e)->u.tree_index
00722 #define ED_weight(e) (e)->u.weight
00723 #define ED_xpenalty(e) (e)->u.xpenalty
00724 #endif
00725 
00726 #ifdef WITH_CGRAPH
00727 #include "cgraph.h"
00728 #define ag_xget(x,a) agxget(x,a)
00729 #define SET_RANKDIR(g,rd) (GD_rankdir2(g) = rd)
00730 #define agfindedge(g,t,h) (agedge(g,t,h,NULL,0))
00731 #define agfindnode(g,n) (agnode(g,n,0))
00732 #define agfindgraphattr(g,a) (agattr(g,AGRAPH,a,NULL))
00733 #define agfindnodeattr(g,a) (agattr(g,AGNODE,a,NULL))
00734 #define agfindedgeattr(g,a) (agattr(g,AGEDGE,a,NULL))
00735 #else
00736 #include "graph.h"
00737 #define SET_RANKDIR(g,rd) ((g)->u.rankdir = (rd))
00738 #define ag_xget(x,a) agxget(x,(a)->index)
00739 #define agnameof(x) ((x)->name)
00740     /* warning, agraphof doesn't work for edges */
00741 #define agraphof(n) ((n)->graph)
00742 #define agroot(g) ((g)->root)
00743 #define aghead(e) ((e)->head)
00744 #define agtail(e) ((e)->tail)
00745 #define agisdirected(g) ((g)->kind & AGFLAG_DIRECTED)
00746 #define AGID(x) ((x)->id)
00747 #define agfindgraphattr(g,a) agfindattr((g)->root,a)
00748 #define agfindnodeattr(g,a) agfindattr((g)->proto->n,a)
00749 #define agfindedgeattr(g,a) agfindattr((g)->proto->e,a)
00750 #define agcanonStr(s) agcanonical(s)
00751 #endif
00752 
00753 
00754     typedef struct {
00755         int useGrid;            /* use grid for speed up */
00756         int useNew;             /* encode x-K into attractive force */
00757         int numIters;           /* actual iterations in layout */
00758         int unscaled;           /* % of iterations used in pass 1 */
00759         double C;               /* Repulsion factor in xLayout */
00760         double Tfact;           /* scale temp from default expression */
00761         double K;               /* spring constant; ideal distance */
00762         double T0;              /* initial temperature */
00763     } fdpParms_t;
00764 
00765     typedef struct {
00766         int flags;
00767     } gvlayout_features_t;
00768 
00769 #ifdef __cplusplus
00770 }
00771 #endif
00772 #endif