From 110c0c9ebe979b1880619300d6c4b315e4889f61 Mon Sep 17 00:00:00 2001 From: kilian Date: Fri, 21 Aug 2026 12:43:46 +0200 Subject: [PATCH] Dateien nach "mod/butadien" hochladen --- mod/butadien/dottodict.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 mod/butadien/dottodict.py diff --git a/mod/butadien/dottodict.py b/mod/butadien/dottodict.py new file mode 100644 index 0000000..51e45f2 --- /dev/null +++ b/mod/butadien/dottodict.py @@ -0,0 +1,22 @@ +#import pydot +import re + +#graph = pydot.graph_from_dot_file("out/014_dg_0_11100.dot") + +#for edge in graph: + #dir(edge) + +HYPERGRAPH = {} + +with open('out/014_dg_0_11100.dot', 'r') as file: + graph = file.read() + #print(re.findall( "// id = [0-9]+\\{ ('Butadien' |'p_\\{0,[0-9]\\} ){1,2}\\}, 'r_\\{[0|1]\\}', \\{ ('Butadien' |'p_\\{0,[0-9]\\} ){1,2}\\}", graph)[0]) + for edge in re.findall( "// id = [0-9]+\\{ [A-Za-z0-9_,{} ']+ \\}, 'r_\\{[0|1]\\}', \\{ [A-Za-z0-9_,{} ']+ \\}", graph): + #print(edge) + index = int(re.findall("(?<=id = )(.*?)(?=\\{)", edge)[0]) + educts = re.findall("(?<=\\{)(.*?)(?=\\}, 'r_\\{[0-1]\\}',)", edge)[0] + educt = re.findall("(?<= ')(.*?)(?=' )", educts) + products = re.findall("(?<='r_\\{[0-1]\\}', \\{)(.*?)(?=\\})", edge)[0] + product = re.findall("(?<= ')(.*?)(?=' )", products) + HYPERGRAPH[index] = (educt, product) + print(HYPERGRAPH) \ No newline at end of file