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
553ef8bf
Commit
553ef8bf
authored
May 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5d7c4811
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+25
-12
No files found.
wcfs/internal/xbtree.py
View file @
553ef8bf
...
...
@@ -434,16 +434,16 @@ import sys
# graphviz returns tree graph representation in dot language.
@
func
(
Tree
)
def
graphviz
(
t
):
def
graphviz
(
t
,
clustername
=
''
):
assert
isinstance
(
t
,
Tree
)
symtab
=
{}
# node -> name
outv
=
[]
def
emit
(
line
):
outv
.
append
(
line
)
def
emit
(
text
):
outv
.
append
(
text
)
emit
(
'digraph {'
)
#emit('subgraph %s {' % clustername) FIXME kills arrows
emit
(
' splines=false'
)
for
(
level
,
nodev
)
in
enumerate
(
_walkBFS
(
t
)):
...
...
@@ -453,7 +453,7 @@ def graphviz(t):
# register node insymtab
assert
node
not
in
symtab
kind
=
(
'T'
if
isinstance
(
node
,
Tree
)
else
'B'
)
symtab
[
node
]
=
'%s%
d:%d'
%
(
kind
,
level
,
i
)
symtab
[
node
]
=
'%s%
s%d:%d'
%
(
clustername
+
'_'
,
kind
,
level
,
i
)
# emit node itself
# approach based on https://github.com/Felerius/btree-generator
...
...
@@ -490,8 +490,8 @@ def graphviz(t):
continue
for
(
j
,
child
)
in
enumerate
(
node
.
children
):
emit
(
' %s:"con%d" -> %s'
%
(
qq
(
symtab
[
node
]),
j
,
qq
(
symtab
[
child
])))
#emit('}')
emit
(
'}'
)
emit
(
''
)
return
'
\
n
'
.
join
(
outv
)
...
...
@@ -501,14 +501,27 @@ def topoview(argv):
if
len
(
argv
)
==
0
:
raise
RuntimeError
(
'E: empty argument'
)
topov
=
[
TopoDecode
(
_
)
for
_
in
argv
]
treev
=
[
TopoDecode
(
_
)
for
_
in
argv
]
outv
=
[]
def
emit
(
text
):
outv
.
append
(
text
)
emit
(
'digraph {'
)
emit
(
' label=%s'
%
qq
(
' '
.
join
(
argv
)))
emit
(
' labelloc="t"'
)
for
(
i
,
tree
)
in
enumerate
(
treev
):
emit
(
tree
.
graphviz
(
clustername
=
'c%d'
%
i
))
emit
(
'}'
)
import
graphviz
as
gv
#g = gv.Digraph(comment='AAA')
#print(g.render(format='pdf', view=True))
g
=
gv
.
Source
(
topov
[
0
].
graphviz
())
#g.view()
g
.
render
(
'x'
,
format
=
'svg'
)
g
=
gv
.
Source
(
'
\
n
'
.
join
(
outv
))
g
.
view
()
#g.render('x', format='svg')
if
__name__
==
'__main__'
:
...
...
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