diff --git a/BFS/bfs.py b/BFS/bfs.py deleted file mode 100644 index 4ef39bbf..00000000 --- a/BFS/bfs.py +++ /dev/null @@ -1,20 +0,0 @@ -import collections - - -def bfs(graph, root): - visited, queue = set(), collections.deque([root]) - # While we still have nodes to visit - while queue: - vertex = queue.popleft() - # Add neighbours of current node to queue if they - # haven't been visited yet and mark them as visited. - for neighbour in graph[vertex]: - if neighbour not in visited: - visited.add(neighbour) - queue.append(neighbour) - - -if __name__ == '__main__': - # sample input format below - graph = {0: [1, 2], 1: [2], 2: []} - bfs(graph, 0)