from gen import Tree from demo_trees import trees from buchheim import buchheim as layout t = layout(trees[3][1]) t2 = layout(trees[3][0]) r = 30 rh = r*1.5 rw = r*1.5 stroke(0) def drawt(root, depth, offset=0): global r oval((root.x * rw) + offset, depth * rh, r, r) fill(0) text(str(int(round(root.x*2, 0))), (root.x * rw) + rw/6 + offset, (depth * rh) + rh/2) fill(1) for child in root.children: drawt(child, depth+1, offset) def drawconn(root, depth, offset=0): for child in root.children: line(root.x * rw + (r/2) + offset, depth * rh + (r/2), child.x * rw + (r/2) + offset, (depth+1) * rh + (r/2)) drawconn(child, depth+1, offset) size(1000, 500) translate(2, 2) stroke(0) drawconn(t2, 0)
from gen import Tree from math import atan, cos, sin, pi import demo_trees reload(demo_trees) from demo_trees import trees import buchheim reload(buchheim) from buchheim import buchheim as layout t = layout(trees[8]) r = 30 rh = r * 1.5 rw = r * 1.5 stroke(0) def drawt(root, depth): oval(root.x * rw, depth * rh, r, r) for child in root.children: drawt(child, depth + 1) def drawconn(root, depth): for child in root.children: line(root.x * rw + (r / 2), depth * rh + (r / 2), child.x * rw + (r / 2), (depth + 1) * rh + (r / 2)) drawconn(child, depth + 1) def dottedline(x1, y1, x2, y2):
from gen import Tree from math import atan, cos, sin, pi import demo_trees; reload(demo_trees) from demo_trees import trees from buchheim import buchheim as layout tree = trees[4][1] tree[0][1].children.append(Tree("a")) tree[0][1].children.append(Tree("b")) t = layout(trees[4][1]) r = 30 rh = r*1.5 rw = r*2 stroke(0) def drawt(root, depth): global r oval(root.x * rw, depth * rh, r, r) for child in root.children: drawt(child, depth+1) def drawconn(root, depth): for child in root.children: line(root.x * rw + (r/2), depth * rh + (r/2), child.x * rw + (r/2), (depth+1) * rh + (r/2)) drawconn(child, depth+1) def dottedline(x1, y1, x2, y2): segment = 5 if x2 - x1 > 0:
from gen import Tree from math import atan, cos, sin, pi import demo_trees; reload(demo_trees) from demo_trees import trees import buchheim; reload(buchheim) from buchheim import buchheim as layout t = layout(trees[8]) r = 30 rh = r*1.5 rw = r*1.5 stroke(0) def drawt(root, depth): oval(root.x * rw, depth * rh, r, r) for child in root.children: drawt(child, depth+1) def drawconn(root, depth): for child in root.children: line(root.x * rw + (r/2), depth * rh + (r/2), child.x * rw + (r/2), (depth+1) * rh + (r/2)) drawconn(child, depth+1) def dottedline(x1, y1, x2, y2): segment = 5 if x2 == x1: theta = pi/2 elif x2 - x1 > 0: theta = atan(float(y2-y1)/float(x2-x1))
from gen import Tree from math import atan, cos, sin, pi import demo_trees reload(demo_trees) from demo_trees import trees from buchheim import buchheim as layout tree = trees[4][1] tree[0][1].children.append(Tree("a")) tree[0][1].children.append(Tree("b")) t = layout(trees[4][1]) r = 30 rh = r * 1.5 rw = r * 2 stroke(0) def drawt(root, depth): global r oval(root.x * rw, depth * rh, r, r) for child in root.children: drawt(child, depth + 1) def drawconn(root, depth): for child in root.children: line(root.x * rw + (r / 2), depth * rh + (r / 2), child.x * rw + (r / 2), (depth + 1) * rh + (r / 2)) drawconn(child, depth + 1)