summaryrefslogtreecommitdiff
path: root/python/src/lattice.pxi
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2012-07-06 11:45:32 +0200
committerPatrick Simianer <p@simianer.de>2012-07-06 11:45:32 +0200
commit45a1af0ff9c164978f91b2734fb24c45551aa25c (patch)
treea3cb13ccc47386b2e51e1fb50fa9a96d5d7fa905 /python/src/lattice.pxi
parent4ec3625b3a1aa9cb417f8a551ad6723626a4c656 (diff)
parent757f56e391bd2e1d7442ab38fc98aff00d064d38 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/src/lattice.pxi')
-rw-r--r--python/src/lattice.pxi12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/src/lattice.pxi b/python/src/lattice.pxi
index 493c6dcd..f8341e29 100644
--- a/python/src/lattice.pxi
+++ b/python/src/lattice.pxi
@@ -54,3 +54,15 @@ cdef class Lattice:
def __dealloc__(self):
del self.lattice
+
+ def todot(self):
+ def lines():
+ yield 'digraph lattice {'
+ yield 'rankdir = LR;'
+ yield 'node [shape=circle];'
+ for i in range(len(self)):
+ for label, weight, delta in self[i]:
+ yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"'))
+ yield '%d [shape=doublecircle]' % len(self)
+ yield '}'
+ return '\n'.join(lines()).encode('utf8')