]> granicus.if.org Git - graphviz/commitdiff
undid changes to types.h
authorJonathan Zheng <jonathanzheng@hotmail.co.uk>
Thu, 16 Jan 2020 21:12:20 +0000 (21:12 +0000)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sun, 5 Apr 2020 20:18:29 +0000 (22:18 +0200)
lib/common/types.h
lib/neatogen/neatoprocs.h
lib/neatogen/sgd.c
lib/neatogen/stuff.c

index e7da57b08d585d0368b847600eda7ecee461cdaa..3a230e6457a9371936b932ac9091c78a3cfdd3bd 100644 (file)
@@ -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)
index d2066323aac1a34a9f32f63c36dd75580b7d84e4..0657f62f736a350da56cbe6011cfc348a76416b1 100644 (file)
@@ -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);
index 5a470b92807380dbc731cc02ad686c96e47182c7..6d525ae272293fa0554341b75c6470a5a3aa7b24 100644 (file)
@@ -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
index df38a13bd85a4b0c8315a45e38ac5899de324e53..9ca317d8ed7e0c71d27f76fde16667c215afd481 100644 (file)
@@ -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);
                }
            }
        }