public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {
        if(node == null) return null;
    	
        HashMap<Integer, UndirectedGraphNode> visited = new HashMap<Integer, UndirectedGraphNode>();
        HashMap<Integer, UndirectedGraphNode> newNodes = new HashMap<Integer, UndirectedGraphNode>();
        LinkedList<UndirectedGraphNode> stack = new LinkedList<UndirectedGraphNode>();
        
        stack.add(node);
        visited.put(node.label, node);
        newNodes.put(node.label, new UndirectedGraphNode(node.label));
        
        while(stack.size() != 0){
        	UndirectedGraphNode oldNode = stack.getLast(), newNode = newNodes.get(oldNode.label);
        	stack.removeLast();
        	
	        for(UndirectedGraphNode i : oldNode.neighbors){
	        	if(visited.containsKey(i.label) == false){
	        		visited.put(i.label, i);
	        		newNodes.put(i.label, new UndirectedGraphNode(i.label));
	        		stack.addLast(i);
	        	}
	        	
	        	newNode.neighbors.add(newNodes.get(i.label));
	        }
	        
        }
        return newNodes.get(node.label);
    }