-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphcreator.py
52 lines (37 loc) · 1.37 KB
/
graphcreator.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
dictlist=[]
size=3
punkter=[]
for i in range(1,size+1):
for j in range(1,size+1):
punkter.append((i,j))
print(punkter)
for i in punkter:
#övre vänstra
if i[0]==1 and i[1]==1:
dictionary={i:((i[0]+1,i[1]),(i[0],i[1]+1))}
#vänstra sidan
elif i[0]==1 and not i[1]==1 and not i[1]==size:
dictionary={i:((i[0]+1,i[1]),(i[0],i[1]+1),(i[0],i[1]-1))}
#övre sidan
elif not i[0]==1 and not i[0]==size and i[1]==1:
dictionary={i:((i[0]+1,i[1]),(i[0],i[1]+1),(i[0]-1,i[1]))}
#nedre vänstra
elif i[0]==1 and i[1]==size:
dictionary={i:((i[0]+1,i[1]),(i[0],i[1]-1))}
#nedre sidan
elif not i[0]==1 and not i[0]==size and i[1]==size :
dictionary={i:((i[0]+1,i[1]),(i[0]-1,i[1]),(i[0],i[1]-1))}
#nedre högra
elif i[0]==size and i[1]==size:
dictionary={i:((i[0]-1,i[1]),(i[0],i[1]-1))}
#högra sidan
elif i[0]==size and not i[1]==size and not i[1]==1:
dictionary={i:((i[0]-1,i[1]),(i[0],i[1]+1),(i[0],i[1]-1))}
#övre högra
elif i[0]==size and i[1]==1:
dictionary={i:((i[0]-1,i[1]),(i[0],i[1]+1))}
#mittbit
else :
dictionary={i:((i[0]-1,i[1]),(i[0]+1,i[1]),(i[0],i[1]+1),(i[0],i[1]-1))}
dictlist.append(dictionary)
print (dictlist)