Breadth First Search Traversal

Given an undirected graph with vertices numbered from 0 through n - 1 and an edge list edges, perform breadth-first search from start and return the order in which reachable vertices are visited.

Build each adjacency list by reading the edge list in input order: for edge edges[i] = [u, v], append v to the list of u and append u to the list of v. When a vertex has several unvisited neighbors, inspect its adjacency list from the first appended entry to the last. Mark a vertex when it is enqueued, so cycles and repeated edges never enqueue it twice. Unreachable vertices are not returned.

Examples
Input: [1,[],0]
Output: [0]
Hints

Breadth First Search Traversal

Given an undirected graph with vertices numbered from `0` through `n - 1` and an edge list `edges`, perform breadth-first search from `start` and return the order in which reachable vertices are visited.