better p format

This commit is contained in:
Tomasz Obrebski 2014-03-10 16:20:00 +01:00
parent f600a028c0
commit f924e4be28

View File

@ -232,17 +232,40 @@ def printtree_dgp(root,arcs,o)
end
end
# old:
# def printpar(root,arcs)
# print nodeinfo(root)
# deps = arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] }
# unless deps == []
# print '('
# cont=false
# for arc in deps
# if cont then print ',' else cont=true end
# print arc[2],':' if $INFO =~ /l/
# printpar(arc[1],arcs)
# end
# print ')'
# end
# end
def printpar(root,arcs)
print nodeinfo(root)
deps = arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] }
unless deps == []
print '('
cont=false
for arc in deps
if cont then print ',' else cont=true end
print arc[2],':' if $INFO =~ /l/
printpar(arc[1],arcs)
end
ldeps = arcs.select{|a| a[0]==root and $gphid[a[1]] < $gphid[root]}.sort{|a,b| $gphid[a[1]]<=>$gphid[b[1]] }
rdeps = arcs.select{|a| a[0]==root and $gphid[a[1]] > $gphid[root]}.sort{|a,b| $gphid[a[1]]<=>$gphid[b[1]] }
for arc in ldeps
print ' ('
print arc[2].upcase if $INFO =~ /l/
printpar(arc[1],arcs)
print ')'
end
print ' ',nodeinfo(root)
for arc in rdeps
print ' ('
print arc[2].upcase if $INFO =~ /l/
printpar(arc[1],arcs)
print ')'
end
end