]> granicus.if.org Git - graphviz/commitdiff
fixed initial_positions segfault
authorJonathan Zheng <jonathanzheng@hotmail.co.uk>
Fri, 17 Jan 2020 10:50:08 +0000 (10:50 +0000)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sun, 5 Apr 2020 20:18:29 +0000 (22:18 +0200)
lib/neatogen/sgd.c
lib/neatogen/stuff.c

index f7e3ea95af39e0c2f0e78d04c1e868830a2382d2..e71ccb24c75d79c463fc58668edff9a4df1e09f8 100644 (file)
@@ -154,7 +154,7 @@ void sgd(graph_t *G, /* input graph */
     int n = agnnodes(G);
 
     if (Verbose) {
-        fprintf(stderr, "calculating shortest paths:");
+        fprintf(stderr, "calculating shortest paths and setting up stress terms:");
         start_timer();
     }
     // calculate how many terms will be needed as fixed nodes can be ignored
@@ -175,7 +175,7 @@ void sgd(graph_t *G, /* input graph */
         }
     }
     assert(offset == n_terms);
-    free(graph);
+    free_adjacency(graph);
     if (Verbose) {
         fprintf(stderr, " %.2f sec\n", elapsed_sec());
     }
@@ -213,7 +213,7 @@ void sgd(graph_t *G, /* input graph */
         start_timer();
     }
     int t;
-    rk_seed(0, &rstate);
+    rk_seed(0, &rstate); // TODO: get seed from graph
     for (t=0; t<MaxIter; t++) {
         fisheryates_shuffle(terms, n_terms);
         float eta = eta_max * exp(-lambda * t);
index 9ca317d8ed7e0c71d27f76fde16667c215afd481..dfd8003824b5e39503ee5a0ee5a2459df5b2232b 100644 (file)
@@ -264,7 +264,7 @@ int scan_graph_mode(graph_t * G, int mode)
     } else if (mode == MODE_SGD) {
        Epsilon = .01;
        getdouble(G, "epsilon", &Epsilon);
-       GD_neato_nlist(G) = N_NEW(nV, node_t *);
+       GD_neato_nlist(G) = N_NEW(nV + 1, node_t *); // not sure why but sometimes needs the + 1
        for (i = 0, np = agfstnode(G); np; np = agnxtnode(G, np)) {
            GD_neato_nlist(G)[i] = np;
            ND_id(np) = i++;