| 1 | /* $Id$ $Revision$ */ |
| 2 | /* vim:set shiftwidth=4 ts=8: */ |
| 3 | |
| 4 | /************************************************************************* |
| 5 | * Copyright (c) 2011 AT&T Intellectual Property |
| 6 | * All rights reserved. This program and the accompanying materials |
| 7 | * are made available under the terms of the Eclipse Public License v1.0 |
| 8 | * which accompanies this distribution, and is available at |
| 9 | * http://www.eclipse.org/legal/epl-v10.html |
| 10 | * |
| 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ |
| 12 | *************************************************************************/ |
| 13 | |
| 14 | #ifndef CIRCULAR_H |
| 15 | #define CIRCULAR_H |
| 16 | |
| 17 | #include "render.h" |
| 18 | #include "block.h" |
| 19 | |
| 20 | typedef struct { |
| 21 | blocklist_t bl; |
| 22 | int orderCount; |
| 23 | int blockCount; |
| 24 | attrsym_t *N_artpos; |
| 25 | attrsym_t *N_root; |
| 26 | char *rootname; |
| 27 | double min_dist; |
| 28 | } circ_state; |
| 29 | |
| 30 | typedef struct { |
| 31 | Agnode_t *dnode; |
| 32 | } ndata; |
| 33 | |
| 34 | /* Extra node data used for layout: |
| 35 | * Pass O: build derived graph |
| 36 | * Pass 1: construct blocks |
| 37 | * Pass 2: construct block tree |
| 38 | * Pass 3: layout block |
| 39 | * a: construct block skeleton |
| 40 | * b: construct skeleton spanning tree |
| 41 | * c: construct circular list of nodes |
| 42 | * Pass 4: connect blocks |
| 43 | */ |
| 44 | typedef struct { |
| 45 | union { /* Pointer to node/cluster in original graph */ |
| 46 | Agraph_t *g; |
| 47 | Agnode_t *np; |
| 48 | } orig; |
| 49 | int flags; |
| 50 | node_t *parent; /* parent in block-cutpoint traversal (1,2,4) */ |
| 51 | block_t *block; /* Block containing node (1,2,3,4) */ |
| 52 | union { |
| 53 | struct { /* Pass 1 */ |
| 54 | node_t *next; /* used for stack */ |
| 55 | int val; |
| 56 | int low_val; |
| 57 | } bc; |
| 58 | node_t *clone; /* Cloned node (3a) */ |
| 59 | struct { /* Spanning tree and longest path (3b) */ |
| 60 | node_t *tparent; /* Parent in tree */ |
| 61 | node_t *first; /* Leaf on longest path from node */ |
| 62 | node_t *second; /* Leaf on 2nd longest path from node */ |
| 63 | int fdist; /* Length of longest path from node */ |
| 64 | int sdist; /* Length of 2nd longest path from node */ |
| 65 | } t; |
| 66 | struct { |
| 67 | int pos; /* Index of node in block circle (3c,4) */ |
| 68 | double psi; /* Offset angle of children (4) */ |
| 69 | } f; |
| 70 | } u; |
| 71 | } cdata; |
| 72 | |
| 73 | typedef struct { |
| 74 | int order; |
| 75 | Agedge_t* next; |
| 76 | } edata; |
| 77 | |
| 78 | #define NDATA(n) ((ndata*)(ND_alg(n))) |
| 79 | #define DNODE(n) (NDATA(n)->dnode) |
| 80 | |
| 81 | #define EDGEDATA(e) ((edata*)(ED_alg(e))) |
| 82 | #define ENEXT(e) (EDGEDATA(e)->next) |
| 83 | #define EDGEORDER(e) (EDGEDATA(e)->order) |
| 84 | |
| 85 | #define DATA(n) ((cdata*)(ND_alg(n))) |
| 86 | #define ORIGG(n) (DATA(n)->orig.g) |
| 87 | #define ORIGN(n) (DATA(n)->orig.np) |
| 88 | #define FLAGS(n) (DATA(n)->flags) |
| 89 | #define PARENT(n) (DATA(n)->parent) |
| 90 | #define BLOCK(n) (DATA(n)->block) |
| 91 | #define NEXT(n) (DATA(n)->u.bc.next) |
| 92 | #define VAL(n) (DATA(n)->u.bc.val) |
| 93 | #define LOWVAL(n) (DATA(n)->u.bc.low_val) |
| 94 | #define CLONE(n) (DATA(n)->u.clone) |
| 95 | #define TPARENT(n) (DATA(n)->u.t.tparent) |
| 96 | #define LEAFONE(n) (DATA(n)->u.t.first) |
| 97 | #define LEAFTWO(n) (DATA(n)->u.t.second) |
| 98 | #define DISTONE(n) (DATA(n)->u.t.fdist) |
| 99 | #define DISTTWO(n) (DATA(n)->u.t.sdist) |
| 100 | #define POSITION(n) (DATA(n)->u.f.pos) |
| 101 | #define PSI(n) (DATA(n)->u.f.psi) |
| 102 | |
| 103 | #define VISITED_F (1 << 0) |
| 104 | #define ONSTACK_F (1 << 2) |
| 105 | #define PARENT_F (1 << 3) |
| 106 | #define PATH_F (1 << 4) |
| 107 | #define NEIGHBOR_F (1 << 5) |
| 108 | |
| 109 | #define VISITED(n) (FLAGS(n)&VISITED_F) |
| 110 | #define ONSTACK(n) (FLAGS(n)&ONSTACK_F) |
| 111 | #define ISPARENT(n) (FLAGS(n)&PARENT_F) |
| 112 | #define ONPATH(n) (FLAGS(n)&PATH_F) |
| 113 | #define NEIGHBOR(n) (FLAGS(n)&NEIGHBOR_F) |
| 114 | |
| 115 | #define SET_VISITED(n) (FLAGS(n) |= VISITED_F) |
| 116 | #define SET_ONSTACK(n) (FLAGS(n) |= ONSTACK_F) |
| 117 | #define SET_PARENT(n) (FLAGS(n) |= PARENT_F) |
| 118 | #define SET_ONPATH(n) (FLAGS(n) |= PATH_F) |
| 119 | #define SET_NEIGHBOR(n) (FLAGS(n) |= NEIGHBOR_F) |
| 120 | |
| 121 | #define UNSET_VISITED(n) (FLAGS(n) &= ~VISITED_F) |
| 122 | #define UNSET_ONSTACK(n) (FLAGS(n) &= ~ONSTACK_F) |
| 123 | #define UNSET_NEIGHBOR(n) (FLAGS(n) &= ~NEIGHBOR_F) |
| 124 | |
| 125 | #define DEGREE(n) (ND_order(n)) |
| 126 | |
| 127 | #include <circo.h> |
| 128 | |
| 129 | #ifdef __cplusplus |
| 130 | extern "C" { |
| 131 | #endif |
| 132 | |
| 133 | #ifdef DEBUG |
| 134 | extern void prData(Agnode_t * n, int pass); |
| 135 | #endif |
| 136 | |
| 137 | extern void circularLayout(Agraph_t * sg, Agraph_t* rg); |
| 138 | |
| 139 | #ifdef __cplusplus |
| 140 | } |
| 141 | #endif |
| 142 | #endif |
| 143 | |