From: Jonathan Zheng Date: Thu, 16 Jan 2020 21:12:20 +0000 (+0000) Subject: undid changes to types.h X-Git-Tag: stable_release_2.44.0~12^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fd5216bfc9db387bf748bb7187bdeb9c5dc369b;p=graphviz undid changes to types.h --- diff --git a/lib/common/types.h b/lib/common/types.h index e7da57b08..3a230e645 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -297,8 +297,6 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #ifndef DOT_ONLY /* to place nodes */ node_t **neato_nlist; - node_t **heap; - int heapsize; int move; double **dist; double **spring; @@ -400,8 +398,6 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #define GD_ndim(g) (((Agraphinfo_t*)AGDATA(g))->ndim) #define GD_odim(g) (((Agraphinfo_t*)AGDATA(g))->odim) #define GD_neato_nlist(g) (((Agraphinfo_t*)AGDATA(g))->neato_nlist) -#define GD_heap(g) (((Agraphinfo_t*)AGDATA(g))->heap) -#define GD_heapsize(g) (((Agraphinfo_t*)AGDATA(g))->heapsize) #define GD_nlist(g) (((Agraphinfo_t*)AGDATA(g))->nlist) #define GD_nodesep(g) (((Agraphinfo_t*)AGDATA(g))->nodesep) #define GD_outleaf(g) (((Agraphinfo_t*)AGDATA(g))->outleaf) diff --git a/lib/neatogen/neatoprocs.h b/lib/neatogen/neatoprocs.h index d2066323a..0657f62f7 100644 --- a/lib/neatogen/neatoprocs.h +++ b/lib/neatogen/neatoprocs.h @@ -30,8 +30,8 @@ extern "C" { extern double fpow32(double); extern Ppolyline_t getPath(edge_t *, vconfig_t *, int, Ppoly_t **, int); - extern void heapdown(graph_t *, Agnode_t *); - extern void heapup(graph_t *, Agnode_t *); + extern void heapdown(Agnode_t *); + extern void heapup(Agnode_t *); extern void initial_positions(graph_t *, int); extern int init_port(Agnode_t *, Agedge_t *, char *, boolean); extern void jitter3d(Agnode_t *, int); @@ -43,8 +43,8 @@ extern "C" { extern void move_node(graph_t *, int, Agnode_t *); extern int init_nop(graph_t * g, int); extern void neato_cleanup(graph_t * g); - extern node_t *neato_dequeue(graph_t *); - extern void neato_enqueue(graph_t *, node_t *); + extern node_t *neato_dequeue(void); + extern void neato_enqueue(node_t *); extern void neato_init_node(node_t * n); extern void neato_layout(Agraph_t * g); extern int Plegal_arrangement(Ppoly_t ** polys, int n_polys); diff --git a/lib/neatogen/sgd.c b/lib/neatogen/sgd.c index 5a470b928..6d525ae27 100644 --- a/lib/neatogen/sgd.c +++ b/lib/neatogen/sgd.c @@ -122,7 +122,7 @@ void sgd(graph_t *G, /* input graph */ assert(offset == n_terms); free(graph); if (Verbose) { - fprintf(stderr, " %.2f\n", elapsed_sec()); + fprintf(stderr, " %.2f sec\n", elapsed_sec()); } // initialise annealing schedule diff --git a/lib/neatogen/stuff.c b/lib/neatogen/stuff.c index df38a13bd..9ca317d8e 100644 --- a/lib/neatogen/stuff.c +++ b/lib/neatogen/stuff.c @@ -600,73 +600,77 @@ void move_node(graph_t * G, int nG, node_t * n) } } -void heapup(graph_t * G, node_t * v) +static node_t **Heap; +static int Heapsize; +static node_t *Src; + +void heapup(node_t * v) { int i, par; node_t *u; for (i = ND_heapindex(v); i > 0; i = par) { par = (i - 1) / 2; - u = GD_heap(G)[par]; + u = Heap[par]; if (ND_dist(u) <= ND_dist(v)) break; - GD_heap(G)[par] = v; + Heap[par] = v; ND_heapindex(v) = par; - GD_heap(G)[i] = u; + Heap[i] = u; ND_heapindex(u) = i; } } -void heapdown(graph_t * G, node_t * v) +void heapdown(node_t * v) { int i, left, right, c; node_t *u; i = ND_heapindex(v); - while ((left = 2 * i + 1) < GD_heapsize(G)) { + while ((left = 2 * i + 1) < Heapsize) { right = left + 1; - if ((right < GD_heapsize(G)) - && (ND_dist(GD_heap(G)[right]) < ND_dist(GD_heap(G)[left]))) + if ((right < Heapsize) + && (ND_dist(Heap[right]) < ND_dist(Heap[left]))) c = right; else c = left; - u = GD_heap(G)[c]; + u = Heap[c]; if (ND_dist(v) <= ND_dist(u)) break; - GD_heap(G)[c] = v; + Heap[c] = v; ND_heapindex(v) = c; - GD_heap(G)[i] = u; + Heap[i] = u; ND_heapindex(u) = i; i = c; } } -void neato_enqueue(graph_t * G, node_t * v) +void neato_enqueue(node_t * v) { int i; assert(ND_heapindex(v) < 0); - i = GD_heapsize(G)++; + i = Heapsize++; ND_heapindex(v) = i; - GD_heap(G)[i] = v; + Heap[i] = v; if (i > 0) - heapup(G, v); + heapup(v); } -node_t *neato_dequeue(graph_t * G) +node_t *neato_dequeue(void) { int i; node_t *rv, *v; - if (GD_heapsize(G) == 0) + if (Heapsize == 0) return NULL; - rv = GD_heap(G)[0]; - i = --GD_heapsize(G); - v = GD_heap(G)[i]; - GD_heap(G)[0] = v; + rv = Heap[0]; + i = --Heapsize; + v = Heap[i]; + Heap[0] = v; ND_heapindex(v) = 0; if (i > 1) - heapdown(G, v); + heapdown(v); ND_heapindex(rv) = -1; return rv; } @@ -675,8 +679,7 @@ void shortest_path(graph_t * G, int nG) { node_t *v; - GD_heap(G) = N_NEW(nG + 1, node_t *); - GD_heapsize(G) = 0; + Heap = N_NEW(nG + 1, node_t *); if (Verbose) { fprintf(stderr, "Calculating shortest paths: "); start_timer(); @@ -686,7 +689,7 @@ void shortest_path(graph_t * G, int nG) if (Verbose) { fprintf(stderr, "%.2f sec\n", elapsed_sec()); } - free(GD_heap(G)); + free(Heap); } void s1(graph_t * G, node_t * node) @@ -698,12 +701,12 @@ void s1(graph_t * G, node_t * node) for (t = 0; (v = GD_neato_nlist(G)[t]); t++) ND_dist(v) = Initial_dist; - node_t * Src = node; + Src = node; ND_dist(Src) = 0; ND_hops(Src) = 0; - neato_enqueue(G, Src); + neato_enqueue(Src); - while ((v = neato_dequeue(G))) { + while ((v = neato_dequeue())) { if (v != Src) make_spring(G, Src, v, ND_dist(v)); for (e = agfstedge(G, v); e; e = agnxtedge(G, e, v)) { @@ -713,10 +716,10 @@ void s1(graph_t * G, node_t * node) if (ND_dist(u) > f) { ND_dist(u) = f; if (ND_heapindex(u) >= 0) - heapup(G, u); + heapup(u); else { ND_hops(u) = ND_hops(v) + 1; - neato_enqueue(G, u); + neato_enqueue(u); } } }