]> granicus.if.org Git - graphviz/commitdiff
topfish fill_neighbors_vec: use 'fabsf' instead of casting to float
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 18 Sep 2022 16:41:12 +0000 (09:41 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 21 Sep 2022 01:11:01 +0000 (18:11 -0700)
This is simpler and more efficient when both the input and the desired output
type are floats.

lib/topfish/hierarchy.c

index b4fd1fd62fff6d1ea4dd3c4343e8090ee9ce311a..7ae51bdf9f367293a028406e8da3059673f5c424 100644 (file)
@@ -60,7 +60,7 @@ static void fill_neighbors_vec(v_data *graph, int vtx, float *vtx_vec) {
     int j;
     if (graph[0].ewgts != NULL) {
        for (j = 0; j < graph[vtx].nedges; j++) {
-           vtx_vec[graph[vtx].edges[j]] = (float) fabs(graph[vtx].ewgts[j]);   // use fabs for the self loop
+           vtx_vec[graph[vtx].edges[j]] = fabsf(graph[vtx].ewgts[j]);  // use fabsf for the self loop
        }
     } else {
        for (j = 0; j < graph[vtx].nedges; j++) {