#endif
}
-/*
#ifdef DEBUG
static void printTok(int tok)
{
}
#endif
-*/
int htmllex()
{
if (endp)
state.ptr = endp;
} while (state.tok == 0);
- /* printTok (state.tok); */
+#if DEBUG
+ printTok (state.tok);
+#endif
return state.tok;
#else
return EOF;
Show_boxes[Show_cnt+1] = NULL;
}
+#if DEBUG > 1
+static void psprintpolypts(Ppoint_t * p, int sz)
+{
+ int i;
+
+ fprintf(stderr, "%%!\n");
+ fprintf(stderr, "%% constraint poly\n");
+ fprintf(stderr, "newpath\n");
+ for (i = 0; i < sz; i++)
+ fprintf(stderr, "%f %f %s\n", p[i].x, p[i].y,
+ (i == 0 ? "moveto" : "lineto"));
+ fprintf(stderr, "closepath stroke\n");
+}
+static void psprintpoint(point p)
+{
+ fprintf(stderr, "gsave\n");
+ fprintf(stderr,
+ "newpath %d %d moveto %d %d 2 0 360 arc closepath fill stroke\n",
+ p.x, p.y, p.x, p.y);
+ fprintf(stderr, "/Times-Roman findfont 4 scalefont setfont\n");
+ fprintf(stderr, "%d %d moveto (\\(%d,%d\\)) show\n", p.x + 5, p.y + 5,
+ p.x, p.y);
+ fprintf(stderr, "grestore\n");
+}
+static void psprintpointf(pointf p)
+{
+ fprintf(stderr, "gsave\n");
+ fprintf(stderr,
+ "newpath %.5g %.5g moveto %.5g %.5g 2 0 360 arc closepath fill stroke\n",
+ p.x, p.y, p.x, p.y);
+ fprintf(stderr, "/Times-Roman findfont 4 scalefont setfont\n");
+ fprintf(stderr, "%.5g %.5g moveto (\\(%.5g,%.5g\\)) show\n", p.x + 5, p.y + 5,
+ p.x, p.y);
+ fprintf(stderr, "grestore\n");
+}
+#endif
+
static void psprintspline(Ppolyline_t spl)
{
char buf[BUFSIZ];
}
}
+#if DEBUG > 1
+static void indent(int l)
+{
+ int i;
+ for (i = 0; i < l; i++)
+ fputs(" ", stderr);
+}
+
+static void prbox(boxf b)
+{
+ fprintf(stderr, "((%.5g,%.5g),(%.5g,%.5g))\n", b.LL.x, b.LL.y, b.UR.x,
+ b.UR.y);
+}
+
+static void dumpL(field_t * info, int level)
+{
+ int i;
+
+ indent(level);
+ if (info->n_flds == 0) {
+ fprintf(stderr, "Label \"%s\" ", info->lp->text);
+ prbox(info->b);
+ } else {
+ fprintf(stderr, "Tbl ");
+ prbox(info->b);
+ for (i = 0; i < info->n_flds; i++) {
+ dumpL(info->fld[i], level + 1);
+ }
+ }
+}
+#endif
+
/* syntax of labels: foo|bar|baz or foo|(recursive|label)|baz */
static void record_init(node_t * n)
{
arr->pts[arr->cnt++].lengthsofar = l;
}
-/*
#ifdef DEBUG
static void
printArr (vararr_t* arr, FILE* fp)
}
}
#endif
-*/
static void
fixArr (vararr_t* arr)
}
}
fixArr (arr);
- /* printArr (arr, stderr); */
+#ifdef DEBUG
+ printArr (arr, stderr);
+#endif
return arr;
}
for (u = GD_nlist(g); u; u = ND_next(u)) cnt++;
return cnt;
}
+
+#if DEBUG > 1
+static void
+dumpRanks (graph_t * g)
+{
+ int i, j;
+ node_t* u;
+ rank_t *rank = GD_rank(g);
+ int rcnt = 0;
+ for (i = GD_minrank(g); i <= GD_maxrank(g); i++) {
+ fprintf (stderr, "[%d] :", i);
+ for (j = 0; j < rank[i].n; j++) {
+ u = rank[i].v[j];
+ rcnt++;
+ if (streq(agnameof(u),"virtual"))
+ fprintf (stderr, " %x", u);
+ else
+ fprintf (stderr, " %s", agnameof(u));
+
+ }
+ fprintf (stderr, "\n");
+ }
+ fprintf (stderr, "count %d rank count = %d\n", fastn(g), rcnt);
+}
+#endif
#endif
static void free_matrix(adjmatrix_t * p);
static int ordercmpf(int *i0, int *i1);
#ifdef DEBUG
+#if DEBUG > 1
+static int gd_minrank(Agraph_t *g) {return GD_minrank(g);}
+static int gd_maxrank(Agraph_t *g) {return GD_maxrank(g);}
+static rank_t *gd_rank(Agraph_t *g, int r) {return &GD_rank(g)[r];}
+static int nd_order(Agnode_t *v) { return ND_order(v); }
+#endif
void check_rs(graph_t * g, int null_ok);
void check_order(void);
void check_vlists(graph_t * g);
static int *TI_list;
static boolean ReMincross;
+#if DEBUG > 1
+static void indent(graph_t* g)
+{
+ if (g->parent) {
+ fprintf (stderr, " ");
+ indent(g->parent);
+ }
+}
+
+static char* nname(node_t* v)
+{
+ static char buf[1000];
+ if (ND_node_type(v)) {
+ if (ND_ranktype(v) == CLUSTER)
+ sprintf (buf, "v%s_%p", agnameof(ND_clust(v)), v);
+ else
+ sprintf (buf, "v_%p", v);
+ } else
+ sprintf (buf, "%s", agnameof(v));
+ return buf;
+}
+static void dumpg (graph_t* g)
+{
+ int j, i, r;
+ node_t* v;
+ edge_t* e;
+
+ fprintf (stderr, "digraph A {\n");
+ for (r = GD_minrank(g); r <= GD_maxrank(g); r++) {
+ fprintf (stderr, " subgraph {rank=same ");
+ for (i = 0; i < GD_rank(g)[r].n; i++) {
+ v = GD_rank(g)[r].v[i];
+ if (i > 0)
+ fprintf (stderr, " -> %s", nname(v));
+ else
+ fprintf (stderr, "%s", nname(v));
+ }
+ if (i > 1) fprintf (stderr, " [style=invis]}\n");
+ else fprintf (stderr, " }\n");
+ }
+ for (r = GD_minrank(g); r < GD_maxrank(g); r++) {
+ for (i = 0; i < GD_rank(g)[r].n; i++) {
+ v = GD_rank(g)[r].v[i];
+ for (j = 0; (e = ND_out(v).list[j]); j++) {
+ fprintf (stderr, "%s -> ", nname(v));
+ fprintf (stderr, "%s\n", nname(aghead(e)));
+ }
+ }
+ }
+ fprintf (stderr, "}\n");
+}
+static void dumpr (graph_t* g, int edges)
+{
+ int j, i, r;
+ node_t* v;
+ edge_t* e;
+
+ for (r = GD_minrank(g); r <= GD_maxrank(g); r++) {
+ fprintf (stderr, "[%d] ", r);
+ for (i = 0; i < GD_rank(g)[r].n; i++) {
+ v = GD_rank(g)[r].v[i];
+ fprintf (stderr, "%s(%.02f,%d) ", nname(v), saveorder(v),ND_order(v));
+ }
+ fprintf (stderr, "\n");
+ }
+ if (edges == 0) return;
+ for (r = GD_minrank(g); r < GD_maxrank(g); r++) {
+ for (i = 0; i < GD_rank(g)[r].n; i++) {
+ v = GD_rank(g)[r].v[i];
+ for (j = 0; (e = ND_out(v).list[j]); j++) {
+ fprintf (stderr, "%s -> ", nname(v));
+ fprintf (stderr, "%s\n", nname(aghead(e)));
+ }
+ }
+ }
+}
+#endif
+
typedef struct {
Agrec_t h;
int x, lo, hi;
static void contain_nodes(graph_t * g);
static boolean idealsize(graph_t * g, double);
+#if DEBUG > 1
+static void
+dumpNS (graph_t * g)
+{
+ node_t* n = GD_nlist(g);
+ elist el;
+ edge_t* e;
+ int i;
+
+ while (n) {
+ el = ND_out(n);
+ for (i = 0; i < el.size; i++) {
+ e = el.list[i];
+ fprintf (stderr, "%s(%x) -> ", agnameof(agtail(e)),agtail(e));
+ fprintf (stderr, "%s(%x) : %d\n", agnameof(aghead(e)), aghead(e),
+ ED_minlen(e));
+ }
+ n = ND_next(n);
+ }
+}
+#endif
+
static double
largeMinlen (double l)
{
*/
#define INIT_SZ 100
+#if DEBUG > 1
+static void dumpObj(Ppoly_t * p)
+{
+ int j;
+ Ppoint_t pt;
+ for (j = 0; j < p->pn; j++) {
+ pt = p->ps[j];
+ fprintf(stderr, " %.5g %.5g", pt.x, pt.y);
+ }
+ fputs("\n", stderr);
+}
+
+static void dumpObjlist(objlist * l)
+{
+ int i;
+ for (i = 0; i < l->cnt; i++) {
+ dumpObj(l->obs[i]);
+ }
+}
+#endif
+
static void addObj(objlist * l, Ppoly_t * obj)
{
if (l->sz == l->cnt) {
}
+#if DEBUG > 1
+static char *symName(Expr_t * ex, int op)
+{
+ if (op >= MINNAME && op <= MAXNAME)
+ return gprnames[op];
+ else {
+ Sfio_t *sf = sfstropen();
+ char *s;
+
+ sfprintf(sf, "<unknown (%d)>", op);
+ s = exstring(ex, sfstruse(sf));
+ sfclose(sf);
+ return s;
+ }
+}
+#endif
+
/* xargs:
* Convert string argument to graph to type of graph desired.
* u => undirected
}
}
+#if DEBUG > 1
+static int
+indegree (graph_t * g, node_t *n)
+{
+ edge_t *e;
+ int cnt = 0;
+ for (e = agfstin(g,n); e; e = agnxtin(g,e)) cnt++;
+ return cnt;
+}
+
+static int
+outdegree (graph_t * g, node_t *n)
+{
+ edge_t *e;
+ int cnt = 0;
+ for (e = agfstout(g,n); e; e = agnxtout(g,e)) cnt++;
+ return cnt;
+}
+
+static void
+validate(graph_t * g)
+{
+ node_t *n;
+ edge_t *e;
+ int i, cnt;
+
+ cnt = 0;
+ for (n = GD_nlist(g);n; n = ND_next(n)) {
+ assert(outdegree(g,n) == ND_out(n).size);
+ for (i = 0; (e = ND_out(n).list[i]); i++) {
+ assert(agtail(e) == n);
+ assert( e == agfindedge(g, n, aghead(e)));
+ }
+ assert(indegree(g,n) == ND_in(n).size);
+ for (i = 0; (e = ND_in(n).list[i]); i++) {
+ assert(aghead(e) == n);
+ assert( e == agfindedge(g, agtail(e), n));
+ }
+ cnt++;
+ }
+
+ assert (agnnodes(g) == cnt);
+}
+#endif
+
#ifdef OLD
static node_t *newNode(graph_t * g)
{
#endif
}
+#if DEBUG > 1
+
+static void
+PQprint (PQ* pq)
+{
+ int i;
+ PQTYPE n;
+
+ fprintf (stderr, "Q: ");
+ for (i = 1; i <= pq->PQcnt; i++) {
+ n = pq->pq[i];
+ fprintf (stderr, "(%d:%f) ", N_IDX(pq,n), N_VAL(pq,n));
+ }
+ fprintf (stderr, "\n");
+}
+#endif
#endif
return Dij;
}
+#if DEBUG > 1
+static void dumpMatrix(float *Dij, int n)
+{
+ int i, j, count = 0;
+ for (i = 0; i < n; i++) {
+ for (j = i; j < n; j++) {
+ fprintf(stderr, "%.02f ", Dij[count++]);
+ }
+ fputs("\n", stderr);
+ }
+}
+#endif
+
/* Accumulator type for diagonal of Laplacian. Needs to be as large
* as possible. Use long double; configure to double if necessary.
*/
return 1;
}
+#if DEBUG > 1
+static void
+dumpTrap (trap_t* tr, int n)
+{
+ int i;
+ for (i = 1; i <= n; i++) {
+ tr++;
+ fprintf (stderr, "%d : %d %d (%f,%f) (%f,%f) %d %d %d %d\n", i,
+ tr->lseg, tr->rseg, tr->hi.x, tr->hi.y, tr->lo.x, tr->lo.y,
+ tr->u0, tr->u1, tr->d0, tr->d1);
+ fprintf (stderr, " %d %d %d %d\n", tr->sink, tr->usave,
+ tr->uside, tr->state);
+ }
+ fprintf (stderr, "====\n");
+}
+
+static void
+dumpSegs (segment_t* sg, int n)
+{
+ int i;
+ for (i = 1; i <= n; i++) {
+ sg++;
+ fprintf (stderr, "%d : (%f,%f) (%f,%f) %d %d %d %d %d\n", i,
+ sg->v0.x, sg->v0.y, sg->v1.x, sg->v1.y,
+ sg->is_inserted, sg->root0, sg->root1, sg->next, sg->prev);
+ }
+ fprintf (stderr, "====\n");
+}
+#endif
+
boxf*
partition (cell* cells, int ncells, int* nrects, boxf bb)
{