Your question is Breadth-First Search Level Order. 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.
Delta DIAView can represent relationships among industrial assets such as controllers, sensors, and gateways. Given this relationship graph and a starting asset, return all reachable assets grouped in breadth-first level order.
Implement bfs_levels(graph, start). The input graph is a dictionary mapping each asset ID to a list of directly connected asset IDs. Treat edges as directed from each key to its listed neighbors. The start asset is guaranteed to exist in graph. Return a list of lists, where the first list contains start, and each subsequent list contains the assets at the corresponding shortest edge distance from start.
Visit each asset at most once. Preserve the order in which neighbors appear in the input lists. Assets that are not reachable from start must not appear in the result.
def bfs_levels(graph, start):