diff --git a/src/irpf90.py b/src/irpf90.py index 5f8b755..456b941 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -58,7 +58,7 @@ def main(): # Create a dot reprenstion of the dependency graph. # Merge inside a subgraph the Entity provided together comm_world.t_filename_parsed_text # Initialize entity need. Dirty I know. - from util import mangled + from util import mangled, l_dummy_entity print 'digraph { ' @@ -72,7 +72,14 @@ def main(): print ' subgraph cluster%s {' % name print ' %s ' % ' '.join([entity.name] + entity.others_entity_name) print ' }' - print '}' + + for i,s in enumerate(l_dummy_entity(comm_world.d_entity)): + print ' subgraph cluster%s {' % i + print ' %s ' % ' '.join(s) + print ' color = blue' + print ' }' + print '}' + return diff --git a/src/util.py b/src/util.py index 7072a3a..8717408 100644 --- a/src/util.py +++ b/src/util.py @@ -308,3 +308,26 @@ def build_call_provide(l_ent, d_ent): return flatten(map(bld_f90, l_same_as)) +def che_merge(sets): + #(List[Set] -> List[Set] + """Merge a list of set is they are not disjoint. + Note: + This will destry sets + """ + results = [] + upd, isd, pop = set.update, set.isdisjoint, sets.pop + while sets: + if not [upd(sets[0],pop(i)) for i in range(len(sets)-1,0,-1) if not isd(sets[0],sets[i])]: + results.append(pop(0)) + return results + + +def l_dummy_entity(d_entity): + from itertools import combinations + l_candidate_botom = [ (i,j) for i,j in combinations(d_entity.keys(),2) if d_entity[i].children == d_entity[j].children] + l_dummy = [set([i,j]) for i,j in l_candidate_botom if d_entity[i].parents == d_entity[j].parents] + + return che_merge(l_dummy) + + +