]> granicus.if.org Git - graphviz/commitdiff
sparse Multilevel_Modularity_Clustering_init: rephrase 'deg_total' clamping
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 2 Jan 2023 00:14:33 +0000 (16:14 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 3 Jan 2023 02:57:45 +0000 (18:57 -0800)
Squashes a -Wfloat-equal warning.

lib/sparse/clustering.c

index 94902f13609f339650cf1111f85264368034ad86..c3cd6618c69d58665bc01b1a963874f59ff28171 100644 (file)
@@ -9,6 +9,7 @@
  *************************************************************************/
 
 #define STANDALONE
+#include <math.h>
 #include <sparse/general.h>
 #include <sparse/SparseMatrix.h>
 #include <sparse/clustering.h>
@@ -58,7 +59,7 @@ static Multilevel_Modularity_Clustering Multilevel_Modularity_Clustering_init(Sp
       }
       deg_total += deg[i];
     }
-    if (deg_total == 0) deg_total = 1;
+    deg_total = fmax(deg_total, 1);
     for (i = 0; i < n; i++){
       modularity += (indeg[i] - deg[i]*deg[i]/deg_total)/deg_total;
     }