arr = {'a': [1,2,3], 'b': [6,7,8], 'c': [7,11,2], 'e': [45,2,10]}
res_arr = []
for key, value in arr.items():
for v in value:
for r in res_arr:
if v in r['key']:
r['value'].add(key)
break
else:
res_arr.append({
'key': set([v]),
'value': set([key])
})
res_dict = {}
for r in res_arr:
key = ','.join(r['value'])
if res_dict.get(key):
res_dict[key].extend(r['key'])
else:
res_dict[key] = list(r['key'])