public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {//AC
        if (node == null) return null;
        java.util.LinkedList<UndirectedGraphNode> queue = new java.util.LinkedList<UndirectedGraphNode>();
        HashMap<UndirectedGraphNode, UndirectedGraphNode> map = new HashMap<UndirectedGraphNode, UndirectedGraphNode>();
        UndirectedGraphNode copy = new UndirectedGraphNode(node.label);
        map.put(node, copy);
        // use a queue to do breadth first traversal
        queue.offer(node);
        while (!queue.isEmpty())
        {
        	UndirectedGraphNode cur = queue.poll();
        	// traverse the current node's neighbors
        	for (int i = 0; i < cur.neighbors.size(); ++i)
        	{
        		// if this node is not visited, then copy it
        		if (!map.containsKey(cur.neighbors.get(i)))
        		{
        			copy = new UndirectedGraphNode(cur.neighbors.get(i).label);
        			map.put(cur.neighbors.get(i), copy);
        			queue.offer(cur.neighbors.get(i));
        		}
        		// copy the neighbors
        		map.get(cur).neighbors.add(map.get(cur.neighbors.get(i)));
        	}
        }
        // return the corresponding node
        return map.get(node);
    }