Commit 08af14ed by Ondrej Platek

reimplement draw_dot(now to_dot) for current dep. graph

parent 0599fd07
...@@ -129,7 +129,7 @@ class DependencyGraph(object): ...@@ -129,7 +129,7 @@ class DependencyGraph(object):
""" """
return node_address in self.nodes return node_address in self.nodes
def draw_dot(self): def to_dot(self):
""" """
Returns a dot representation suitable for using with Graphviz Returns a dot representation suitable for using with Graphviz
@rtype C{String} @rtype C{String}
...@@ -139,13 +139,14 @@ class DependencyGraph(object): ...@@ -139,13 +139,14 @@ class DependencyGraph(object):
s += 'edge [dir=forward]\n' s += 'edge [dir=forward]\n'
s += 'node [shape=plaintext]\n' s += 'node [shape=plaintext]\n'
# Draw the remaining nodes # Draw the remaining nodes
for head, h_node in self.nodes.iteritems(): for node in sorted(self.nodes.values()):
s += '\n%s [label="%s (%s)"]' % (h_node['address'], h_node['address'], h_node['word']) s += '\n%s [label="%s (%s)"]' % (node['address'], node['address'], node['word'])
if head != 0: # not TOP for rel, deps in node['deps'].iteritems():
if h_node['rel'] != '_': for dep in deps:
s += '\n%s -> %s [label="%s"]' % (h_node['head'], h_node['address'], h_node['rel']) if rel != None:
else: s += '\n%s -> %s [label="%s"]' % (node['address'], dep, rel)
s += '\n%s -> %s ' % (h_node['head'], h_node['address']) else:
s += '\n%s -> %s ' % (node['address'], dep)
s += "\n}" s += "\n}"
return s return s
......
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