public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {
        // write your code here
        if (node == null)
            return null;
        HashMap<UndirectedGraphNode, UndirectedGraphNode> map = new HashMap<UndirectedGraphNode, UndirectedGraphNode>();
        Queue<UndirectedGraphNode> queue = new LinkedList<UndirectedGraphNode>();
        queue.offer(node);
        map.put(node, new UndirectedGraphNode(node.label));
        // create new node
        while (!queue.isEmpty()) {
            UndirectedGraphNode element = queue.poll();
            for (UndirectedGraphNode neighbor : element.neighbors) {
                if (!map.containsKey(neighbor)) {
                    queue.offer(neighbor);
                    map.put(neighbor, new UndirectedGraphNode(neighbor.label));
                }
            }
        }
        // make the neighbors
        for (Map.Entry<UndirectedGraphNode, UndirectedGraphNode> entry : map.entrySet()) {
            UndirectedGraphNode element = entry.getKey();
            for (UndirectedGraphNode neighbor : element.neighbors) {
                map.get(element).neighbors.add(map.get(neighbor));
            }
        }
        return map.get(node);
    }