Problem Description: 
 
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ ' s undirected graph serialization:
 
Nodes is labeled uniquely. We use # as a separator for each node, and, as a separator for node label and each neighbor of the node.
 
 
As an example, consider the serialized graph {0,1,2#1,2#2,2}.
 
The graph has a total of three nodes, and therefore contains three parts as separated by #. First node is labeled as 0. Connect node 0 to both nodes 1 and 2. Second node is labeled as 1. Connect Node 1 to Node 2. Third node is labeled as 2. Connect Node 2 to Node 2 (itself), thus forming a self-cycle.
 
 
Visually, the graph looks like the following:
 
       1
      /\
     /   \
    0---2
         /\
         \_/
 
 
Code:
 
Undirectedgraphnode *clonegraph (Undirectedgraphnode *node) {//c++ if (node = = NULL) return null;
        Set<int> visited;
        Map<int,undirectedgraphnode*> MyMap;
        Queue<undirectedgraphnode*> Myqueue;
        
        Undirectedgraphnode *head,*p,*temp,*one;
        Myqueue.push (node);
        bool IsFirst = true;
            do {p = Myqueue.front ();
                if (isFirst) {temp = new Undirectedgraphnode (P->label);
                head= temp;
                Mymap.insert (Make_pair (p->label,temp));
            IsFirst = false;
            } Else temp = mymap[p->label];
            Vector<undirectedgraphnode*> VEC;
                for (int i=0; i< (p->neighbors). Size (); i++) {int label = (p->neighbors) [i]->label;
                if (mymap.count (label)!=0) one = Mymap[label];
       else {             one = new Undirectedgraphnode (label);
                Mymap.insert (Make_pair (Label,one));
                } vec.push_back (one);
            if (visited.count (label) ==0) Myqueue.push (P->neighbors[i]);
            } temp->neighbors = VEC;
            Myqueue.pop ();
        Visited.insert (P->label);
        }while (!myqueue.empty ());
    return head; }