if (dim==2) {
IMDS_given_dim(graph, n, y, x, Epsilon);
}
- }
+ }
else {
initLayout(graph, n, dim, d_coords);
hierarchy_spread = compute_hierarchy(graph, n, abs_tol, relative_tol, NULL, &ordering, &levels, &num_levels);
}
+ if (n == 1) return 0;
hierarchy_boundaries = N_GNEW(num_levels, float);
}
}
+#ifdef OBSOLETE
+/* originally, the code called mkHeap to allocate space, then
+ * initHeap to realloc the space. This is silly.
+ * Now we just call initHeap.
+ */
static void mkHeap(heap * h, int size)
{
h->data = N_GNEW(size, int);
h->heapSize = 0;
}
+#endif
static void freeHeap(heap * h)
{
- free(h->data);
+ if (h->data) free(h->data);
}
static void
initHeap(heap * h, int startVertex, int index[], Word dist[], int n)
{
int i, count;
- int j; /* We cannot use an unsigned value in this loop */
+ int j; /* We cannot use an unsigned value in this loop */
/* h->data=(int*) realloc(h->data, (n-1)*sizeof(int)); */
- h->data = N_GNEW(n - 1, int);
+ if (n == 1) h->data = NULL;
+ else h->data = N_GNEW(n - 1, int);
h->heapSize = n - 1;
for (count = 0, i = 0; i < n; i++)
DistType closestDist, prevClosestDist = MAXINT;
static int *index;
+#ifdef OBSOLETE
mkHeap(&H, n);
+#endif
index = (int *) realloc(index, n * sizeof(int));
/* initial distances with edge weights: */
}
+#ifdef OBSOLETE
mkHeap(&H, n);
+#endif
index = (int *) realloc(index, n * sizeof(int));
/* initial distances with edge weights: */
for (i = 1; i < graph[vertex].nedges; i++)
dist[graph[vertex].edges[i]] = (DistType) graph[vertex].ewgts[i];
- initHeap(&H, vertex, index, dist, n); /* again, TOO COSTLY (O(n)) to put all nodes in heap! */
+ /* again, TOO COSTLY (O(n)) to put all nodes in heap! */
+ initHeap(&H, vertex, index, dist, n);
while (num_found < num_visited_nodes
&& extractMax(&H, &closestVertex, index, dist)) {
float closestDist;
int *index;
+#ifdef OBSOLETE
mkHeap(&H, n);
+#endif
index = N_GNEW(n, int);
/* initial distances with edge weights: */