Skip to content

Commit

Permalink
Merge pull request #6 from rohaquinlop/dev
Browse files Browse the repository at this point in the history
feat(view): #4 enable graphviz customization
  • Loading branch information
rohaquinlop authored Nov 5, 2023
2 parents d8f7558 + 5c1ebd3 commit 4e2f798
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions automathon/finiteAutomata/dfa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Exceptions module
from __future__ import annotations

from automathon.errors.errors import *
from collections import deque
from graphviz import Digraph
Expand Down Expand Up @@ -218,8 +220,8 @@ def union(self, M: 'DFA') -> 'DFA':

return tmp_nfa.get_dfa()

def view(self, fileName: str):
dot = Digraph(name=fileName, format='png')
def view(self, file_name: str, node_attr: dict[str, str] | None = None, edge_attr: dict[str, str] | None = None):
dot = Digraph(name=file_name, format='png', node_attr=node_attr, edge_attr=edge_attr)

dot.graph_attr['rankdir'] = 'LR'

Expand Down
6 changes: 4 additions & 2 deletions automathon/finiteAutomata/nfa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Exceptions module
from __future__ import annotations

from automathon.errors.errors import *
from collections import deque
from graphviz import Digraph
Expand Down Expand Up @@ -400,8 +402,8 @@ def product(self, M: 'NFA') -> 'NFA':

return nfa

def view(self, file_name: str):
dot = Digraph(name=file_name, format='png')
def view(self, file_name: str, node_attr: dict[str, str] | None = None, edge_attr: dict[str, str] | None = None):
dot = Digraph(name=file_name, format='png', node_attr=node_attr, edge_attr=edge_attr)

dot.graph_attr['rankdir'] = 'LR'

Expand Down
4 changes: 4 additions & 0 deletions tests/test_nfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,7 @@ def test_renumber(self):
automata_4.renumber()

self.assertTrue(automata_4.is_valid())


if __name__ == '__main__':
unittest.main()

0 comments on commit 4e2f798

Please sign in to comment.