-
Notifications
You must be signed in to change notification settings - Fork 0
/
traces_theory.py
34 lines (21 loc) · 1.01 KB
/
traces_theory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from utility import input_to_matrix, load_input, save_graph_as_DOT, save_traces_theory_output
from tools import calculate_operations, calculate_dependence, gauss_as_symbols, diekert_graph, get_foaty, get_alphabet
from graphviz import Source
import os
def traces_run(input, output, force_graph):
matrix, vector = input_to_matrix(load_input(input))
operations = calculate_operations(matrix)
symbols = gauss_as_symbols(matrix)
alphabet = get_alphabet(symbols)
w = alphabet
D = calculate_dependence(symbols)
G = diekert_graph(alphabet, D)
foaty = get_foaty(w)
if len(matrix) <= 10 or force_graph:
os.makedirs('tmp', exist_ok=True)
save_graph_as_DOT(G, alphabet, 'tmp/G.dot')
source = Source.from_file('tmp/G.dot')
source.render(output + '/diekert_graph', format='png', view=False, cleanup=True)
os.remove('tmp/G.dot')
os.rmdir('tmp')
save_traces_theory_output(alphabet, D, w, foaty, output + "/traces_theory_output.txt")