# Changeset 690 for mds-and-trees

Ignore:
Timestamp:
09/04/17 02:52:52 (6 years ago)
Message:

Better (but not ideal) behavior for very big trees

File:
1 edited

Unmodified
Added
Removed
• ## mds-and-trees/tree-genealogy.py

 r689 self.colors = { 'white' :   {'r':100,   'g':100,    'b':100}, 'black' :   {'r':0,     'g':0,      'b':0}, 'red' :     {'r':100,   'g':0,      'b':0}, def xmin_crowd_density(self, x1, x2, y): x1_dist = 0 x2_dist = 0 # TODO experimental - requires further work to make it less 'jumpy' and more predictable x1_dist_loc = 0 x2_dist_loc = 0 count_loc = 1 x1_dist_glob = 0 x2_dist_glob = 0 count_glob = 1 miny = y-2000 maxy = y+2000 def include_pos(pos): nonlocal x1_dist, x2_dist nonlocal x1_dist_loc, x2_dist_loc, x1_dist_glob, x2_dist_glob, count_loc, count_glob dysq = (pos['y']-y)**2 dx1 = pos['x']-x1 dx2 = pos['x']-x2 x1_dist += math.sqrt(dysq + dx1**2) x2_dist += math.sqrt(dysq + dx2**2) d = math.fabs(pos['x'] - (x1+x2)/2) if d < 10: x1_dist_loc += math.sqrt(dysq + dx1**2) x2_dist_loc += math.sqrt(dysq + dx2**2) count_loc += 1 elif d > 20: x1_dist_glob += math.sqrt(dysq + dx1**2) x2_dist_glob += math.sqrt(dysq + dx2**2) count_glob += 1 # optimized to draw from all the nodes, if less than 10 nodes in the range include_pos(pos) return (x1 if x1_dist > x2_dist else x2) # return ((x1 if x1_dist > x2_dist else x2) #             if x1_dist < 10000 else #         (x1 if x1_dist < x2_dist else x2)) return (x1 if (x1_dist_loc-x2_dist_loc)/count_loc-(x1_dist_glob-x2_dist_glob)/count_glob > 0  else x2) #return (x1 if x1_dist +random.gauss(0, 0.00001) > x2_dist +random.gauss(0, 0.00001)  else x2) #print(x1_dist, x2_dist) #x1_dist = x1_dist**2 if self.JITTER: dissimilarity = (1-similarity) + random.gauss(0, 0.5) + 0.001 dissimilarity = (1-similarity) + random.gauss(0, 0.01) + 0.001 else: dissimilarity = (1-similarity) + 0.001
Note: See TracChangeset for help on using the changeset viewer.