From: Mart Lubbers Date: Thu, 10 Jul 2014 19:12:35 +0000 (+0200) Subject: removal of equal patterns X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=069c32912503385751c8aa46892d41311354e04c;p=bsc-thesis1415.git removal of equal patterns --- diff --git a/program/regexex/fsm.py b/program/regexex/fsm.py index 4d06244..5f833e6 100644 --- a/program/regexex/fsm.py +++ b/program/regexex/fsm.py @@ -153,9 +153,24 @@ class fsm(): # Remove the obsolete nodes if result: # Magic removal process - print result - print group - + res_nodes = [r[0] for r in result] + remove = [] + for n in group[0]: + if n not in res_nodes: + remove.append(n) + + indices = [] + for i, k in enumerate(self.subgraphs['none'][0]): + if k[0] in remove: + indices.insert(0, i) + for i in indices: + del(self.subgraphs['none'][0][i]) + indices = [] + for i, c in enumerate(self.subgraphs['none'][1]): + if c[0] in remove or c[1] in remove: + indices.insert(0, i) + for i in indices: + del(self.subgraphs['none'][1][i]) def process_multipath(self, path): """Looks for possible merge candidates @@ -182,7 +197,6 @@ class fsm(): # Magic pass - def walk(self, current, conn, currents=[], strings=[], vis=set()): """Walk the graph and keep track of vis conn