# HG changeset patch # User vitor # Date 1216785337 0 # Node ID c2318e551ff51cb518a520ed79c32ced10e8feee # Parent 1502ba3beb72505f4cf4bcd07f1c6c5f8639cd68 When picking a "high utility centroid" do not pick one that has no corresponding points. Not only it is the worst possible pick, but also the code was written without this case in mind. diff -r 1502ba3beb72 -r c2318e551ff5 elbg.c --- a/elbg.c Wed Jul 23 03:54:31 2008 +0000 +++ b/elbg.c Wed Jul 23 03:55:37 2008 +0000 @@ -105,9 +105,12 @@ { int i=0; /* Using linear search, do binary if it ever turns to be speed critical */ - int r = av_random(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1]; + int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1; while (elbg->utility_inc[i] < r) i++; + + assert(!elbg->cells[i]); + return i; }