#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)