Commit 56072b89 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent afb41a07
......@@ -445,7 +445,7 @@ import sys
def graphviz(t, clustername=''):
assert isinstance(t, Tree)
symtab = {} # node -> name
symtab = {} # id(node) -> name
outv = []
def emit(text):
......@@ -459,13 +459,13 @@ def graphviz(t, clustername=''):
assert isinstance(node, (Tree,Bucket))
# register node insymtab
assert node not in symtab
assert id(node) not in symtab
kind = ('T' if isinstance(node, Tree) else 'B')
symtab[node] = '%s%s%d:%d' % (clustername+'_', kind, level, i)
symtab[id(node)] = '%s%s%d:%d' % (clustername+'_', kind, level, i)
# emit node itself
# approach based on https://github.com/Felerius/btree-generator
emit(' %s' % qq(symtab[node]))
emit(' %s' % qq(symtab[id(node)]))
emit(' [')
emit(' shape = box')
emit(' margin = 0')
......@@ -491,13 +491,13 @@ def graphviz(t, clustername=''):
for nodev in _walkBFS(t):
# same rank for nodes on the same level
emit('')
emit(' {rank=same; %s}' % ' '.join([qq(symtab[_]) for _ in nodev]))
emit(' {rank=same; %s}' % ' '.join([qq(symtab[id(_)]) for _ in nodev]))
# links
for node in nodev:
if not isinstance(node, Tree):
continue
for (j,child) in enumerate(node.children):
emit(' %s:"con%d" -> %s' % (qq(symtab[node]), j, qq(symtab[child])))
emit(' %s:"con%d" -> %s' % (qq(symtab[id(node)]), j, qq(symtab[id(child)])))
#emit('}')
emit('')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment