Your question is Breadth-First Search in Practice. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Amaris Consulting engineers model connected project components as a directed graph. Implement breadth-first search to visit every node reachable from a specified starting component, processing neighbors in the order provided.
Return the list of visited node names in BFS order. Each node must appear at most once, even when the graph contains cycles or multiple paths to the same node.
Implement bfs_traversal(graph, start), where graph is a dictionary mapping a node name to a list of its directly connected neighbor names, and start is a node name. Return a list of node names in breadth-first order. The input guarantees that start exists in graph.
Use a queue to process nodes level by level. Nodes that are not reachable from start must not appear in the result.
def bfs_traversal(graph, start):