-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbfs.py
More file actions
29 lines (21 loc) · 749 Bytes
/
bfs.py
File metadata and controls
29 lines (21 loc) · 749 Bytes
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
import time
def bfs(main, node):
graf = main.graf
# definisemo prazan red sa pocetnim cvorom
red = [node]
poseceni = [node]
# petlja dok postoji cvorova u redu
while (len(red)):
cur = red.pop(0)
main.izvrsiNaredbu(main.selectCvor, cur)
time.sleep(1)
# prolazimo kroz sve komsije
for ngb in graf.dohvatiVeze(cur):
main.izvrsiNaredbu(main.selectGranu, ngb, cur)
time.sleep(1)
# provera da li je komsija posecen
if (ngb not in poseceni):
red.append(ngb)
poseceni.append(ngb)
main.izvrsiNaredbu(main.disselectGranu, ngb, cur)
main.izvrsiNaredbu(main.selectCvor, cur, 'gray75')