Changeset 690
- Timestamp:
- 09/04/17 02:52:52 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r689 r690 24 24 25 25 self.colors = { 26 'white' : {'r':100, 'g':100, 'b':100}, 26 27 'black' : {'r':0, 'g':0, 'b':0}, 27 28 'red' : {'r':100, 'g':0, 'b':0}, … … 389 390 390 391 def xmin_crowd_density(self, x1, x2, y): 391 x1_dist = 0 392 x2_dist = 0 392 # TODO experimental - requires further work to make it less 'jumpy' and more predictable 393 x1_dist_loc = 0 394 x2_dist_loc = 0 395 count_loc = 1 396 x1_dist_glob = 0 397 x2_dist_glob = 0 398 count_glob = 1 393 399 miny = y-2000 394 400 maxy = y+2000 … … 402 408 403 409 def include_pos(pos): 404 nonlocal x1_dist, x2_dist 405 410 nonlocal x1_dist_loc, x2_dist_loc, x1_dist_glob, x2_dist_glob, count_loc, count_glob 406 411 dysq = (pos['y']-y)**2 407 412 dx1 = pos['x']-x1 408 413 dx2 = pos['x']-x2 409 414 410 x1_dist += math.sqrt(dysq + dx1**2) 411 x2_dist += math.sqrt(dysq + dx2**2) 415 d = math.fabs(pos['x'] - (x1+x2)/2) 416 417 if d < 10: 418 x1_dist_loc += math.sqrt(dysq + dx1**2) 419 x2_dist_loc += math.sqrt(dysq + dx2**2) 420 count_loc += 1 421 elif d > 20: 422 x1_dist_glob += math.sqrt(dysq + dx1**2) 423 x2_dist_glob += math.sqrt(dysq + dx2**2) 424 count_glob += 1 412 425 413 426 # optimized to draw from all the nodes, if less than 10 nodes in the range … … 421 434 include_pos(pos) 422 435 423 return (x1 if x1_dist > x2_dist else x2) 436 # return ((x1 if x1_dist > x2_dist else x2) 437 # if x1_dist < 10000 else 438 # (x1 if x1_dist < x2_dist else x2)) 439 440 441 return (x1 if (x1_dist_loc-x2_dist_loc)/count_loc-(x1_dist_glob-x2_dist_glob)/count_glob > 0 else x2) 442 #return (x1 if x1_dist +random.gauss(0, 0.00001) > x2_dist +random.gauss(0, 0.00001) else x2) 424 443 #print(x1_dist, x2_dist) 425 444 #x1_dist = x1_dist**2 … … 474 493 475 494 if self.JITTER: 476 dissimilarity = (1-similarity) + random.gauss(0, 0. 5) + 0.001495 dissimilarity = (1-similarity) + random.gauss(0, 0.01) + 0.001 477 496 else: 478 497 dissimilarity = (1-similarity) + 0.001
Note: See TracChangeset
for help on using the changeset viewer.