BFS_Python
BFS_Python
class Graph:
def __init__(self):
self.graph = nx.Graph()
while queue:
node = queue.popleft()
traversal_order.append(node)
g = Graph()
num_edges = int(input("Enter the number of edges: "))
g.bfs(start_node)
Sample Input/Output
Sample Input:
Enter the number of edges: 6
Enter the edges (u v):
01
02
13
14
25
26
Enter the starting node for BFS: 0
Sample Output:
BFS Traversal Order:
0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6