From 069c32912503385751c8aa46892d41311354e04c Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Thu, 10 Jul 2014 21:12:35 +0200 Subject: [PATCH] removal of equal patterns --- program/regexex/fsm.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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 -- 2.20.1