changeset 64:c7d03c2e6e29

Graph.to_dot now takes a file argument.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Wed, 27 May 2009 11:58:09 +0200
parents b60bb8512736
children 8cd61403ce80
files pysmcl/graph.py
diffstat 1 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/graph.py	Wed May 27 11:52:28 2009 +0200
+++ b/pysmcl/graph.py	Wed May 27 11:58:09 2009 +0200
@@ -14,15 +14,12 @@
 
     def __init__(self, entry):
         self.entry = entry
-#         self.ex = ex
 
-    def to_dot(self):
+    def to_dot(self, output):
         taken = set()
-        print "digraph G {"
-        print "  in -> %s" % self.entry.nr
-        print '  in [shape = plaintext, label=""]'
-#         print "  %s -> out" % self.ex.nr
-#         print '  out [shape = plaintext, label=""]'
+        print >>output, "digraph G {"
+        print >>output, "  in -> %s" % self.entry.nr
+        print >>output, '  in [shape = plaintext, label=""]'
         stack = [self.entry]
         while(True):
             while(True):
@@ -34,10 +31,10 @@
                     break
             if not current:
                 break
-            print '    %s [label="%s"]' % (current.nr, current.msg)
+            print >>output, '    %s [label="%s"]' % (current.nr, current.msg)
             taken.add(current)
             for i in current.out:
-                print "    %s->%s;" % (current.nr, i.nr)
+                print >>output, "    %s->%s;" % (current.nr, i.nr)
 
             stack += current.out # list concatenation
-        print "}"
+        print >>output, "}"