Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
70da0a60
Commit
70da0a60
authored
Jun 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
11538410
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+31
-9
No files found.
wcfs/internal/xbtree.py
View file @
70da0a60
...
...
@@ -18,8 +18,6 @@
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
# XXX review
"""Package xbtree provides utilities for inspecting/manipulating internal
structure of integer-keyed BTrees.
...
...
@@ -990,6 +988,7 @@ def graphviz(t, clustername=''):
assert
isinstance
(
t
,
Tree
)
symtab
=
{}
# id(node) -> name
valtab
=
{}
# value -> name
outv
=
[]
def
emit
(
text
):
...
...
@@ -1001,8 +1000,6 @@ def graphviz(t, clustername=''):
for
(
level
,
nodev
)
in
enumerate
(
_walkBFS
(
t
)):
for
(
i
,
node
)
in
enumerate
(
nodev
):
assert
isinstance
(
node
,
(
Tree
,
Bucket
))
# TODO show Bucket values in triangles
# register node in symtab
assert
id
(
node
)
not
in
symtab
kind
=
(
'T'
if
isinstance
(
node
,
Tree
)
else
'B'
)
...
...
@@ -1032,17 +1029,42 @@ def graphviz(t, clustername=''):
emit
(
' </table>>'
)
emit
(
' ]'
)
# second pass: emit links + node ranks
# emit values
if
kind
==
'B'
and
node
.
valuev
is
not
None
:
assert
len
(
node
.
keyv
)
==
len
(
node
.
valuev
)
for
(
j
,
key
)
in
enumerate
(
node
.
keyv
):
v
=
node
.
valuev
[
j
]
valtab
[
v
]
=
'%sV%s'
%
(
clustername
+
'_'
,
v
)
# second pass: emit links + node ranks + links to values
for
nodev
in
_walkBFS
(
t
):
# same rank for nodes on the same level
emit
(
''
)
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
[
id
(
node
)]),
j
,
qq
(
symtab
[
id
(
child
)])))
assert
isinstance
(
node
,
(
Tree
,
Bucket
))
if
isinstance
(
node
,
Tree
):
for
(
j
,
child
)
in
enumerate
(
node
.
children
):
emit
(
' %s:"con%d" -> %s'
%
(
qq
(
symtab
[
id
(
node
)]),
j
,
qq
(
symtab
[
id
(
child
)])))
elif
node
.
valuev
is
not
None
:
assert
len
(
node
.
valuev
)
==
len
(
node
.
keyv
)
for
(
j
,
key
)
in
enumerate
(
node
.
keyv
):
emit
(
' %s:"key%d" -> %s'
%
(
qq
(
symtab
[
id
(
node
)]),
j
,
valtab
[
node
.
valuev
[
j
]]))
# third pass: emit values
emit
(
''
)
for
v
in
sorted
(
valtab
):
emit
(
' %s'
%
qq
(
valtab
[
v
]))
emit
(
' ['
)
emit
(
' shape = plain'
)
emit
(
' label = "%s"'
%
v
)
emit
(
' margin = 0'
)
emit
(
' height = 0'
)
emit
(
' width = 0'
)
emit
(
' ]'
)
#emit('}')
emit
(
''
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment