title = str(node['from']) if 'to' in node: title += ' ' + str(node['to']) master = Point(x, y, 100, title = title) node_chain = [(node, master)] canvas.points.append(master) i = 1 for node in nodes[1:]: i+=1 y = node['level']*(height-1)/max_level x = i*(width-1)/len(nodes) title = str(node['from']) if 'to' in node: title += ' ' + str(node['to']) p = Point(x, y, 100, title = title) canvas.points.append(p) if node['level'] > node_chain[-1:][0][0]['level']: canvas.link(p, node_chain[-1:][0][1]) elif node['level'] <= node_chain[-1:][0][0]['level']: print node_chain while node['level'] <= node_chain[-1:][0][0]['level']: node_chain = node_chain[:-1] canvas.link(p, node_chain[-1:][0][1]) node_chain.append((node, p)) pixel_mov = 1.0 cm = canvas.center_of_mass() odc = ((width/2)-cm[0])**2 + ((height/2)-cm[1])**2 #canvas.show() #canvas.visualize() i = 0 while canvas.converge(pixel_mov, 3.0): print canvas.converge_time, 'animation/frame%05d' % i
#nodes.reverse() i = 0 for node in nodes: i+=1.0 y = r.randint(1, height-1)#float((i % r)+1)/(r+1)*height x = r.randint(1, width-1)#float((i % r)+1)/(r+1)*width print x, y p = Point(x, y, 10000, title = node[:5]) canvas.points.append(p) nodes[node]['p'] = p for node in nodes: for dest in nodes[node]['links']: canvas.link(nodes[node]['p'], nodes[dest]['p']) pixel_mov = 3.0 cm = canvas.center_of_mass() odc = ((width/2)-cm[0])**2 + ((height/2)-cm[1])**2 #canvas.show() #canvas.visualize() i = 0 while canvas.converge(pixel_mov, 3.0): #print canvas.converge_time, 'animation/frame%05d' % i #canvas.write_to_svg('animation/frame%05d' % i) i+=1 cm = canvas.center_of_mass() ndc = ((width/2)-cm[0])**2 + ((height/2)-cm[1])**2 if ndc > odc: pixel_mov /= 1.25