Commits

Fernando G N Rocha  committed a3ea946

Added __str__

  • Participants
  • Parent commits e5fd775

Comments (0)

Files changed (1)

File automaton.py

 #!/usr/bin/python
+# -*- coding: utf-8 -*-
 '''
 Automata Simplification
 
         self.states = states
         self.initial = states[0]
 
+    def __str__(self):
+        M = '\nM = (Q, Σ, δ, {0}, F)\n'.format(self.initial) + \
+            'Q = {0}\n'.format(self.states) + \
+            'Σ = {0}\n'.format(self.alphabet) + \
+            'δ = {0}\n'.format(self.delta) + \
+            'F = {0}\n'.format(self.final_states)
+        return M
+
     def to_pygraphviz(self):
         '''Convert the automaton to graph format, for drawing'''
         graph = pgv.AGraph(directed=True) #specify dot format?
         return graph
             
        
-#Q0 = {'0':['q1','q2']}
-#Q1 = {'1':['q1'], 'E':['q2']}
-#Q2 = {'1':['q2','q3'], 'E':['q1']}
-#Q3 = {}
-#A = Automaton(['0', '1', 'E'], ['q3'], {'q0':Q0, 'q1':Q1, 'q2':Q2, 'q3':Q3})
+Q0 = {'0':['q1','q2']}
+Q1 = {'1':['q1'], 'E':['q2']}
+Q2 = {'1':['q2','q3'], 'E':['q1']}
+Q3 = {}
+A = Automaton(['0', '1', 'E'], ['q3'], {'q0':Q0, 'q1':Q1, 'q2':Q2, 'q3':Q3})
 #G = A.to_pygraphviz()
 #G.layout(prog='dot')
 #G.draw('teste.png')
 #         'e5': {'0': ['e5']},
 #         'e6': {'0': ['e7']},
 #         'e7': {'1': ['e4']}}
-##Add verify for only strings?
+#Add verify for only strings?
 #B = Automaton(['0','1'], ['e3', 'e4', 'e5', 'e7'], delta)
+#print (A)
+#print (B)
 #G = B.to_pygraphviz()
 #G.layout(prog='dot')
 #G.draw('afd.png')