-
Notifications
You must be signed in to change notification settings - Fork 0
/
nano_topology.py
56 lines (56 loc) · 1.24 KB
/
nano_topology.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def vh(s):
if s==[]:
return[s]
sets=[s]
for i in range(0,len(s)):
tmp=vh(s[:i]+s[(i+1):])
for sub in tmp:
if sub not in sets:
sets.append(sub)
return sets
def lower_approximation(vh,d):
temp=set()
ru=[]
for m in vh:
for n in m:
temp=temp.union(set(d[n]))
ru.append(list(temp))
temp=set()
return ru
def upper_approximation(vh,d):
rl=[]
temp=[]
for i in vh:
for j in i:
if(set(d[j]).issubset(set(i))):
temp.append(j)
rl.append(temp)
temp=[]
return rl
def boundary_region(a,b):
sym=[]
for i,j in zip(a,b):
x=set(i).symmetric_difference(j)
sym.append(list(x))
return sym
def nanoset(a,b,c):
final=[]
for j in range(len(a)):
if(a[j]==b[j]==c[j]):
result=a[j]
elif(a[j]==b[j]):
result=a[j]+c[j]
elif(a[j]==c[j]):
result=a[j]+b[j]
elif(b[j]==c[j]):
result=a[j]+b[j]
else:
result=a[j]+b[j]+c[j]
final.append(result)
return final
def singleton(x,y):
result=[]
for a,b in zip(x,y):
if(len(a)==1):
result.append(b)
return result