Google Interview Question

Simple bfs problem and one MST