Changeset 622 for mds-and-trees
- Timestamp:
- 10/11/16 16:48:23 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r621 r622 101 101 global firstnode, nodes, inv_nodes, time 102 102 f = open(dir) 103 loaded = 0 104 103 105 for line in f: 104 106 sline = line.split(' ', 1) … … 127 129 kind[creature["ID"]] = creature["Kind"] 128 130 131 loaded += 1 132 if loaded == max_nodes and max_nodes != 0: 133 break 134 129 135 for k, v in sorted(nodes.items()): 130 136 for val in sorted(v): … … 138 144 global firstnode, nodes, inv_nodes 139 145 f = open(dir) 146 loaded = 0 147 140 148 for line in f: 141 149 sline = line.split() … … 148 156 else: 149 157 firstnode = sline[0] 158 159 loaded += 1 160 if loaded == max_nodes and max_nodes != 0: 161 break 150 162 151 163 for k, v in sorted(nodes.items()): … … 181 193 x1_dist = 0 182 194 x2_dist = 0 195 ymin = y-10 196 ymax = y+10 183 197 for pos in positions: 184 198 pos = positions[pos] 185 if pos[1] > y -10 or pos[1] < y+10:186 dy = pos[1]-y199 if pos[1] > ymin or pos[1] < ymax: 200 dysq = (pos[1]-y)**2 187 201 dx1 = pos[0]-x1 188 202 dx2 = pos[0]-x2 189 203 190 x1_dist += math.sqrt(dy**2 + dx1**2) 191 x2_dist += math.sqrt(dy**2 + dx2**2) 204 205 x1_dist += math.sqrt(dysq + dx1**2) 206 x2_dist += math.sqrt(dysq + dx2**2) 192 207 return (x1 if x1_dist > x2_dist else x2) 193 208 194 209 # ------------------------------------ 195 196 # def prepos_children_reccurent(node):197 # global visited198 # for c in inv_nodes[node]:199 #200 # # we want to visit the node just once, after all of its parents201 # if not all_parents_visited(c):202 # continue203 # else:204 # visited[c] = True205 #206 # cy = 0207 # if TIME == "BIRTHS":208 # if c[0] == "c":209 # cy = int(c[1:])210 # else:211 # cy = int(c)212 # elif TIME == "GENERATIONAL":213 # cy = positions[node][1]+1214 # elif TIME == "REAL":215 # cy = time[c]216 #217 # if len(nodes[c]) == 1:218 # dissimilarity = 0219 # if JITTER == True:220 # dissimilarity = random.gauss(0,1)221 # else:222 # dissimilarity = 1223 # positions[c] = [xmin_crowd(positions[node][0]-dissimilarity, positions[node][0]+dissimilarity, cy), cy]224 # else:225 # vsum = sum([v for k, v in nodes[c].items()])226 # cx = sum([positions[k][0]*v/vsum for k, v in nodes[c].items()])227 #228 # if JITTER == True:229 # positions[c] = [cx + random.gauss(0, 0.1), cy]230 # else:231 # positions[c] = [cx, cy]232 #233 #234 # if c in inv_nodes:235 # prepos_children_reccurent(c)236 210 237 211 def prepos_children(): … … 451 425 452 426 min_skeleton_depth = 0 427 max_nodes = 0 453 428 454 429 firstnode = None … … 462 437 463 438 def main(): 464 global svg_file, min_skeleton_depth, args, \439 global svg_file, min_skeleton_depth, max_nodes, args, \ 465 440 TIME, BALANCE, DOT_STYLE, COLORING, JITTER, \ 466 441 svg_mutation_line_style, svg_crossover_line_style … … 499 474 500 475 parser.add_argument('--simple-data', type=bool, dest='simple_data', help='input data are given in a simple format (#child #parent)') 476 477 478 parser.add_argument('-x', '--max-nodes', type=int, default=0, dest='max_nodes', help='maximum number of nodes drawn (starting from the first one)') 501 479 502 480 parser.set_defaults(draw_tree=True) … … 528 506 dir = args.input 529 507 min_skeleton_depth = args.min_skeleton_depth 508 max_nodes = args.max_nodes 530 509 seed = args.seed 531 510 if seed == -1:
Note: See TracChangeset
for help on using the changeset viewer.