Graphviz  2.31.20130524.0447
lib/circogen/circular.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 CIRCULAR_H
00015 #define CIRCULAR_H
00016 
00017 #include "render.h"
00018 #include "block.h"
00019 
00020 typedef struct {
00021     blocklist_t bl;
00022     int orderCount;
00023     int blockCount;
00024     attrsym_t *N_artpos;
00025     attrsym_t *N_root;
00026     char *rootname;
00027     double min_dist;
00028 } circ_state;
00029 
00030 typedef struct {
00031     Agnode_t *dnode;
00032 } ndata;
00033 
00034 /* Extra node data used for layout:
00035  * Pass O: build derived graph
00036  * Pass 1: construct blocks
00037  * Pass 2: construct block tree
00038  * Pass 3: layout block
00039  *      a:  construct block skeleton
00040  *      b:  construct skeleton spanning tree
00041  *      c:  construct circular list of nodes
00042  * Pass 4: connect blocks
00043  */
00044 typedef struct {
00045     union {                     /* Pointer to node/cluster in original graph */
00046         Agraph_t *g;
00047         Agnode_t *np;
00048     } orig;
00049     int flags;
00050     node_t *parent;             /* parent in block-cutpoint traversal (1,2,4) */
00051     block_t *block;             /* Block containing node (1,2,3,4) */
00052     union {
00053         struct {                /* Pass  1 */
00054             node_t *next;       /* used for stack */
00055             int val;
00056             int low_val;
00057         } bc;
00058         node_t *clone;          /* Cloned node (3a) */
00059         struct {                /* Spanning tree and longest path (3b) */
00060             node_t *tparent;    /* Parent in tree */
00061             node_t *first;      /* Leaf on longest path from node */
00062             node_t *second;     /* Leaf on 2nd longest path from node */
00063             int fdist;          /* Length of longest path from node */
00064             int sdist;          /* Length of 2nd longest path from node */
00065         } t;
00066         struct {
00067             int pos;            /* Index of node in block circle (3c,4) */
00068             double psi;         /* Offset angle of children (4) */
00069         } f;
00070     } u;
00071 } cdata;
00072 
00073 typedef struct {
00074     int order;
00075     Agedge_t* next;
00076 } edata;
00077 
00078 #define NDATA(n) ((ndata*)(ND_alg(n)))
00079 #define DNODE(n)        (NDATA(n)->dnode)
00080 
00081 #define EDGEDATA(e)  ((edata*)(ED_alg(e)))
00082 #define ENEXT(e)     (EDGEDATA(e)->next)
00083 #define EDGEORDER(e) (EDGEDATA(e)->order)
00084 
00085 #define DATA(n) ((cdata*)(ND_alg(n)))
00086 #define ORIGG(n)        (DATA(n)->orig.g)
00087 #define ORIGN(n)        (DATA(n)->orig.np)
00088 #define FLAGS(n) (DATA(n)->flags)
00089 #define PARENT(n) (DATA(n)->parent)
00090 #define BLOCK(n) (DATA(n)->block)
00091 #define NEXT(n) (DATA(n)->u.bc.next)
00092 #define VAL(n) (DATA(n)->u.bc.val)
00093 #define LOWVAL(n)        (DATA(n)->u.bc.low_val)
00094 #define CLONE(n) (DATA(n)->u.clone)
00095 #define TPARENT(n)      (DATA(n)->u.t.tparent)
00096 #define LEAFONE(n)      (DATA(n)->u.t.first)
00097 #define LEAFTWO(n)      (DATA(n)->u.t.second)
00098 #define DISTONE(n)      (DATA(n)->u.t.fdist)
00099 #define DISTTWO(n)      (DATA(n)->u.t.sdist)
00100 #define POSITION(n) (DATA(n)->u.f.pos)
00101 #define PSI(n) (DATA(n)->u.f.psi)
00102 
00103 #define VISITED_F   (1 << 0)
00104 #define ONSTACK_F   (1 << 2)
00105 #define PARENT_F    (1 << 3)
00106 #define PATH_F      (1 << 4)
00107 #define NEIGHBOR_F  (1 << 5)
00108 
00109 #define VISITED(n) (FLAGS(n)&VISITED_F)
00110 #define ONSTACK(n)       (FLAGS(n)&ONSTACK_F)
00111 #define ISPARENT(n)      (FLAGS(n)&PARENT_F)
00112 #define ONPATH(n)        (FLAGS(n)&PATH_F)
00113 #define NEIGHBOR(n)      (FLAGS(n)&NEIGHBOR_F)
00114 
00115 #define SET_VISITED(n) (FLAGS(n) |= VISITED_F)
00116 #define SET_ONSTACK(n)   (FLAGS(n) |= ONSTACK_F)
00117 #define SET_PARENT(n)    (FLAGS(n) |= PARENT_F)
00118 #define SET_ONPATH(n)    (FLAGS(n) |= PATH_F)
00119 #define SET_NEIGHBOR(n)  (FLAGS(n) |= NEIGHBOR_F)
00120 
00121 #define UNSET_VISITED(n) (FLAGS(n) &= ~VISITED_F)
00122 #define UNSET_ONSTACK(n)         (FLAGS(n) &= ~ONSTACK_F)
00123 #define UNSET_NEIGHBOR(n)        (FLAGS(n) &= ~NEIGHBOR_F)
00124 
00125 #define DEGREE(n) (ND_order(n))
00126 
00127 #include <circo.h>
00128 
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132 
00133 #ifdef DEBUG
00134     extern void prData(Agnode_t * n, int pass);
00135 #endif
00136 
00137     extern void circularLayout(Agraph_t * sg, Agraph_t* rg);
00138 
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142 #endif