From: erg Date: Fri, 21 Mar 2008 22:27:45 +0000 (+0000) Subject: Fix bug in split function of quicksort_place. X-Git-Tag: LAST_LIBGRAPH~32^2~4450 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=948252b54951d12ec3e3b2142b7fbe08f384740d;p=graphviz Fix bug in split function of quicksort_place. --- diff --git a/lib/neatogen/kkutils.c b/lib/neatogen/kkutils.c index 5e34abf20..1b0050ad4 100644 --- a/lib/neatogen/kkutils.c +++ b/lib/neatogen/kkutils.c @@ -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; diff --git a/lib/topfish/rescale_layout.c b/lib/topfish/rescale_layout.c index 65b292a80..61d800d15 100644 --- a/lib/topfish/rescale_layout.c +++ b/lib/topfish/rescale_layout.c @@ -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;