Unity tooling can model scene, prefab, and asset dependencies as a directed graph. Given an adjacency-list representation and a starting asset, return the nodes visited by a breadth-first search, preserving the neighbor order provided in the input.
Implement bfs_graph(graph, start).
graph is a dictionary where each key is a node identifier and its value is a list of directly reachable node identifiers.start is a node identifier. It may be omitted from graph, in which case it has no outgoing edges.start, in BFS order.def bfs_graph(graph, start):