]> granicus.if.org Git - graphviz/commitdiff
Fix bug in split function of quicksort_place.
authorerg <devnull@localhost>
Fri, 21 Mar 2008 22:27:45 +0000 (22:27 +0000)
committererg <devnull@localhost>
Fri, 21 Mar 2008 22:27:45 +0000 (22:27 +0000)
lib/neatogen/kkutils.c
lib/topfish/rescale_layout.c

index 5e34abf201812c10dc812d80b859b21170899e54..1b0050ad4fd5d7c5d782217ef966c2818930b0b5 100644 (file)
@@ -121,16 +121,15 @@ DistType **compute_apsp_artifical_weights(vtx_data * graph, int n)
 
 
 /**********************/
-/*                                   */
+/*                   */
 /*  Quick Sort        */
-/*                                   */
+/*                   */
 /**********************/
 
 static void
 split_by_place(double *place, int *nodes, int first, int last, int *middle)
 {
-    unsigned int splitter =
-       rand() * ((unsigned) (last - first)) / RAND_MAX + (unsigned) first;
+    unsigned int splitter=((unsigned int)rand()|((unsigned int)rand())<<16)%(unsigned int)(last-first+1)+(unsigned int)first;
     int val;
     double place_val;
     int left = first + 1;
index 65b292a8070a659b22859283204e16bd99bdec18..61d800d15f03625f7b18f1cdea7ba89b53d20499 100644 (file)
@@ -122,8 +122,7 @@ static double *smooth_vec(double *vec, int *ordering, int n, int interval,
 static void
 split_by_place(double *place, int *nodes, int first, int last, int *middle)
 {
-    unsigned int splitter =
-       rand() * ((unsigned) (last - first)) / RAND_MAX + (unsigned) first;
+    unsigned int splitter=((unsigned int)rand()|((unsigned int)rand())<<16)%(unsigned int)(last-first+1)+(unsigned int)first;
     int val;
     double place_val;
     int left = first + 1;