You are given the reference of a node in a connected undirected graph.
Return a deep copy (clone) of the graph.
Each node in the graph contains a value and a list of its neighbors.
There are n nodes in the graph each with a unique value from 0 to n-1.
class Node {
public int value;
public List<Node> neighbors;
}
The given node will have a value of 0. You need to return a copy of this node as a reference to the cloned graph.
The first line contains an integer T denoting the number of test cases.
For each test case, the input has the following lines:
For each test case, the output has n lines, one for each node and its neighbors in order. Each line has the number of neighbors and then the neighbors as space-separated integers representing the adjacency list.
2
4
3 1 2 3
1 0
2 0 3
2 0 2
4
3 1 2 3
1 0
2 0 3
3 0 2 3
3 1 2 3
1 0
2 0 3
2 0 2
3 1 2 3
1 0
2 0 3
3 0 2 3
1 <= T <= 10
1 <= n <= 500
0 <= m < n