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