Skip to content

Commit 2c2bb49

Browse files
Philip GuoPhilip Guo
authored andcommitted
bah
1 parent 9a2b7d5 commit 2c2bb49

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎v3/bintree_module.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# TODO: how do you set the BACKGROUND COLOR of a GraphViz node ... fill=?
22

3+
4+
# example code snippet to visualize, which uses '#break' as a breakpoint
5+
# feel free to clean up however you like
6+
'''
7+
from bintree_module import TNode
8+
import html_module
9+
10+
r = TNode('a',
11+
left=TNode('b0',
12+
left=TNode('c0',
13+
right=TNode('d1')),
14+
right=TNode('c1',
15+
left=TNode('d3'),
16+
right=TNode('d4'))),
17+
right=TNode('b1',
18+
left=TNode('c2')))
19+
20+
def highlight_and_display(root):
21+
def f(node):
22+
node.highlight()
23+
html_module.display_img(root.to_graphviz_img()) #break
24+
node.reset_style()
25+
return f
26+
27+
def preorder(t, visitfn):
28+
if not t:
29+
return
30+
visitfn(t)
31+
preorder(t.left, visitfn)
32+
preorder(t.right, visitfn)
33+
34+
preorder(r, highlight_and_display(r))
35+
'''
36+
37+
338
from collections import defaultdict
439

540
import GChartWrapper

0 commit comments

Comments
 (0)