BFS:
#1.设置队列 from queue import Queue q = Queue() #2.设置closed表 closed = set()/[] #3.开始循环 while not q.empty(): #取出 a = q.get() #判断 if a not in cloesd : #进入closed并进入下一步 closed.add()/append() q.put()
2024-01-05 11:54:28
BFS:
#1.设置队列 from queue import Queue q = Queue() #2.设置closed表 closed = set()/[] #3.开始循环 while not q.empty(): #取出 a = q.get() #判断 if a not in cloesd : #进入closed并进入下一步 closed.add()/append() q.put()