def traversierung_bfs(graph, start): """Returns the list of nodes in graph reachable from start, in breadth-first order.""" sequence=[] # list of nodes in breadth-first order candidates = [start] # known nodes we should process while candidates: # Handle the next candidate: # - remove from list # - if not visited yet: add to sequence and add its neighbors node = candidates.pop(0) if node in sequence: continue sequence.append(node) for neighbor in graph[node]: candidates.append(neighbor) return sequence print("bfs: ", traversierung_bfs(graph, "ksr"))