示例#1
0
from gen import Tree
import demo_trees
reload(demo_trees)
from demo_trees import trees
import reingold_thread
reload(reingold_thread)
from reingold_thread import reingold_tilford as rt
#from reingold_naive import reingold_tilford as rt
import buchheim
reload(buchheim)
from buchheim import buchheim

t = buchheim(trees[9])

r = 30
rh = r * 1.5
rw = r * 1.5
stroke(0)

DEBUG = True


def drawt(root, depth):
    global r
    oval(root.x * rw, depth * rh, r, r)
    if DEBUG:
        fill(0)
        fontsize(10)
        text("%s" % (round(root.x, 1)), root.x * rw + (rw / 7),
             depth * rh + 1.6 * (rh / 3))
        text("%s" % (root.tree), root.x * rw + (rw / 7), depth * rh + (rh / 3))
示例#2
0
import demo_trees; reload(demo_trees)
from demo_trees import trees
import reingold_thread; reload(reingold_thread)
from reingold_thread import reingold_tilford as rt
#from reingold_naive import reingold_tilford as rt
import buchheim; reload(buchheim)
from buchheim import buchheim

def mirror(t):
    if len(t.children) > 1:
        t.children = tuple(reversed(t.children))
    for c in t.children:
       mirror(c) 
    return t

t = buchheim(trees[8])
#t = buchheim(trees[9])
#t = rt(trees[4])

r = 30
rh = r*1.5
rw = r*1.5
stroke(0)

def drawt(root, depth):
    global r
    oval(root.x * rw, depth * rh, r, r)
    fill(0)
    fontsize(10)
    try:
        text("  %s\n%s,%s" % (root.tree, round(root.x, 2), round(root.mod)), 
示例#3
0
import demo_trees

reload(demo_trees)
from demo_trees import trees
import reingold_thread

reload(reingold_thread)
from reingold_thread import reingold_tilford as rt

# from reingold_naive import reingold_tilford as rt
import buchheim

reload(buchheim)
from buchheim import buchheim

t = buchheim(trees[9])

r = 30
rh = r * 1.5
rw = r * 1.5
stroke(0)

DEBUG = True


def drawt(root, depth):
    global r
    oval(root.x * rw, depth * rh, r, r)
    if DEBUG:
        fill(0)
        fontsize(10)
示例#4
0
from gen import Tree
import demo_trees; reload(demo_trees)
from demo_trees import trees
import buchheim; reload(buchheim)
from buchheim import buchheim

t = buchheim(trees[7])
#t = rt(trees[4])

r = 30
rh = r*1.5
rw = r*1.5
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 sign(x):
    if x == 0: return 0
    if x > 0:  return 1
    else:      return -1
示例#5
0
from gen import Tree
import demo_trees
reload(demo_trees)
from demo_trees import trees
import buchheim
reload(buchheim)
from buchheim import buchheim

t = buchheim(trees[7])
#t = rt(trees[4])

r = 30
rh = r * 1.5
rw = r * 1.5
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)

示例#6
0
from reingold_thread import reingold_tilford as rt
#from reingold_naive import reingold_tilford as rt
import buchheim
reload(buchheim)
from buchheim import buchheim


def mirror(t):
    if len(t.children) > 1:
        t.children = tuple(reversed(t.children))
    for c in t.children:
        mirror(c)
    return t


t = buchheim(trees[8])
#t = buchheim(trees[9])
#t = rt(trees[4])

r = 30
rh = r * 1.5
rw = r * 1.5
stroke(0)


def drawt(root, depth):
    global r
    oval(root.x * rw, depth * rh, r, r)
    fill(0)
    fontsize(10)
    try: