1
/* Various runtime sanity checks. These should be disabled in
2
* a production version of the code.
11
/* Test global consistency of the view. */
12
void dd_check_all(ddview_t *view)
16
for (r = view->config->low; r <= view->config->high; r++)
17
dd_check_rank(view,r);
18
dd_check_edges(view->layout);
21
/* Check consistency of the nodes within one rank. */
22
void dd_check_rank(ddview_t *view, int r)
24
Agnode_t *ln,*rn,**list;
28
rd = dd_rankd(view,r);
32
for (rn = dd_leftmost(view,r); rn; rn = dd_right(view,rn)) {
33
assert(list[i] == rn); i++;
34
assert(dd_node_in_config(rn));
35
assert(dd_rank(rn) == r);
36
dd_check_elts(view,rn);
38
assert(dd_order(ln) + 1 == dd_order(rn));
39
assert(dd_pos(ln).x + BASE(view)->client->separation.x <= dd_pos(rn).x);
46
/* Check membership of a node w.r.t. graph configuration. */
47
void dd_check_containment(ddview_t *view, int r, Agnode_t *n, int must_be_in)
51
for (rn = dd_leftmost(view,r); rn; rn = dd_right(view,rn)) {
52
if (must_be_in) { if (n == rn) break; }
53
else assert (n != rn);
55
if (must_be_in) assert (n == rn);
58
/* all edges should be unit-length */
59
void dd_check_edges(Agraph_t *g)
65
for (u = agfstnode(g); u; u = agnxtnode(u)) {
66
if (NOT(dd_node_in_config(u))) continue;
67
for (e = agfstout(u); e; e = agnxtout(e)) {
69
assert(aghead(p->last));
71
if (NOT(dd_node_in_config(v))) continue;
72
if (dd_first_elt(e) == NILedge) continue;
73
assert(dd_rank(u) + 1 == dd_rank(v));
78
ilbool dd_check_pathnode(ddview_t *view, Agnode_t *n)
85
rd = dd_rankd(view,r);
86
assert(rd->v[i] == n);
90
void dd_check_vnode_path(ddview_t *view, Agedge_t **vpath)
96
for (i = 0; (e = vpath[i]); i++) {
97
dd_check_pathnode(view,agtail(e));
98
if (i > 0) assert(dd_is_a_vnode(agtail(e)));
101
dd_check_pathnode(view,aghead(f));
104
void dd_check_elts(ddview_t *view, Agnode_t *n)
106
Agedge_t *e,*f,*fst,*lst;
108
if (dd_is_a_vnode(n)) return;
109
for (e = agfstout(n); e; e = agnxtout(e)) {
110
fst = dd_first_elt(e);
111
lst = dd_last_elt(e);
113
for (f = fst; f; f = agfstout(aghead(f))) {
114
dd_check_pathnode(view,aghead(f));
120
void dd_check_newranks(Agraph_t *g)
125
for (n = agfstnode(g); n; n = agnxtnode(n)) {
126
if (dd_is_a_vnode(n)) continue;
127
for (e = agfstout(n); e; e = agnxtout(e)) {
128
if (NOT(dd_constraint(e))) continue;
129
assert (dd_newrank(dd_pathhead(e)) - dd_newrank(dd_pathtail(e)) >= 1);
134
static void check_mg(Agraph_t *g, Agraph_t *root)
139
for (mn = agfstnode(g); mn; mn = agnxtnode(mn)) {
140
assert(mn->base.data);
141
assert(agsubnode(root,mn,FALSE));
142
for (me = agfstout(mn); me; me = agnxtout(me)) {
143
assert(me->base.data);
144
assert(agsubedge(root,me,FALSE));
149
void dd_check_model(ddview_t *view)
153
root = BASE(view)->model.main;
155
check_mg(BASE(view)->model.v[IL_INS],root);
156
check_mg(BASE(view)->model.e[IL_INS],root);
157
check_mg(BASE(view)->model.v[IL_MOD],root);
158
check_mg(BASE(view)->model.e[IL_MOD],root);
159
check_mg(BASE(view)->model.v[IL_DEL],root);
160
check_mg(BASE(view)->model.e[IL_DEL],root);
163
void dd_check_really_gone(Agraph_t *g, Agnode_t *n, unsigned long id)
168
assert (agidnode(g,id,FALSE) == NILnode);
170
for (u = agfstnode(g); u; u = agnxtnode(u)) {
172
for (e = agfstedge(u); e; e = agnxtedge(e,u))
173
assert(e->node != n);
177
void dd_check_vnodes(ddview_t *view)
182
for (n = agfstnode(view->layout); n; n = agnxtnode(n)) {
183
if (NOT(dd_is_a_vnode(n))) continue;
185
if (e == NILedge) abort();
187
if (e == NILedge) abort();
191
static int CLcnt = 0;
192
void dd_check_links(ddview_t *view)
194
Agraph_t *model, *layout;
196
Agedge_t *me, *le, *mme;
199
dd_check_model(view);
200
model = BASE(view)->model.main;
201
layout = view->layout;
203
/* check model graph links to layout graph */
204
for (mn = agfstnode(model); mn; mn = agnxtnode(mn)) {
206
if (ln == NILnode) continue;
207
assert(dd_node(ln)->model == mn);
209
for (me = agfstedge(mn); me; me = agnxtedge(me,mn)) {
210
path = dd_pathrep(me);
212
if (mme == NILedge) continue;
213
assert((mme == me) || (mme == AGOPP(me)));
217
/* check layout object links to model objects */
218
for (ln = agfstnode(layout); ln; ln = agnxtnode(ln)) {
219
if (dd_is_a_vnode(ln) == FALSE) {
220
mn = dd_node(ln)->model;
222
assert(agsubnode(model,mn,FALSE) == mn);
223
assert(ln == dd_rep(mn));
224
for (le = agfstedge(ln); le; le = agnxtedge(le,ln)) {
225
path = dd_edge(le)->path;
227
assert(agsubedge(model,me,FALSE) == me);
231
assert(agfstin(ln) != NILedge);
232
assert(agfstout(ln) != NILedge);