From: Matthew Fernandez Date: Sun, 19 Dec 2021 19:20:02 +0000 (-0800) Subject: dijkstra.c: make 'DIST_MAX' a 'DistType' instead of 'double' X-Git-Tag: 3.0.0~120^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c60228a0b6f27e2732f31d4ea95c84531bde469b;p=graphviz dijkstra.c: make 'DIST_MAX' a 'DistType' instead of 'double' It is not clear to me why this value was type cast to a `double` when all uses of it either explicitly or implicitly cast it back to `DistType`. --- diff --git a/lib/neatogen/dijkstra.c b/lib/neatogen/dijkstra.c index f524d569d..377b35326 100644 --- a/lib/neatogen/dijkstra.c +++ b/lib/neatogen/dijkstra.c @@ -24,10 +24,10 @@ #include #include -#define MAX_DIST (double)INT_MAX - typedef DistType Word; +#define MAX_DIST ((DistType)INT_MAX) + /* This heap class is suited to the Dijkstra alg. data[i]=vertexNum <==> index[vertexNum]=i */ @@ -146,7 +146,7 @@ void dijkstra(int vertex, vtx_data * graph, int n, DistType * dist) /* initial distances with edge weights: */ for (i = 0; i < n; i++) - dist[i] = (DistType) MAX_DIST; + dist[i] = MAX_DIST; dist[vertex] = 0; for (i = 1; i < graph[vertex].nedges; i++) dist[graph[vertex].edges[i]] = (DistType) graph[vertex].ewgts[i]; @@ -217,7 +217,7 @@ dijkstra_bounded(int vertex, vtx_data * graph, int n, DistType * dist, /* initial distances with edge weights: */ for (i = 0; i < n; i++) /* far, TOO COSTLY (O(n))! */ - dist[i] = (DistType) MAX_DIST; + dist[i] = MAX_DIST; dist[vertex] = 0; for (i = 1; i < graph[vertex].nedges; i++) dist[graph[vertex].edges[i]] = (DistType) graph[vertex].ewgts[i];